Skip to content

Commit

Permalink
feat(SetServiceUrl): Refactored SetEndpoint to SetServiceUrl
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Use SetServiceUrl to set the service endpoint rather than SetEndpoint
  • Loading branch information
mediumTaj committed Sep 6, 2019
1 parent 199f371 commit feab2d9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 46 deletions.
16 changes: 8 additions & 8 deletions src/IBM.Cloud.SDK.Core/Service/IBMService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public abstract class IBMService : IIBMService
private const string apikeyAsUsername = "apikey";
public IClient Client { get; set; }
public string ServiceName { get; set; }
public string Url { get { return Endpoint; } }
public string ServiceUrl { get { return Endpoint; } }
protected Dictionary<string, string> customRequestHeaders = new Dictionary<string, string>();
private const string ErrorMessageNoAuthenticator = "Authentication information was not properly configured.";

Expand All @@ -60,14 +60,14 @@ protected string Endpoint

private IAuthenticator authenticator;

protected IBMService(string serviceName, string url, IClient httpClient)
protected IBMService(string serviceName, string serviceUrl, IClient httpClient)
{
ServiceName = serviceName;
Client = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
authenticator = new NoAuthAuthenticator();

if (!string.IsNullOrEmpty(Endpoint))
Endpoint = url;
Endpoint = serviceUrl;
}

protected IBMService(string serviceName, IAuthenticator authenticator)
Expand All @@ -80,10 +80,10 @@ protected IBMService(string serviceName, IAuthenticator authenticator)

// Try to retrieve the service URL from either a credential file, environment, or VCAP_SERVICES.
Dictionary<string, string> props = CredentialUtils.GetServiceProperties(serviceName);
props.TryGetValue(PropNameServiceUrl, out string url);
if (!string.IsNullOrEmpty(url))
props.TryGetValue(PropNameServiceUrl, out string serviceUrl);
if (!string.IsNullOrEmpty(serviceUrl))
{
SetEndpoint(url);
SetServiceUrl(serviceUrl);
}

// Check to see if "disable ssl" was set in the service properties.
Expand All @@ -109,9 +109,9 @@ protected void SetAuthentication()
}
}

public void SetEndpoint(string url)
public void SetServiceUrl(string serviceUrl)
{
Endpoint = url;
Endpoint = serviceUrl;
}

public void DisableSslVerification(bool insecure)
Expand Down
2 changes: 1 addition & 1 deletion src/IBM.Cloud.SDK.Core/Service/IIBMService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public interface IIBMService
IClient Client { get; set; }

string ServiceName { get; set; }
void SetEndpoint(string endpoint);
void SetServiceUrl(string serviceUrl);
IAuthenticator GetAuthenticator();
}
}
2 changes: 1 addition & 1 deletion test/IBM.Cloud.SDK.Core.Tests/CloudPak4DataAuthTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public void TestBadPasswordBracketEnd()
[TestMethod, ExpectedException(typeof(ArgumentException))]
public void TestBadUrlBeginningBracketEnd()
{
CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator("{url}", "username", "password");
CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator("{serviceUrl}", "username", "password");
}

[TestMethod, ExpectedException(typeof(ArgumentException))]
Expand Down
36 changes: 0 additions & 36 deletions test/IBM.Cloud.SDK.Core.Tests/NoauthTests.cs

This file was deleted.

0 comments on commit feab2d9

Please sign in to comment.