Skip to content

Commit

Permalink
is: Update SearchAccounts tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaspcr committed Feb 12, 2024
1 parent afa38dd commit 6774118
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions pkg/identityserver/storetest/entity_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,15 @@ func (st *StoreTest) TestEntitySearch(t *T) {
if a.So(err, should.BeNil) && a.So(ids, should.NotBeNil) && a.So(ids, should.HaveLength, 1) {
a.So(ids[0], should.Resemble, usr1.GetIds().GetOrganizationOrUserIdentifiers())
}

// Exclude app1 collaborator.
ids, err = s.SearchAccounts(ctx, &ttnpb.SearchAccountsRequest{
ExcludeFrom: &ttnpb.SearchAccountsRequest_ExcludeFrom{
Entity: &ttnpb.SearchAccountsRequest_ExcludeFrom_ApplicationIds{ApplicationIds: app1.GetIds()},
},
})
a.So(err, should.BeNil)
a.So(ids, should.HaveLength, 3)
})

t.Run("Client", func(t *T) {
Expand All @@ -571,6 +580,15 @@ func (st *StoreTest) TestEntitySearch(t *T) {
if a.So(err, should.BeNil) && a.So(ids, should.NotBeNil) && a.So(ids, should.HaveLength, 1) {
a.So(ids[0], should.Resemble, usr1.GetIds().GetOrganizationOrUserIdentifiers())
}

// Exclude cli1 collaborator.
ids, err = s.SearchAccounts(ctx, &ttnpb.SearchAccountsRequest{
ExcludeFrom: &ttnpb.SearchAccountsRequest_ExcludeFrom{
Entity: &ttnpb.SearchAccountsRequest_ExcludeFrom_ClientIds{ClientIds: cli1.GetIds()},
},
})
a.So(err, should.BeNil)
a.So(ids, should.HaveLength, 3)
})

t.Run("Gateway", func(t *T) {
Expand All @@ -582,6 +600,15 @@ func (st *StoreTest) TestEntitySearch(t *T) {
if a.So(err, should.BeNil) && a.So(ids, should.NotBeNil) && a.So(ids, should.HaveLength, 1) {
a.So(ids[0], should.Resemble, usr1.GetIds().GetOrganizationOrUserIdentifiers())
}

// Exclude gtw1 collaborator.
ids, err = s.SearchAccounts(ctx, &ttnpb.SearchAccountsRequest{
ExcludeFrom: &ttnpb.SearchAccountsRequest_ExcludeFrom{
Entity: &ttnpb.SearchAccountsRequest_ExcludeFrom_GatewayIds{GatewayIds: gtw1.GetIds()},
},
})
a.So(err, should.BeNil)
a.So(ids, should.HaveLength, 3)
})

t.Run("Organization", func(t *T) {
Expand All @@ -593,6 +620,15 @@ func (st *StoreTest) TestEntitySearch(t *T) {
if a.So(err, should.BeNil) && a.So(ids, should.NotBeNil) && a.So(ids, should.HaveLength, 1) {
a.So(ids[0], should.Resemble, usr1.GetIds().GetOrganizationOrUserIdentifiers())
}

// Exclude org1 collaborator.
ids, err = s.SearchAccounts(ctx, &ttnpb.SearchAccountsRequest{
ExcludeFrom: &ttnpb.SearchAccountsRequest_ExcludeFrom{
Entity: &ttnpb.SearchAccountsRequest_ExcludeFrom_OrganizationIds{OrganizationIds: org1.GetIds()},
},
})
a.So(err, should.BeNil)
a.So(ids, should.HaveLength, 3)
})
})
}
Expand Down

0 comments on commit 6774118

Please sign in to comment.