-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
is: Update contact info registry tests
- Loading branch information
1 parent
c729236
commit 9fd031b
Showing
1 changed file
with
11 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
|