Skip to content

Commit

Permalink
change more test names
Browse files Browse the repository at this point in the history
  • Loading branch information
caroline-ttd committed Apr 29, 2024
1 parent f10d4dd commit 46eac0c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 22 deletions.
13 changes: 8 additions & 5 deletions test/UID2.Client.Test/BidstreamClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,39 +370,42 @@ 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);
Assert.Null(res.Uid);
}

[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);
Expand Down
9 changes: 5 additions & 4 deletions test/UID2.Client.Test/EncryptionTestsV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down
11 changes: 6 additions & 5 deletions test/UID2.Client.Test/EncryptionTestsV3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down
9 changes: 5 additions & 4 deletions test/UID2.Client.Test/EncryptionTestsV4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions test/UID2.Client.Test/KeyParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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));
}
Expand Down

0 comments on commit 46eac0c

Please sign in to comment.