( options ...ForceAuthenticateOption, )
| 189 | } |
| 190 | |
| 191 | func (tc *TestContext) forceAuthenticate( |
| 192 | options ...ForceAuthenticateOption, |
| 193 | ) *domainmodels.OrganizationUser { |
| 194 | opts := &ForceAuthenticateOptions{} |
| 195 | for _, opt := range options { |
| 196 | opt(opts) |
| 197 | } |
| 198 | email := uuid.NewString() + "@home.arpa" |
| 199 | orgUser, err := tc.identityRepo.CreateUserWithOrganization( |
| 200 | email, |
| 201 | uuid.NewString(), |
| 202 | "password", |
| 203 | ) |
| 204 | if err != nil { |
| 205 | tc.tObj.Fatal(err) |
| 206 | } |
| 207 | if opts.IsSiteOwner { |
| 208 | tc.identityRepo.AddRoleToOrganizationUser(orgUser.Id, "site_owner") |
| 209 | orgUser = tc.identityRepo.GetOrganizationUserById(orgUser.Id) |
| 210 | } |
| 211 | var resp struct { |
| 212 | Authenticate *model.ViewerResult |
| 213 | } |
| 214 | err = tc.client.Post(` |
| 215 | mutation auth($email: String!, $password: String!) { |
| 216 | authenticate(email: $email, password: $password) { |
| 217 | viewer { |
| 218 | id |
| 219 | organizationUser { |
| 220 | id |
| 221 | user { |
| 222 | id |
| 223 | |
| 224 | } |
| 225 | organization { |
| 226 | id |
| 227 | } |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 | }`, &resp, client.Var("email", orgUser.User.Email), client.Var("password", "password")) |
| 232 | if err != nil { |
| 233 | tc.tObj.Fatal(err) |
| 234 | } |
| 235 | if resp.Authenticate == nil { |
| 236 | tc.tObj.Fatal("auth failed") |
| 237 | } |
| 238 | if resp.Authenticate.Viewer.OrganizationUser.User.Email != email { |
| 239 | tc.tObj.Fatal("auth failed") |
| 240 | } |
| 241 | return orgUser |
| 242 | } |
no test coverage detected