Skip to content

Commit

Permalink
Fix TNT-41585 Unable to set full custom serverDomain (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
XDex authored Aug 2, 2021
1 parent f7634e9 commit 252f59d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
35 changes: 20 additions & 15 deletions Source/Adobe.Target.Client/TargetClientConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ namespace Adobe.Target.Client
public sealed class TargetClientConfig
{
private const string ClusterPrefix = "mboxedge";
private const string DefaultDomain = "tt.omtrdc.net";
private const string Https = "https://";
private const string Http = "http://";

private TargetClientConfig()
{
Expand All @@ -35,11 +38,13 @@ private TargetClientConfig(Builder builder)
ValidateConfig(builder);
this.Client = builder.Client;
this.OrganizationId = builder.OrganizationId;
this.Protocol = builder.Secure ? "https://" : "http://";
this.Protocol = builder.Secure ? Https : Http;
this.DefaultPropertyToken = builder.DefaultPropertyToken;
this.DefaultUrl = this.Protocol + this.Client + "." + builder.ServerDomain;
this.ClusterUrlPrefix = this.Protocol + ClusterPrefix;
this.ClusterUrlSuffix = "." + builder.ServerDomain;
this.DefaultUrl = builder.ServerDomain != DefaultDomain
? $"{this.Protocol}{builder.ServerDomain}"
: $"{this.Protocol}{this.Client}.{DefaultDomain}";
this.ClusterUrlPrefix = $"{this.Protocol}{ClusterPrefix}";
this.ClusterUrlSuffix = $".{DefaultDomain}";
this.Logger = builder.Logger;
this.Timeout = builder.Timeout;
this.Proxy = builder.Proxy;
Expand Down Expand Up @@ -82,16 +87,6 @@ private TargetClientConfig(Builder builder)
/// </summary>
public string DefaultUrl { get; }

/// <summary>
/// ClusterUrlPrefix
/// </summary>
public string ClusterUrlPrefix { get; }

/// <summary>
/// ClusterUrlSuffix
/// </summary>
public string ClusterUrlSuffix { get; }

/// <summary>
/// Default Property Token
/// </summary>
Expand Down Expand Up @@ -173,6 +168,16 @@ private TargetClientConfig(Builder builder)
/// </summary>
public bool LocalArtifactOnly { get; }

/// <summary>
/// ClusterUrlPrefix
/// </summary>
internal string ClusterUrlPrefix { get; }

/// <summary>
/// ClusterUrlSuffix
/// </summary>
internal string ClusterUrlSuffix { get; }

private static void ValidateConfig(Builder builder)
{
if (builder.Client == null)
Expand Down Expand Up @@ -215,7 +220,7 @@ public Builder(string client, string organizationId)
/// <summary>
/// ServerDomain
/// </summary>
internal string ServerDomain { get; private set; } = "tt.omtrdc.net";
internal string ServerDomain { get; private set; } = DefaultDomain;

/// <summary>
/// DefaultPropertyToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void Build_ReturnClientConfig()

Assert.Equal(testClientId, targetClientConfig.Client);
Assert.Equal(testOrgId, targetClientConfig.OrganizationId);
Assert.Equal("https://" + testClientId + "." + testDomain, targetClientConfig.DefaultUrl);
Assert.Equal("https://" + testDomain, targetClientConfig.DefaultUrl);
Assert.Equal(testPropertyToken, targetClientConfig.DefaultPropertyToken);
Assert.Equal(testLogger, targetClientConfig.Logger);
Assert.Equal(testTimeout, targetClientConfig.Timeout);
Expand Down

0 comments on commit 252f59d

Please sign in to comment.