Skip to content

Commit

Permalink
Update DNS Merchant regular expression length (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
armando-rodriguez-cko authored Aug 29, 2024
1 parent d82d31a commit c34be15
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/CheckoutSdk/Environment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private static Uri AddSubdomainToApiUrlEnvironment(Environment environment, stri

Uri newEnvironment = new Uri(apiUrl.ToString());

Regex regex = new Regex(@"^[0-9a-z]{8,11}$");
Regex regex = new Regex(@"^[0-9a-z]+$");
if (regex.IsMatch(subdomain))
{
UriBuilder merchantApiUrl = new UriBuilder(apiUrl.Host);
Expand Down
15 changes: 9 additions & 6 deletions test/CheckoutSdkTest/CheckoutConfigurationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ private void ShouldCreateConfiguration()
}

[Theory]
[InlineData("123dmain", "https://123dmain.api.sandbox.checkout.com/")]
[InlineData("123domain", "https://123domain.api.sandbox.checkout.com/")]
[InlineData("1234domain", "https://1234domain.api.sandbox.checkout.com/")]
[InlineData("a", "https://a.api.sandbox.checkout.com/")]
[InlineData("ab", "https://ab.api.sandbox.checkout.com/")]
[InlineData("abc", "https://abc.api.sandbox.checkout.com/")]
[InlineData("abc1", "https://abc1.api.sandbox.checkout.com/")]
[InlineData("12345domain", "https://12345domain.api.sandbox.checkout.com/")]
public void ShouldCreateConfigurationWithSubdomain(string subdomain, string expectedUri)
{
Expand All @@ -38,9 +39,11 @@ public void ShouldCreateConfigurationWithSubdomain(string subdomain, string expe

[Theory]
[InlineData("", "https://api.sandbox.checkout.com/")]
[InlineData("123", "https://api.sandbox.checkout.com/")]
[InlineData("123bad", "https://api.sandbox.checkout.com/")]
[InlineData("12345domainBad", "https://api.sandbox.checkout.com/")]
[InlineData(" ", "https://api.sandbox.checkout.com/")]
[InlineData(" ", "https://api.sandbox.checkout.com/")]
[InlineData(" - ", "https://api.sandbox.checkout.com/")]
[InlineData("a b", "https://api.sandbox.checkout.com/")]
[InlineData("ab c1", "https://api.sandbox.checkout.com/")]
public void ShouldCreateConfigurationWithBadSubdomain(string subdomain, string expectedUri)
{
var credentials = new StaticKeysSdkCredentials(ValidDefaultSk, ValidDefaultPk);
Expand Down

0 comments on commit c34be15

Please sign in to comment.