Skip to content

Commit 530fdee

Browse files
authored
Merge branch 'master' into eudc-updates
2 parents 14279ad + 4f684ab commit 530fdee

File tree

7 files changed

+21
-7
lines changed

7 files changed

+21
-7
lines changed

.github/workflows/e2e.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
- name: Build and test
1717
env:
1818
api_key: ${{secrets.E2E_API_KEY}}
19+
server_api_key: ${{secrets.E2E_SERVER_API_KEY}}
1920
push_campaign_id: ${{secrets.E2E_PUSH_CAMPAIGN_ID}}
2021
push_template_id: ${{secrets.E2E_PUSH_TEMPLATE_ID}}
2122
in_app_campaign_id: ${{secrets.E2E_IN_APP_CAMPAIGN_ID}}

tests/endpoint-tests/CI.swift.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Foundation
88
/// Actual values will be injected by build step
99
struct CI {
1010
static let apiKey = "{api_key}"
11+
static let serverApiKey = "{server_api_key}"
1112
static let pushCampaignId = NSNumber(0)
1213
static let pushTemplateId = NSNumber(0)
1314
static let inAppCampaignId = NSNumber(0)

tests/endpoint-tests/EndpointTests.swift

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,13 @@ class EndpointTests: XCTestCase {
215215
ensureInAppMessages(api: api, email: email)
216216

217217
api.inAppManager.scheduleSync().wait()
218-
let count = api.inAppManager.getMessages().count
219-
XCTAssert(count > 0)
220-
221-
let message = api.inAppManager.getMessages()[0]
218+
let messages = api.inAppManager.getMessages()
219+
XCTAssert(messages.count > 0)
220+
221+
guard let message = messages.first else {
222+
XCTFail("No messages available")
223+
return
224+
}
222225
let startTime = Date()
223226
let endTime = startTime.addingTimeInterval(10.0)
224227

@@ -274,6 +277,7 @@ class EndpointTests: XCTestCase {
274277
}
275278

276279
private static let apiKey = Environment.apiKey!
280+
private static let serverApiKey = Environment.serverApiKey!
277281
private static let pushCampaignId = Environment.pushCampaignId!
278282
private static let pushTemplateId = Environment.pushTemplateId!
279283
private static let inAppCampaignId = Environment.inAppCampaignId!
@@ -288,7 +292,7 @@ class EndpointTests: XCTestCase {
288292
}
289293

290294
let expectation1 = expectation(for: predicate, evaluatedWith: nil, handler: nil)
291-
wait(for: [expectation1], timeout: 60)
295+
wait(for: [expectation1], timeout: 120)
292296
}
293297

294298
private func clearAllInAppMessages(api: InternalIterableAPI) {

tests/endpoint-tests/Environment.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Foundation
1010
struct Environment {
1111
enum Key: String {
1212
case apiKey = "api_key"
13+
case serverApiKey = "server_api_key"
1314
case pushCampaignId = "push_campaign_id"
1415
case pushTemplateId = "push_template_id"
1516
case inAppCampaignId = "in_app_campaign_id"
@@ -19,6 +20,10 @@ struct Environment {
1920
static var apiKey: String? {
2021
getFromEnv(key: .apiKey) ?? CI.apiKey
2122
}
23+
24+
static var serverApiKey: String? {
25+
getFromEnv(key: .serverApiKey) ?? CI.serverApiKey
26+
}
2227

2328
static var pushCampaignId: NSNumber? {
2429
getNSNumberFromEnv(key: .pushCampaignId) ?? CI.pushCampaignId

tests/endpoint-tests/IterableAPISupport.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct IterableAPISupport {
1212
}
1313

1414
var urlRequest = URLRequest(url: url)
15-
urlRequest.setValue(apiKey, forHTTPHeaderField: JsonKey.Header.apiKey)
15+
urlRequest.setValue(serverApiKey, forHTTPHeaderField: JsonKey.Header.apiKey)
1616

1717
return RequestSender.sendRequest(urlRequest, usingSession: urlSession)
1818
}
@@ -44,6 +44,7 @@ struct IterableAPISupport {
4444
}
4545

4646
private static let apiKey = Environment.apiKey!
47+
private static let serverApiKey = Environment.serverApiKey!
4748

4849
private static func createPostRequest(iterablePostRequest: PostRequest) -> URLRequest? {
4950
IterableRequestUtil.createPostRequest(forApiEndPoint: Path.apiEndpoint,
@@ -57,7 +58,7 @@ struct IterableAPISupport {
5758
[JsonKey.contentType: JsonValue.applicationJson,
5859
JsonKey.Header.sdkPlatform: JsonValue.iOS,
5960
JsonKey.Header.sdkVersion: IterableAPI.sdkVersion,
60-
JsonKey.Header.apiKey: apiKey]
61+
JsonKey.Header.apiKey: serverApiKey]
6162
}
6263

6364
private static var urlSession: URLSession = {

tests/endpoint-tests/scripts/env_vars.sh.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

33
export api_key=the_api_key
4+
export server_api_key=the_server_api_key
45
export push_campaign_id=0
56
export push_template_id=0
67
export in_app_campaign_id=0

tests/endpoint-tests/scripts/run_test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ fi
1414

1515
echo Generating CI.swift
1616
sed -e "s/\(apiKey = \).*$/\1\"$api_key\"/" \
17+
-e "s/\(serverApiKey = \).*$/\1\"$server_api_key\"/" \
1718
-e "s/\(pushCampaignId = \).*$/\1\NSNumber($push_campaign_id)/" \
1819
-e "s/\(pushTemplateId = \).*$/\1\NSNumber($push_template_id)/" \
1920
-e "s/\(inAppCampaignId = \).*$/\1\NSNumber($in_app_campaign_id)/" \

0 commit comments

Comments
 (0)