()
| 158 | } |
| 159 | |
| 160 | func (ts *PhoneTestSuite) TestMissingSmsProviderConfig() { |
| 161 | u, err := models.FindUserByPhoneAndAudience(ts.API.db, "123456789", ts.Config.JWT.Aud) |
| 162 | require.NoError(ts.T(), err) |
| 163 | now := time.Now() |
| 164 | u.PhoneConfirmedAt = &now |
| 165 | require.NoError(ts.T(), ts.API.db.Update(u), "Error updating new test user") |
| 166 | |
| 167 | s, err := models.NewSession(u.ID, nil) |
| 168 | require.NoError(ts.T(), err) |
| 169 | require.NoError(ts.T(), ts.API.db.Create(s)) |
| 170 | |
| 171 | req := httptest.NewRequest(http.MethodPost, "/token?grant_type=password", nil) |
| 172 | token, _, err := ts.API.generateAccessToken(req, ts.API.db, u, &s.ID, models.PasswordGrant) |
| 173 | require.NoError(ts.T(), err) |
| 174 | |
| 175 | cases := []struct { |
| 176 | desc string |
| 177 | endpoint string |
| 178 | method string |
| 179 | header string |
| 180 | body map[string]string |
| 181 | expected map[string]interface{} |
| 182 | }{ |
| 183 | { |
| 184 | desc: "Signup", |
| 185 | endpoint: "/signup", |
| 186 | method: http.MethodPost, |
| 187 | header: "", |
| 188 | body: map[string]string{ |
| 189 | "phone": "1234567890", |
| 190 | "password": "testpassword", |
| 191 | }, |
| 192 | expected: map[string]interface{}{ |
| 193 | "code": http.StatusInternalServerError, |
| 194 | "message": "Unable to get SMS provider", |
| 195 | }, |
| 196 | }, |
| 197 | { |
| 198 | desc: "Sms OTP", |
| 199 | endpoint: "/otp", |
| 200 | method: http.MethodPost, |
| 201 | header: "", |
| 202 | body: map[string]string{ |
| 203 | "phone": "123456789", |
| 204 | }, |
| 205 | expected: map[string]interface{}{ |
| 206 | "code": http.StatusInternalServerError, |
| 207 | "message": "Unable to get SMS provider", |
| 208 | }, |
| 209 | }, |
| 210 | { |
| 211 | desc: "Phone change", |
| 212 | endpoint: "/user", |
| 213 | method: http.MethodPut, |
| 214 | header: token, |
| 215 | body: map[string]string{ |
| 216 | "phone": "111111111", |
| 217 | }, |
nothing calls this directly
no test coverage detected