Skip to content

Commit 29e8fa8

Browse files
authored
Merge pull request #128 from adobe/dev-v4.1.1
Dev v4.1.1 to Staging
2 parents c7da0f6 + a0f65e1 commit 29e8fa8

10 files changed

+96
-70
lines changed

AEPAssurance.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "AEPAssurance"
3-
s.version = "4.1.0"
3+
s.version = "4.1.1"
44
s.summary = "AEPAssurance SDK for Adobe Experience Platform Mobile SDK. Written and maintained by Adobe."
55

66
s.description = <<-DESC

AEPAssurance.xcodeproj/project.pbxproj

+6-2
Original file line numberDiff line numberDiff line change
@@ -1471,7 +1471,7 @@
14711471
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
14721472
GCC_WARN_UNUSED_FUNCTION = YES;
14731473
GCC_WARN_UNUSED_VARIABLE = YES;
1474-
IPHONEOS_DEPLOYMENT_TARGET = 14.4;
1474+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
14751475
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
14761476
MTL_FAST_MATH = YES;
14771477
ONLY_ACTIVE_ARCH = YES;
@@ -1529,7 +1529,7 @@
15291529
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
15301530
GCC_WARN_UNUSED_FUNCTION = YES;
15311531
GCC_WARN_UNUSED_VARIABLE = YES;
1532-
IPHONEOS_DEPLOYMENT_TARGET = 14.4;
1532+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
15331533
MTL_ENABLE_DEBUG_INFO = NO;
15341534
MTL_FAST_MATH = YES;
15351535
SDKROOT = iphoneos;
@@ -1650,6 +1650,7 @@
16501650
CODE_SIGN_ENTITLEMENTS = TestApp/TestApp.entitlements;
16511651
CODE_SIGN_IDENTITY = "Apple Development";
16521652
CODE_SIGN_STYLE = Automatic;
1653+
CURRENT_PROJECT_VERSION = 1;
16531654
DEVELOPMENT_ASSET_PATHS = "\"TestApp/Preview Content\"";
16541655
DEVELOPMENT_TEAM = FKGEE875K4;
16551656
ENABLE_PREVIEWS = YES;
@@ -1658,6 +1659,7 @@
16581659
"$(inherited)",
16591660
"@executable_path/Frameworks",
16601661
);
1662+
MARKETING_VERSION = 1;
16611663
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.assurance.testApp;
16621664
PRODUCT_NAME = "$(TARGET_NAME)";
16631665
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -1675,6 +1677,7 @@
16751677
CODE_SIGN_ENTITLEMENTS = TestApp/TestApp.entitlements;
16761678
CODE_SIGN_IDENTITY = "Apple Development";
16771679
CODE_SIGN_STYLE = Automatic;
1680+
CURRENT_PROJECT_VERSION = 1;
16781681
DEVELOPMENT_ASSET_PATHS = "\"TestApp/Preview Content\"";
16791682
DEVELOPMENT_TEAM = FKGEE875K4;
16801683
ENABLE_PREVIEWS = YES;
@@ -1683,6 +1686,7 @@
16831686
"$(inherited)",
16841687
"@executable_path/Frameworks",
16851688
);
1689+
MARKETING_VERSION = 1;
16861690
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.assurance.testApp;
16871691
PRODUCT_NAME = "$(TARGET_NAME)";
16881692
PROVISIONING_PROFILE_SPECIFIER = "";

