diff --git a/test/UID2.Client.Test/BidstreamClientTests.cs b/test/UID2.Client.Test/BidstreamClientTests.cs index e4c8ed6..880cf3e 100644 --- a/test/UID2.Client.Test/BidstreamClientTests.cs +++ b/test/UID2.Client.Test/BidstreamClientTests.cs @@ -370,12 +370,12 @@ private void DomainOrAppNameCaseSensitiveAndCheckFailedTest(string domainOrAppNa [InlineData("example.edu", TokenVersion.V4)] // Domain associated with site SITE_ID2, as defined by KeySharingResponse(). [InlineData("com.123.Game.App.ios", TokenVersion.V4)] // App associated with site SITE_ID2, as defined by KeySharingResponse(). [InlineData("foo.com", TokenVersion.V4)] // Domain not associated with any site. - private void TokenIsCstgDerivedDomainNameFailTest(string domainName, TokenVersion tokenVersion) + private void TokenIsCstgDerivedDomainOrAppNameFailTest(string domainOrAppName, TokenVersion tokenVersion) { Refresh(KeySharingResponse(new[] { MASTER_KEY, SITE_KEY })); var privacyBits = PrivacyBitsBuilder.Builder().WithClientSideGenerated(true).Build(); var advertisingToken = _tokenBuilder.WithPrivacyBits(privacyBits).WithVersion(tokenVersion).Build(); - var res = _client.DecryptTokenIntoRawUid(advertisingToken, domainName); + var res = _client.DecryptTokenIntoRawUid(advertisingToken, domainOrAppName); Assert.True(res.IsClientSideGenerated); Assert.False(res.Success); Assert.Equal(DecryptionStatus.DomainOrAppNameCheckFailed, res.Status); @@ -383,26 +383,29 @@ private void TokenIsCstgDerivedDomainNameFailTest(string domainName, TokenVersio } [Theory] - // Any domain name is OK, because the token is not client-side generated. + // Any domain or app name is OK, because the token is not client-side generated. [InlineData((string)null, TokenVersion.V2)] [InlineData("", TokenVersion.V2)] [InlineData("example.com", TokenVersion.V2)] [InlineData("foo.com", TokenVersion.V2)] + [InlineData("com.uid2.devapp", TokenVersion.V2)] [InlineData((string)null, TokenVersion.V3)] [InlineData("", TokenVersion.V3)] [InlineData("example.com", TokenVersion.V3)] [InlineData("foo.com", TokenVersion.V3)] + [InlineData("com.uid2.devapp", TokenVersion.V3)] [InlineData((string)null, TokenVersion.V4)] [InlineData("", TokenVersion.V4)] [InlineData("example.com", TokenVersion.V4)] [InlineData("foo.com", TokenVersion.V4)] - private void TokenIsNotCstgDerivedDomainNameSuccessTest(string domainName, TokenVersion tokenVersion) + [InlineData("com.uid2.devapp", TokenVersion.V4)] + private void TokenIsNotCstgDerivedDomainNameSuccessTest(string domainOrAppName, TokenVersion tokenVersion) { Refresh(KeySharingResponse(new[] { MASTER_KEY, SITE_KEY })); var privacyBits = PrivacyBitsBuilder.Builder().WithClientSideGenerated(false).Build(); string advertisingToken = _tokenBuilder.WithPrivacyBits(privacyBits).WithVersion(tokenVersion).Build(); ValidateAdvertisingToken(advertisingToken, IdentityScope.UID2, IdentityType.Email, tokenVersion); - var res = _client.DecryptTokenIntoRawUid(advertisingToken, domainName); + var res = _client.DecryptTokenIntoRawUid(advertisingToken, domainOrAppName); Assert.False(res.IsClientSideGenerated); Assert.True(res.Success); Assert.Equal(DecryptionStatus.Success, res.Status); diff --git a/test/UID2.Client.Test/EncryptionTestsV2.cs b/test/UID2.Client.Test/EncryptionTestsV2.cs index 9a2993b..4b553c7 100644 --- a/test/UID2.Client.Test/EncryptionTestsV2.cs +++ b/test/UID2.Client.Test/EncryptionTestsV2.cs @@ -92,13 +92,13 @@ public void TokenIsCstgDerivedDomainOrAppNameFailTest(string domainOrAppName) Assert.Null(res.Uid); } - // if there is domain name associated with sites but we explicitly call + // if there is domain or app name associated with sites but we explicitly call // DecryptionResponse Decrypt(string token) or DecryptionResponse Decrypt(string token, DateTime utcNow) // and we do not want to do domain name check // the Decrypt function would still decrypt successfully // in case DSP does not want to enable domain name check [Fact] - public void TokenIsCstgDerivedNoDomainNameTest() + public void TokenIsCstgDerivedNoDomainOrAppNameTest() { _client.RefreshJson(KeySharingResponse(new [] { MASTER_KEY, SITE_KEY })); var privacyBits = PrivacyBitsBuilder.Builder().WithClientSideGenerated(true).Build(); @@ -116,12 +116,13 @@ public void TokenIsCstgDerivedNoDomainNameTest() [InlineData("")] [InlineData("example.com")] [InlineData("foo.com")] - public void TokenIsNotCstgDerivedDomainNameSuccessTest(string domainName) + [InlineData("com.uid2.devapp")] + public void TokenIsNotCstgDerivedDomainOrAppNameSuccessTest(string domainOrAppName) { _client.RefreshJson(KeySharingResponse(new [] { MASTER_KEY, SITE_KEY })); var privacyBits = PrivacyBitsBuilder.Builder().WithClientSideGenerated(false).Build(); var advertisingToken = _tokenBuilder.WithPrivacyBits(privacyBits).Build(); - var res = _client.Decrypt(advertisingToken, domainName); + var res = _client.Decrypt(advertisingToken, domainOrAppName); Assert.False(res.IsClientSideGenerated); Assert.True(res.Success); Assert.Equal(DecryptionStatus.Success, res.Status); diff --git a/test/UID2.Client.Test/EncryptionTestsV3.cs b/test/UID2.Client.Test/EncryptionTestsV3.cs index 23e8757..e024118 100644 --- a/test/UID2.Client.Test/EncryptionTestsV3.cs +++ b/test/UID2.Client.Test/EncryptionTestsV3.cs @@ -112,13 +112,13 @@ public void TokenIsCstgDerivedDomainOrAppNameFailTest(string domainOrAppName) Assert.Null(res.Uid); } - // if there is domain name associated with sites but we explicitly call + // if there is domain or app name associated with sites but we explicitly call // DecryptionResponse Decrypt(string token) or DecryptionResponse Decrypt(string token, DateTime utcNow) // and we do not want to do domain name check // the Decrypt function would still decrypt successfully // in case DSP does not want to enable domain name check [Fact] - public void TokenIsCstgDerivedNoDomainNameTest() + public void TokenIsCstgDerivedNoDomainOrAppNameTest() { _client.RefreshJson(KeySharingResponse(new [] { MASTER_KEY, SITE_KEY })); var privacyBits = PrivacyBitsBuilder.Builder().WithClientSideGenerated(true).Build(); @@ -131,17 +131,18 @@ public void TokenIsCstgDerivedNoDomainNameTest() } [Theory] - // Any domain name is OK, because the token is not client-side generated. + // Any domain or app name is OK, because the token is not client-side generated. [InlineData((string) null)] [InlineData("")] [InlineData("example.com")] [InlineData("foo.com")] - public void TokenIsNotCstgDerivedDomainNameSuccessTest(string domainName) + [InlineData("com.uid2.devapp")] + public void TokenIsNotCstgDerivedDomainOrAppNameSuccessTest(string domainOrAppName) { _client.RefreshJson(KeySharingResponse(new [] { MASTER_KEY, SITE_KEY })); var privacyBits = PrivacyBitsBuilder.Builder().WithClientSideGenerated(false).Build(); var advertisingToken = _tokenBuilder.WithPrivacyBits(privacyBits).Build(); - var res = _client.Decrypt(advertisingToken, domainName); + var res = _client.Decrypt(advertisingToken, domainOrAppName); Assert.False(res.IsClientSideGenerated); Assert.True(res.Success); Assert.Equal(DecryptionStatus.Success, res.Status); diff --git a/test/UID2.Client.Test/EncryptionTestsV4.cs b/test/UID2.Client.Test/EncryptionTestsV4.cs index 275b0e3..2e1c77e 100644 --- a/test/UID2.Client.Test/EncryptionTestsV4.cs +++ b/test/UID2.Client.Test/EncryptionTestsV4.cs @@ -244,13 +244,13 @@ public void TokenIsCstgDerivedDomainOrAppNameFailTest(string domainOrAppName) Assert.Null(res.Uid); } - // if there is domain name associated with sites but we explicitly call + // if there is domain or app name associated with sites but we explicitly call // DecryptionResponse Decrypt(string token) or DecryptionResponse Decrypt(string token, DateTime utcNow) // and we do not want to do domain name check // the Decrypt function would still decrypt successfully // in case DSP does not want to enable domain name check [Fact] - public void TokenIsCstgDerivedNoDomainNameTest() + public void TokenIsCstgDerivedNoDomainOrAppNameTest() { _client.RefreshJson(KeySharingResponse(new [] { MASTER_KEY, SITE_KEY })); var privacyBits = PrivacyBitsBuilder.Builder().WithClientSideGenerated(true).Build(); @@ -268,13 +268,14 @@ public void TokenIsCstgDerivedNoDomainNameTest() [InlineData("")] [InlineData("example.com")] [InlineData("foo.com")] - public void TokenIsNotCstgDerivedDomainNameSuccessTest(string domainName) + [InlineData("com.uid2.devapp")] + public void TokenIsNotCstgDerivedDomainNameSuccessTest(string domainOrAppName) { _client.RefreshJson(KeySharingResponse(new [] { MASTER_KEY, SITE_KEY })); var privacyBits = PrivacyBitsBuilder.Builder().WithClientSideGenerated(false).Build(); string advertisingToken = _tokenBuilder.WithPrivacyBits(privacyBits).Build(); ValidateAdvertisingToken(advertisingToken, IdentityScope.UID2, IdentityType.Email); - var res = _client.Decrypt(advertisingToken, domainName); + var res = _client.Decrypt(advertisingToken, domainOrAppName); Assert.False(res.IsClientSideGenerated); Assert.True(res.Success); Assert.Equal(DecryptionStatus.Success, res.Status); diff --git a/test/UID2.Client.Test/KeyParserTests.cs b/test/UID2.Client.Test/KeyParserTests.cs index efebc1c..19a9143 100644 --- a/test/UID2.Client.Test/KeyParserTests.cs +++ b/test/UID2.Client.Test/KeyParserTests.cs @@ -156,9 +156,9 @@ public void ParseMissingSiteData() var keyContainer = KeyParser.Parse(json); - var isDomainNameForSite = keyContainer.IsDomainOrAppNameAllowedForSite(1, "example.com"); + var isDomainOrAppNameForSite = keyContainer.IsDomainOrAppNameAllowedForSite(1, "example.com"); - Assert.False(isDomainNameForSite); + Assert.False(isDomainOrAppNameForSite); Assert.True(keyContainer.TryGetKey(3, out var key)); } @@ -184,8 +184,8 @@ public void ParseEmptySiteData() var keyContainer = KeyParser.Parse(json); - var isDomainNameForSite = keyContainer.IsDomainOrAppNameAllowedForSite(1, "example.com"); - Assert.False(isDomainNameForSite); + var isDomainOrAppNameForSite = keyContainer.IsDomainOrAppNameAllowedForSite(1, "example.com"); + Assert.False(isDomainOrAppNameForSite); Assert.False(keyContainer.IsDomainOrAppNameAllowedForSite(1, null)); Assert.True(keyContainer.TryGetKey(3, out var key)); }