(t *testing.T)
| 475 | } |
| 476 | |
| 477 | func TestEnterprisePostUser(t *testing.T) { |
| 478 | t.Parallel() |
| 479 | |
| 480 | t.Run("OrganizationNoAccess", func(t *testing.T) { |
| 481 | t.Parallel() |
| 482 | |
| 483 | dv := coderdtest.DeploymentValues(t) |
| 484 | client, first := coderdenttest.New(t, &coderdenttest.Options{ |
| 485 | Options: &coderdtest.Options{ |
| 486 | DeploymentValues: dv, |
| 487 | }, |
| 488 | LicenseOptions: &coderdenttest.LicenseOptions{ |
| 489 | Features: license.Features{ |
| 490 | codersdk.FeatureMultipleOrganizations: 1, |
| 491 | }, |
| 492 | }, |
| 493 | }) |
| 494 | |
| 495 | notInOrg, _ := coderdtest.CreateAnotherUser(t, client, first.OrganizationID) |
| 496 | other, _ := coderdtest.CreateAnotherUser(t, client, first.OrganizationID, rbac.RoleOwner(), rbac.RoleMember()) |
| 497 | |
| 498 | ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong) |
| 499 | defer cancel() |
| 500 | |
| 501 | org := coderdenttest.CreateOrganization(t, other, coderdenttest.CreateOrganizationOptions{}, func(request *codersdk.CreateOrganizationRequest) { |
| 502 | request.Name = "another" |
| 503 | }) |
| 504 | |
| 505 | _, err := notInOrg.CreateUserWithOrgs(ctx, codersdk.CreateUserRequestWithOrgs{ |
| 506 | Email: "some@domain.com", |
| 507 | Username: "anotheruser", |
| 508 | Password: "SomeSecurePassword!", |
| 509 | OrganizationIDs: []uuid.UUID{org.ID}, |
| 510 | }) |
| 511 | var apiErr *codersdk.Error |
| 512 | require.ErrorAs(t, err, &apiErr) |
| 513 | require.Equal(t, http.StatusNotFound, apiErr.StatusCode()) |
| 514 | }) |
| 515 | |
| 516 | t.Run("OrganizationNoAccess", func(t *testing.T) { |
| 517 | t.Parallel() |
| 518 | dv := coderdtest.DeploymentValues(t) |
| 519 | client, first := coderdenttest.New(t, &coderdenttest.Options{ |
| 520 | Options: &coderdtest.Options{ |
| 521 | DeploymentValues: dv, |
| 522 | }, |
| 523 | LicenseOptions: &coderdenttest.LicenseOptions{ |
| 524 | Features: license.Features{ |
| 525 | codersdk.FeatureMultipleOrganizations: 1, |
| 526 | }, |
| 527 | }, |
| 528 | }) |
| 529 | notInOrg, _ := coderdtest.CreateAnotherUser(t, client, first.OrganizationID) |
| 530 | other, _ := coderdtest.CreateAnotherUser(t, client, first.OrganizationID, rbac.RoleOwner(), rbac.RoleMember()) |
| 531 | |
| 532 | ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong) |
| 533 | defer cancel() |
| 534 |
nothing calls this directly
no test coverage detected