AEPAssurance/Source/AssuranceConstants.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Foundation
1515
enum AssuranceConstants {
1616
static let EXTENSION_NAME = "com.adobe.assurance"
1717
static let FRIENDLY_NAME = "Assurance"
18-
static let EXTENSION_VERSION = "4.1.0"
18+
static let EXTENSION_VERSION = "4.1.1"
1919
static let LOG_TAG = FRIENDLY_NAME
2020
static let DEFAULT_ENVIRONMENT = AssuranceEnvironment.prod
2121

AEPAssurance/Source/AssuranceSessionOrchestrator.swift

+36-28
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class AssuranceSessionOrchestrator: AssurancePresentationDelegate, AssuranceConn
2323
/// A buffer for holding the events until the initial Assurance session associated with
2424
/// the app launch happens. This is emptied once a session has been connected.
2525
var outboundEventBuffer: ThreadSafeArray<AssuranceEvent>?
26+
27+
let orchestratorQueue = DispatchQueue(label: "com.adobe.assurance.orchestrationQueue")
2628

2729
/// Flag indicating if an Assurance Session was ever terminated
2830
/// The purpose of this flag is to determine if the Assurance Extension has discarded any MobileCore Events
@@ -56,17 +58,19 @@ class AssuranceSessionOrchestrator: AssurancePresentationDelegate, AssuranceConn
5658
/// - Parameters:
5759
/// - sessionDetails: An `AssuranceSessionDetails` instance containing all the essential data for starting a session
5860
func createSession(withDetails sessionDetails: AssuranceSessionDetails) {
59-
if session != nil {
60-
Log.warning(label: AssuranceConstants.LOG_TAG, "An active Assurance session already exists. Cannot create a new one. Ignoring to process the scanned deeplink.")
61-
return
61+
orchestratorQueue.async {
62+
if self.session != nil {
63+
Log.warning(label: AssuranceConstants.LOG_TAG, "An active Assurance session already exists. Cannot create a new one. Ignoring to process the scanned deeplink.")
64+
return
65+
}
66+
67+
self.stateManager.shareAssuranceState(withSessionID: sessionDetails.sessionId)
68+
self.session = AssuranceSession(sessionDetails: sessionDetails, stateManager: self.stateManager, sessionOrchestrator: self, outboundEvents: self.outboundEventBuffer)
69+
self.session?.startSession()
70+
71+
self.outboundEventBuffer?.clear()
72+
self.outboundEventBuffer = nil
6273
}
63-
64-
stateManager.shareAssuranceState(withSessionID: sessionDetails.sessionId)
65-
session = AssuranceSession(sessionDetails: sessionDetails, stateManager: stateManager, sessionOrchestrator: self, outboundEvents: outboundEventBuffer)
66-
session?.startSession()
67-
68-
outboundEventBuffer?.clear()
69-
outboundEventBuffer = nil
7074
}
7175

7276
#if DEBUG
@@ -93,29 +97,33 @@ class AssuranceSessionOrchestrator: AssurancePresentationDelegate, AssuranceConn
9397
/// Dissolve the active session (if one exists) and its associated states.
9498
///
9599
func terminateSession(purgeBuffer: Bool) {
96-
hasEverTerminated = true
97-
98-
if purgeBuffer && outboundEventBuffer != nil {
99-
Log.debug(label: AssuranceConstants.LOG_TAG, "Clearing outbound event buffer")
100-
outboundEventBuffer = nil
100+
orchestratorQueue.async {
101+
self.hasEverTerminated = true
102+
103+
if purgeBuffer && self.outboundEventBuffer != nil {
104+
Log.debug(label: AssuranceConstants.LOG_TAG, "Clearing outbound event buffer")
105+
self.outboundEventBuffer = nil
106+
}
107+
108+
self.stateManager.clearAssuranceState()
109+
110+
self.session?.disconnect()
111+
self.session = nil
101112
}
102-
103-
stateManager.clearAssuranceState()
104-
105-
session?.disconnect()
106-
session = nil
107113
}
108114

109115
func queueEvent(_ assuranceEvent: AssuranceEvent) {
110-
/// Queue this event to the active session if one exists.
111-
if let session = session {
112-
session.sendEvent(assuranceEvent)
113-
return
116+
orchestratorQueue.async {
117+
/// Queue this event to the active session if one exists.
118+
if let session = self.session {
119+
session.sendEvent(assuranceEvent)
120+
return
121+
}
122+
123+
/// Drop the event if outboundEventBuffer is nil
124+
/// If not, we still want to queue the events to the buffer until the session is connected.
125+
self.outboundEventBuffer?.append(assuranceEvent)
114126
}
115-
116-
/// Drop the event if outboundEventBuffer is nil
117-
/// If not, we still want to queue the events to the buffer until the session is connected.
118-
outboundEventBuffer?.append(assuranceEvent)
119127
}
120128

121129
/// Check if the Assurance extension is capable of handling events.

AEPAssurance/UnitTests/AssuranceSessionOrchestratorTests.swift

+33-20
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class AssuranceSessionOrchestratorTests: XCTestCase {
4848
sessionOrchestrator.createSession(withDetails: sampleSessionDetail)
4949

5050
// verify that a new session is created
51+
sleep(1)
5152
XCTAssertNotNil(sessionOrchestrator.session)
5253
XCTAssertIdentical(sampleSessionDetail, sessionOrchestrator.session?.sessionDetails)
5354

@@ -77,9 +78,9 @@ class AssuranceSessionOrchestratorTests: XCTestCase {
7778
sessionOrchestrator.terminateSession(purgeBuffer: true)
7879

7980
// verify
81+
wait(for: [mockSession.disconnectCalled], timeout: 1.0)
8082
XCTAssertTrue(sessionOrchestrator.hasEverTerminated)
8183
XCTAssertTrue(mockStateManager.clearAssuranceStateCalled)
82-
XCTAssertTrue(mockSession.disconnectCalled)
8384
XCTAssertNil(sessionOrchestrator.outboundEventBuffer)
8485
XCTAssertNil(sessionOrchestrator.session)
8586
}
@@ -92,32 +93,38 @@ class AssuranceSessionOrchestratorTests: XCTestCase {
9293
sessionOrchestrator.queueEvent(AssuranceEvent(type: "event1", payload: [:]))
9394

9495
// verify
96+
wait(for: [mockSession.sendEventCalled], timeout: 1.0)
9597
XCTAssertTrue(sessionOrchestrator.outboundEventBuffer!.isEmpty)
96-
XCTAssertTrue(mockSession.sendEventCalled)
9798
}
9899

99100
func test_queueEvent_whenSessionInActive() {
100101
// setup
101102
sessionOrchestrator.session = nil
102103

104+
// Invert the expectation as we need to verify sendEvent is not called
105+
mockSession.sendEventCalled.isInverted = true
106+
103107
// test
104108
sessionOrchestrator.queueEvent(AssuranceEvent(type: "event1", payload: [:]))
105109

106110
// verify
107-
XCTAssertFalse(mockSession.sendEventCalled)
108-
XCTAssertEqual(1,sessionOrchestrator.outboundEventBuffer!.count)
111+
wait(for: [mockSession.sendEventCalled], timeout: 1.0)
112+
XCTAssertEqual(1,sessionOrchestrator.outboundEventBuffer!.count)
109113
}
110114

111115
func test_queueEvent_whenShutDown() {
112116
// setup
113117
sessionOrchestrator.session = nil
114118
sessionOrchestrator.outboundEventBuffer = nil
115119

120+
// Invert the expectation as we need to verify sendEvent is not called
121+
mockSession.sendEventCalled.isInverted = true
122+
116123
// test
117124
sessionOrchestrator.queueEvent(AssuranceEvent(type: "event1", payload: [:]))
118125

119126
// verify
120-
XCTAssertFalse(mockSession.sendEventCalled)
127+
wait(for: [mockSession.sendEventCalled], timeout: 1.0)
121128
XCTAssertNil(sessionOrchestrator.outboundEventBuffer)
122129
}
123130

@@ -132,7 +139,7 @@ class AssuranceSessionOrchestratorTests: XCTestCase {
132139
sessionOrchestrator.pinScreenConnectClicked("3325")
133140

134141
// verify
135-
XCTAssertTrue(mockSession.startSessionCalled)
142+
wait(for: [mockSession.startSessionCalled], timeout: 1.0)
136143
}
137144

138145

@@ -151,13 +158,16 @@ class AssuranceSessionOrchestratorTests: XCTestCase {
151158
sessionOrchestrator.authorizingPresentation = mockAuthorizingPresentation
152159
mockStateManager.orgIDReturnValue = "mockOrgId"
153160
sessionOrchestrator.session = mockSession
161+
162+
// Invert the expectation as we need to verify startSession is not called
163+
mockSession.startSessionCalled.isInverted = true
154164

155165
// test
156166
sessionOrchestrator.pinScreenConnectClicked("")
157167

158168
// verify that the UI is indicated for the error and session is cleared
159-
XCTAssertFalse(mockSession.startSessionCalled)
160-
XCTAssertTrue(mockSession.disconnectCalled)
169+
wait(for: [mockSession.startSessionCalled], timeout: 1.0)
170+
wait(for: [mockSession.disconnectCalled], timeout: 1.0)
161171
XCTAssertTrue(mockAuthorizingPresentation.sessionConnectionErrorCalled)
162172
XCTAssertEqual(.noPincode ,mockAuthorizingPresentation.sessionConnectionErrorValue)
163173
XCTAssertTrue(mockStateManager.clearAssuranceStateCalled)
@@ -170,12 +180,15 @@ class AssuranceSessionOrchestratorTests: XCTestCase {
170180
mockStateManager.orgIDReturnValue = nil
171181
sessionOrchestrator.session = mockSession
172182

183+
// Invert the expectation as we need to verify startSession is not called
184+
mockSession.startSessionCalled.isInverted = true
185+
173186
// test
174187
sessionOrchestrator.pinScreenConnectClicked("4442")
175188

176189
// verify that the UI is indicated for the error and session is cleared
177-
XCTAssertFalse(mockSession.startSessionCalled)
178-
XCTAssertTrue(mockSession.disconnectCalled)
190+
wait(for: [mockSession.startSessionCalled], timeout: 1.0)
191+
wait(for: [mockSession.disconnectCalled], timeout: 1.0)
179192
XCTAssertTrue(mockAuthorizingPresentation.sessionConnectionErrorCalled)
180193
XCTAssertEqual(.noOrgId ,mockAuthorizingPresentation.sessionConnectionErrorValue)
181194
XCTAssertTrue(mockStateManager.clearAssuranceStateCalled)
@@ -188,9 +201,9 @@ class AssuranceSessionOrchestratorTests: XCTestCase {
188201
sessionOrchestrator.pinScreenCancelClicked()
189202

190203
// verify that the session is terminated and cleared
204+
wait(for: [mockSession.disconnectCalled], timeout: 1.0)
191205
XCTAssertTrue(sessionOrchestrator.hasEverTerminated)
192206
XCTAssertTrue(mockStateManager.clearAssuranceStateCalled)
193-
XCTAssertTrue(mockSession.disconnectCalled)
194207
XCTAssertNil(sessionOrchestrator.outboundEventBuffer)
195208
XCTAssertNil(sessionOrchestrator.session)
196209
}
@@ -202,9 +215,9 @@ class AssuranceSessionOrchestratorTests: XCTestCase {
202215
sessionOrchestrator.disconnectClicked()
203216

204217
// verify that the session is terminated and cleared
218+
wait(for: [mockSession.disconnectCalled], timeout: 1.0)
205219
XCTAssertTrue(sessionOrchestrator.hasEverTerminated)
206220
XCTAssertTrue(mockStateManager.clearAssuranceStateCalled)
207-
XCTAssertTrue(mockSession.disconnectCalled)
208221
XCTAssertNil(sessionOrchestrator.outboundEventBuffer)
209222
XCTAssertNil(sessionOrchestrator.session)
210223
}
@@ -232,25 +245,25 @@ class AssuranceSessionOrchestratorTests: XCTestCase {
232245

233246
XCTAssertTrue(mockAuthorizingPresentation.sessionConnectingCalled)
234247

235-
XCTAssertTrue(mockStateManager.shareAssuranceStateCalled)
248+
wait(for: [mockStateManager.shareAssuranceStateExpectation], timeout: 1.0)
236249
XCTAssertEqual(sampleSessionID, mockStateManager.shareAssuranceStateSessionID)
250+
sleep(1)
237251
XCTAssertNotNil(sessionOrchestrator.session)
238252
XCTAssertNil(sessionOrchestrator.outboundEventBuffer)
239253
}
240254

241-
// This is testing the retry scenario when a session has been created, but the socket connection failed
255+
// This is testing the retry scenario when a session has been created, but the socket connection failed
242256
func test_createQuickConnectSession_withExistingSession() {
243257
let mockAuthorizingPresentation = MockAuthorizingPresentation(authorizingView: MockSessionAuthorizingUI(withPresentationDelegate: sessionOrchestrator))
244258
sessionOrchestrator.authorizingPresentation = mockAuthorizingPresentation
245-
let sampleSessionID = "sampleSessionID"
246-
let sampleSessionDetails = AssuranceSessionDetails(sessionId: sampleSessionID, clientId: "sampleClientID")
247259
queueTwoOutboundEvents()
248-
let session = AssuranceSession(sessionDetails: sampleSessionDetails, stateManager: mockStateManager, sessionOrchestrator: sessionOrchestrator, outboundEvents: sessionOrchestrator.outboundEventBuffer)
249-
sessionOrchestrator.session = session
250-
sessionOrchestrator.createQuickConnectSession(with: sampleSessionDetails)
260+
sessionOrchestrator.session = mockSession
261+
sessionOrchestrator.createQuickConnectSession(with: mockSession.sessionDetails)
251262

263+
wait(for: [mockSession.disconnectCalled], timeout: 1.0)
252264
XCTAssertTrue(mockStateManager.clearAssuranceStateCalled)
253-
XCTAssertNotNil(session.outboundQueue)
265+
XCTAssertNotNil(mockSession.outboundQueue)
266+
sleep(1)
254267
XCTAssertNotNil(sessionOrchestrator.session)
255268
}
256269

AEPAssurance/UnitTests/Mocks/MockSession.swift

+6-7
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,22 @@ class MockSession: AssuranceSession {
2424
}
2525

2626

27-
var sendEventCalled = false
27+
var sendEventCalled = XCTestExpectation(description: "Send event method called expectation")
2828
var sentEvent: AssuranceEvent?
2929
override func sendEvent(_ assuranceEvent: AssuranceEvent) {
30-
expectation?.fulfill()
31-
sendEventCalled = true
3230
sentEvent = assuranceEvent
31+
sendEventCalled.fulfill()
3332
}
3433

35-
var startSessionCalled = false
34+
var startSessionCalled = XCTestExpectation(description: "Start session called expectation")
3635
override func startSession() {
37-
startSessionCalled = true
36+
startSessionCalled.fulfill()
3837
}
3938

4039

41-
var disconnectCalled = false
40+
var disconnectCalled = XCTestExpectation(description: "Disconnect called expectation")
4241
override func disconnect() {
43-
disconnectCalled = true
42+
disconnectCalled.fulfill()
4443
}
4544

4645
var handleConnectionErrorCalled = false

AEPAssurance/UnitTests/Mocks/MockStateManager.swift

+2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ class MockStateManager : AssuranceStateManager {
3232

3333
var shareAssuranceStateCalled = false
3434
var shareAssuranceStateSessionID: String?
35+
var shareAssuranceStateExpectation = XCTestExpectation(description: "Share assurance state expectation")
3536
override func shareAssuranceState(withSessionID sessionId: String) {
3637
shareAssuranceStateCalled = true
3738
shareAssuranceStateSessionID = sessionId
39+
shareAssuranceStateExpectation.fulfill()
3840
}
3941

4042
var clearAssuranceStateCalled = false

0 commit comments

Comments
 (0)