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

RTC8 #526

Merged
merged 13 commits into from
Dec 1, 2016
Prev Previous commit
Next Next commit
RTC8a1 (part 1)
ricardopereira committed Nov 30, 2016

Verified

This commit was signed with the committer’s verified signature. The key has expired.
addaleax Anna Henningsen
commit 8aec9e00c4bc441b6a936f0c47ab83326c2e776e
56 changes: 56 additions & 0 deletions Spec/RealtimeClient.swift
Original file line number Diff line number Diff line change
@@ -408,6 +408,62 @@ class RealtimeClient: QuickSpec {
}
}

// RTC8a1 - part 1
it("when the authentication token change is successful, then the client should receive a new CONNECTED ProtocolMessage") {
let options = AblyTests.commonAppSetup()
options.autoConnect = false
let testToken = getTestToken()
options.token = testToken
let client = ARTRealtime(options: options)
defer { client.dispose(); client.close() }
client.setTransportClass(TestProxyTransport.self)

waitUntil(timeout: testTimeout) { done in
client.connection.once(.Connected) { stateChange in
expect(stateChange?.reason).to(beNil())
done()
}
client.connect()
}

waitUntil(timeout: testTimeout) { done in
let partialDone = AblyTests.splitDone(2, done: done)

client.connection.once(.Connected) { stateChange in
guard let stateChange = stateChange else {
fail("ConnectionStateChange is nil"); partialDone(); return
}
expect(stateChange.previous).to(equal(ARTRealtimeConnectionState.Connected))
expect(stateChange.reason).toNot(beNil())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we check for a particular error code or type here please so that we know we're testing the correct thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 81e48b4.


guard let transport = client.transport as? TestProxyTransport else {
fail("TestProxyTransport is not set"); partialDone(); return
}
let connectedMessages = transport.protocolMessagesReceived.filter{ $0.action == .Connected }
expect(connectedMessages).to(haveCount(2))

guard let connectedAfterAuth = connectedMessages.last, connectionDetailsAfterAuth = connectedAfterAuth.connectionDetails else {
fail("Missing CONNECTED protocol message after AUTH protocol message"); partialDone(); return
}

expect(client.auth.clientId).to(equal(connectionDetailsAfterAuth.clientId))
expect(client.connection.key).to(equal(connectionDetailsAfterAuth.connectionKey))
partialDone()
}

client.auth.authorize(nil, options: nil) { tokenDetails, error in
expect(error).to(beNil())
guard let tokenDetails = tokenDetails else {
fail("TokenDetails is nil"); partialDone(); return
}
expect(tokenDetails.token).toNot(equal(testToken))
partialDone()
}
}

expect(client.auth.tokenDetails?.token).toNot(equal(testToken))
}

}

it("should never register any connection listeners for internal use with the public EventEmitter") {