Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ABLY_ENV support #740

Merged
merged 2 commits into from
Jul 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ install:
before_script:
- xcrun simctl erase all
script:
- export ABLY_ENV="push-device-auth-dev"
- fastlane $LANE
after_success:
- sleep 5
2 changes: 2 additions & 0 deletions Spec/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>ABLY_ENV</key>
<string>$(ABLY_ENV)</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions Spec/RealtimeClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ class RealtimeClient: QuickSpec {
expect(options.restHost).to(equal("test-rest.ably.io"))
expect(options.realtimeHost).to(equal("test-realtime.ably.io"))
// Extra care
expect(oldRestHost).to(equal("push-device-auth-dev-rest.ably.io"))
expect(oldRealtimeHost).to(equal("push-device-auth-dev-realtime.ably.io"))
expect(oldRestHost).to(equal("\(getEnvironment())-rest.ably.io"))
expect(oldRealtimeHost).to(equal("\(getEnvironment())-realtime.ably.io"))
}
}

Expand Down
6 changes: 3 additions & 3 deletions Spec/RestClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class RestClient: QuickSpec {
}

it("should accept a token") {
ARTClientOptions.setDefaultEnvironment("push-device-auth-dev")
ARTClientOptions.setDefaultEnvironment(getEnvironment())
defer { ARTClientOptions.setDefaultEnvironment(nil) }

let client = ARTRest(token: getTestToken())
Expand Down Expand Up @@ -99,7 +99,7 @@ class RestClient: QuickSpec {
context("logging") {
// RSC2
it("should output to the system log and the log level should be Warn") {
ARTClientOptions.setDefaultEnvironment("push-device-auth-dev")
ARTClientOptions.setDefaultEnvironment(getEnvironment())
defer {
ARTClientOptions.setDefaultEnvironment(nil)
}
Expand Down Expand Up @@ -473,7 +473,7 @@ class RestClient: QuickSpec {
guard let components = options.key?.components(separatedBy: ":"), let keyName = components.first, let keySecret = components.last else {
fail("Invalid API key: \(options.key ?? "nil")"); return
}
ARTClientOptions.setDefaultEnvironment("push-device-auth-dev")
ARTClientOptions.setDefaultEnvironment(getEnvironment())
defer {
ARTClientOptions.setDefaultEnvironment(nil)
}
Expand Down
12 changes: 10 additions & 2 deletions Spec/TestUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class AblyTests {

class func clientOptions(_ debug: Bool = false, key: String? = nil, requestToken: Bool = false) -> ARTClientOptions {
let options = ARTClientOptions()
options.environment = "push-device-auth-dev"
options.environment = getEnvironment()
options.logExceptionReportingUrl = nil
if debug {
options.logLevel = .debug
Expand Down Expand Up @@ -514,7 +514,7 @@ func getJWTToken(invalid: Bool = false, expiresIn: Int = 3600, clientId: String
URLQueryItem(name: "capability", value: capability),
URLQueryItem(name: "jwtType", value: jwtType),
URLQueryItem(name: "encrypted", value: String(encrypted)),
URLQueryItem(name: "environment", value: "push-device-auth-dev")
URLQueryItem(name: "environment", value: getEnvironment())
]

let request = NSMutableURLRequest(url: urlComponents!.url!)
Expand All @@ -539,6 +539,14 @@ public func delay(_ seconds: TimeInterval, closure: @escaping ()->()) {
deadline: DispatchTime.now() + Double(Int64(seconds * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC), execute: closure)
}

public func getEnvironment() -> String {
let b = Bundle(for: AblyTests.self)
if let env = b.infoDictionary!["ABLY_ENV"] as? String {
return env
}
return "sandbox"
}

class Box<T> {
let unbox: T
init(_ value: T) {
Expand Down
9 changes: 6 additions & 3 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ platform :ios do

lane :test_iOS11 do
run_tests(devices: ["iPhone 8 (11.2)"],
test_without_building: false)
test_without_building: false,
xcargs: { ABLY_ENV: ENV['ABLY_ENV'] })
slack(
message: "Completed tests on iOS11",
success: :test_result,
Expand All @@ -14,7 +15,8 @@ platform :ios do

lane :test_iOS10 do
run_tests(devices: ["iPhone 7 (10.3.1)"],
test_without_building: false)
test_without_building: false,
xcargs: { ABLY_ENV: ENV['ABLY_ENV'] })
slack(
message: "Completed tests on iOS10",
success: :test_result,
Expand All @@ -24,7 +26,8 @@ platform :ios do

lane :test_iOS9 do
run_tests(devices: ["iPhone 6 (9.3)"],
test_without_building: false)
test_without_building: false,
xcargs: { ABLY_ENV: ENV['ABLY_ENV'] })
slack(
message: "Completed tests on iOS9",
success: :test_result,
Expand Down