Skip to content

Commit

Permalink
Merge pull request #335 from ably/rtp9e
Browse files Browse the repository at this point in the history
RTP9e
  • Loading branch information
tcard committed Apr 5, 2016
2 parents a5a4cfd + 8343e4a commit e037afe
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions Spec/RealtimeClientPresence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,94 @@ class RealtimeClientPresence: QuickSpec {
}
}


// RTP9
context("update") {

// RTP9e
it("should result in an error immediately if the client is anonymous") {
let client = ARTRealtime(options: AblyTests.commonAppSetup())
defer { client.close() }
let channel = client.channels.get("test")

waitUntil(timeout: testTimeout) { done in
channel.presence.update(nil) { error in
expect(error!.message).to(contain("attempted to publish presence message without clientId"))
done()
}
}
}

// RTP9e
it("should result in an error immediately if the channel is DETACHED") {
let options = AblyTests.commonAppSetup()
options.clientId = "john"
let client = ARTRealtime(options: options)
defer { client.close() }
let channel = client.channels.get("test")

channel.attach()
channel.detach()

waitUntil(timeout: testTimeout) { done in
channel.presence.update(nil) { error in
expect(error!.message).to(contain("invalid channel state"))
done()
}
}
}

// RTP9e
it("should result in an error immediately if the channel is FAILED") {
let options = AblyTests.commonAppSetup()
options.clientId = "john"
let client = ARTRealtime(options: options)
defer { client.close() }
let channel = client.channels.get("test")

channel.onError(AblyTests.newErrorProtocolMessage())

waitUntil(timeout: testTimeout) { done in
channel.presence.update(nil) { error in
expect(error!.message).to(contain("invalid channel state"))
done()
}
}
}

// RTP9e
it("should result in an error if the client does not have required presence permission") {
let options = AblyTests.clientOptions()
options.token = getTestToken(capability: "{ \"cannotpresence:john\":[\"publish\"] }")
options.clientId = "john"
let client = ARTRealtime(options: options)
defer { client.close() }
let channel = client.channels.get("cannotpresence")

waitUntil(timeout: testTimeout) { done in
channel.presence.update(nil) { error in
expect(error!.message).to(contain("Channel denied access based on given capability"))
done()
}
}
}

// RTP9e
it("should result in an error if Ably service determines that the client is unidentified") {
let client = ARTRealtime(options: AblyTests.commonAppSetup())
defer { client.close() }
let channel = client.channels.get("test")

waitUntil(timeout: testTimeout) { done in
channel.presence.update(nil) { error in
expect(error!.message).to(contain("presence message without clientId"))
done()
}
}
}

}

// RTP15e
let cases: [String:(ARTRealtimePresence, Optional<(ARTErrorInfo?)->Void>)->()] = [
"enterClient": { $0.enterClient("john", data: nil, callback: $1) },
Expand Down

0 comments on commit e037afe

Please sign in to comment.