Skip to content

Commit

Permalink
is: Update contact info registry tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaspcr committed Jan 22, 2024
1 parent c729236 commit 9fd031b
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions pkg/identityserver/contact_info_registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,33 @@ import (
"google.golang.org/grpc"
)

// TODO: This set of tests have to be updated after (https://github.com/TheThingsNetwork/lorawan-stack/issues/6567) is
// resolved.
func TestContactInfoValidation(t *testing.T) {
t.Parallel()

p := &storetest.Population{}
usr1 := p.NewUser()
usr1.ContactInfo = []*ttnpb.ContactInfo{ // nolint:staticcheck
{
ContactType: ttnpb.ContactType_CONTACT_TYPE_OTHER,
ContactMethod: ttnpb.ContactMethod_CONTACT_METHOD_EMAIL,
Value: "[email protected]",
Public: false,
ValidatedAt: nil,
},
}
usr1Key, _ := p.NewAPIKey(usr1.GetEntityIdentifiers(), ttnpb.Right_RIGHT_ALL)
usr1Creds := rpcCreds(usr1Key)

testWithIdentityServer(t, func(is *IdentityServer, cc *grpc.ClientConn) {
reg := ttnpb.NewContactInfoRegistryClient(cc)
a, ctx := test.New(t)

retryInterval := test.Delay << 5
is.config.UserRegistration.ContactInfoValidation.Required = true
is.config.UserRegistration.ContactInfoValidation.TokenTTL = retryInterval * 2
is.config.UserRegistration.ContactInfoValidation.RetryInterval = retryInterval

// Directly insert contact info into database since entities no longer support creating new contact info.
c, err := is.store.SetContactInfo(ctx, usr1.GetEntityIdentifiers(), []*ttnpb.ContactInfo{{
ContactType: ttnpb.ContactType_CONTACT_TYPE_OTHER,
ContactMethod: ttnpb.ContactMethod_CONTACT_METHOD_EMAIL,
Value: "[email protected]",
}})
a.So(c, should.HaveLength, 1)
a.So(err, should.BeNil)
time.Sleep(3 * retryInterval) // Wait for the validation token to expire.

t.Run("Request Validation", func(t *testing.T) { // nolint:paralleltest
t.Run("Insufficient Rights", func(t *testing.T) { // nolint:paralleltest
a, ctx := test.New(t)
Expand Down

0 comments on commit 9fd031b

Please sign in to comment.