Skip to content

Commit

Permalink
is: Add restriction test to organization registry
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaspcr committed Jul 5, 2023
1 parent 46bb03d commit 01b8d2d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pkg/identityserver/organization_registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,32 @@ func TestOrganizationsCRUD(t *testing.T) {
a.So(updated.Name, should.Equal, "Updated Name")
}

t.Run("contact_info_restriction", func(t *testing.T) { // nolint:paralleltest
a, ctx := test.New(t)
is.config.Restrictions.Entity.RestrictContacts = true
t.Cleanup(func() { is.config.Restrictions.Entity.RestrictContacts = false })

_, err := reg.Update(ctx, &ttnpb.UpdateOrganizationRequest{
Organization: &ttnpb.Organization{
Ids: created.GetIds(),
Name: "Updated Name",
AdministrativeContact: usr2.GetOrganizationOrUserIdentifiers(),
},
FieldMask: ttnpb.FieldMask("name"),
}, creds)
a.So(errors.IsPermissionDenied(err), should.BeTrue)

_, err = reg.Update(ctx, &ttnpb.UpdateOrganizationRequest{
Organization: &ttnpb.Organization{
Ids: created.GetIds(),
Name: "Updated Name",
TechnicalContact: usr2.GetOrganizationOrUserIdentifiers(),
},
FieldMask: ttnpb.FieldMask("name"),
}, creds)
a.So(errors.IsPermissionDenied(err), should.BeTrue)
})

for _, collaborator := range []*ttnpb.OrganizationOrUserIdentifiers{nil, usr1.GetOrganizationOrUserIdentifiers()} {
list, err := reg.List(ctx, &ttnpb.ListOrganizationsRequest{
FieldMask: ttnpb.FieldMask("name"),
Expand Down

0 comments on commit 01b8d2d

Please sign in to comment.