Skip to content

Commit

Permalink
Merge 0b1e2d4 into 65e4d1d
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalymibm committed Dec 12, 2018
2 parents 65e4d1d + 0b1e2d4 commit 6ed6822
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 10 additions & 0 deletions IBMCloudAppIDTests/ConfigTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,18 @@ public class ConfigTests: XCTestCase {
XCTAssertEqual("https://region/oauth/v3/sometenant", Config.getServerUrl(appId: appid))

XCTAssertEqual("https://region/oauth/v3/sometenant/publickeys", Config.getPublicKeyEndpoint(appId: appid))
XCTAssertEqual("https://region/api/v1/", Config.getAttributesUrl(appId: appid))


XCTAssertEqual("region", Config.getIssuer(appId: appid))

// with OLD .region and tenant
appid.initialize(tenantId: "sometenant", region: ".region")
XCTAssertEqual("https://appid-oauth.region/oauth/v3/sometenant", Config.getServerUrl(appId: appid))
XCTAssertEqual("https://appid-oauth.region/oauth/v3/sometenant/publickeys", Config.getPublicKeyEndpoint(appId: appid))
XCTAssertEqual("https://appid-profiles.region/api/v1/", Config.getAttributesUrl(appId: appid))

XCTAssertEqual("appid-oauth.region", Config.getIssuer(appId: appid))

// with overrideserverhost
AppID.overrideServerHost = "somehost/"
Expand Down
7 changes: 5 additions & 2 deletions Source/IBMCloudAppID/internal/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ import BMSCore

internal class Config {

private static var oauthEndpoint = "/oauth/v3/"
private static var attributesEndpoint = "/api/v1/"
private static var serverUrlPrefix = "https://appid-oauth"
private static var attributesUrlPrefix = "https://appid-profiles"
private static var publicKeysEndpoint = "/publickeys"
private static var urlProtocol = "http"

internal static let logger = Logger.logger(name: AppIDConstants.ConfigLoggerName)

Expand All @@ -29,7 +32,7 @@ internal class Config {
return serverUrlPrefix
}

var serverUrl = region + "/oauth/v3/"
var serverUrl = region.starts(with: urlProtocol) ? region + oauthEndpoint : serverUrlPrefix + region + oauthEndpoint
if let overrideServerHost = AppID.overrideServerHost {
serverUrl = overrideServerHost
}
Expand All @@ -45,7 +48,7 @@ internal class Config {
return serverUrlPrefix
}

var attributesUrl = region + "/api/v1/"
var attributesUrl = region.starts(with: urlProtocol) ? region + attributesEndpoint : attributesUrlPrefix + region + attributesEndpoint
if let overrideHost = AppID.overrideAttributesHost {
attributesUrl = overrideHost
}
Expand Down

0 comments on commit 6ed6822

Please sign in to comment.