{"action":"created","comment":{"url":"https://api.github.com/repos/ably/ably-ruby/pulls/comments/194335720","pull_request_review_id":127485496,"id":194335720,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NDMzNTcyMA==","diff_hunk":"@@ -1031,5 +1031,184 @@ def disconnect_transport(connection)\n         end\n       end\n     end\n+\n+    context 'when using JWT' do\n+      let(:auth_url) { 'https://shrouded-plains-50367.herokuapp.com/createJWT' } # TODO: change this\n+      let(:auth_params) { { keyName: key_name, keySecret: key_secret } }\n+      let(:channel_name) { 'test_JWT' }\n+      let(:message_name) { 'message_JWT' }\n+\n+      context 'when using auth_url' do\n+        let(:client_options) { default_options.merge(auto_connect: false, auth_url: auth_url, auth_params: auth_params) }\n+\n+        context 'when credentials are valid' do\n+          it 'client successfully fetches a channel and publishes a message' do\n+            message = client.channels.get(channel_name).publish message_name\n+            expect(message.name).to eql(message_name)\n+            stop_reactor\n+          end\n+        end\n+\n+        context 'when credentials are wrong' do\n+          let(:auth_params) { { keyName: key_name, keySecret: 'invalid' } }\n+\n+          it 'disconnected includes and invalid signature message' do\n+            client.connection.once(:disconnected) do |state_change|\n+              expect(state_change.reason.message.match(/invalid signature/i)).to_not be_nil\n+              expect(state_change.reason.code).to eql(40144)\n+              stop_reactor\n+            end\n+            client.connect\n+          end\n+        end\n+\n+        context 'when token is expired' do\n+          let(:token_duration) { 5 }\n+          let(:auth_params) { { keyName: key_name, keySecret: key_secret, expiresIn: token_duration } }\n+          it 'receives a 40142 error from the server' do\n+            client.connection.once(:connected) do\n+              sleep token_duration + 1\n+              client.connection.once(:disconnected) do |state_change|\n+                expect(state_change.reason).to be_a(Ably::Models::ErrorInfo)\n+                expect(state_change.reason.message).to match(/(expire)/i)\n+                expect(state_change.reason.code).to eql(40142)\n+                stop_reactor\n+              end\n+            end\n+            client.connect\n+          end\n+        end\n+      end\n+\n+      context 'when using auth_callback' do\n+        let(:token_callback) do\n+          lambda do |token_params|\n+            Ably::Rest::Client.new(default_options).auth.request_token({}, { auth_url: auth_url, auth_params: auth_params, auth_method: :post}).token\n+          end\n+        end\n+        let(:client_options) { default_options.merge(auth_callback: token_callback) }\n+\n+        context 'when credentials are valid' do\n+          it 'authentication succeeds and stats are pulled correctly' do\n+            client.stats do |stats|","path":"spec/acceptance/realtime/auth_spec.rb","position":null,"original_position":63,"commit_id":"1d03b75529d40c673cf311bc71f513a65f73221b","original_commit_id":"3cb60b53e456281ba7c60fc7c6c6428dd2f6376f","user":{"login":"paddybyers","id":1137574,"node_id":"MDQ6VXNlcjExMzc1NzQ=","avatar_url":"https://avatars2.githubusercontent.com/u/1137574?v=4","gravatar_id":"","url":"https://api.github.com/users/paddybyers","html_url":"https://github.com/paddybyers","followers_url":"https://api.github.com/users/paddybyers/followers","following_url":"https://api.github.com/users/paddybyers/following{/other_user}","gists_url":"https://api.github.com/users/paddybyers/gists{/gist_id}","starred_url":"https://api.github.com/users/paddybyers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paddybyers/subscriptions","organizations_url":"https://api.github.com/users/paddybyers/orgs","repos_url":"https://api.github.com/users/paddybyers/repos","events_url":"https://api.github.com/users/paddybyers/events{/privacy}","received_events_url":"https://api.github.com/users/paddybyers/received_events","type":"User","site_admin":false},"body":"Sure, I'm not suggesting changing it now.","created_at":"2018-06-11T09:05:34Z","updated_at":"2018-06-11T09:05:34Z","html_url":"https://github.com/ably/ably-ruby/pull/137#discussion_r194335720","pull_request_url":"https://api.github.com/repos/ably/ably-ruby/pulls/137","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/ably/ably-ruby/pulls/comments/194335720"},"html":{"href":"https://github.com/ably/ably-ruby/pull/137#discussion_r194335720"},"pull_request":{"href":"https://api.github.com/repos/ably/ably-ruby/pulls/137"}},"in_reply_to_id":191365184},"pull_request":{"url":"https://api.github.com/repos/ably/ably-ruby/pulls/137","id":182428783,"node_id":"MDExOlB1bGxSZXF1ZXN0MTgyNDI4Nzgz","html_url":"https://github.com/ably/ably-ruby/pull/137","diff_url":"https://github.com/ably/ably-ruby/pull/137.diff","patch_url":"https://github.com/ably/ably-ruby/pull/137.patch","issue_url":"https://api.github.com/repos/ably/ably-ruby/issues/137","number":137,"state":"open","locked":false,"title":"Add JWT tests","user":{"login":"funkyboy","id":348355,"node_id":"MDQ6VXNlcjM0ODM1NQ==","avatar_url":"https://avatars3.githubusercontent.com/u/348355?v=4","gravatar_id":"","url":"https://api.github.com/users/funkyboy","html_url":"https://github.com/funkyboy","followers_url":"https://api.github.com/users/funkyboy/followers","following_url":"https://api.github.com/users/funkyboy/following{/other_user}","gists_url":"https://api.github.com/users/funkyboy/gists{/gist_id}","starred_url":"https://api.github.com/users/funkyboy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/funkyboy/subscriptions","organizations_url":"https://api.github.com/users/funkyboy/orgs","repos_url":"https://api.github.com/users/funkyboy/repos","events_url":"https://api.github.com/users/funkyboy/events{/privacy}","received_events_url":"https://api.github.com/users/funkyboy/received_events","type":"User","site_admin":false},"body":"Fix #136 \r\n\r\n- [X] Remove old test\r\n- [X] Add tests that use `authURL`\r\n- [X] Add tests that use `ClientOptions`\r\n- [x] Add tests that use `authCallback`\r\n- [x] Add tests for automatic renewal\r\n- [x] Add tests with JWT wrapping an Ably native token `x-ably-token`\r\n- [x] Add tests with encrypted token\r\n- [x] Add tests with JWT that includes TokenDetails in `x-ably-capability`\r\n- [x] Add example when token is returned with `application/jwt` Content-Type\r\n- [x] Add refs to spec items\r\n- [x] Change URL of `auth_url` when echo server is deployed. See TODOs","created_at":"2018-04-18T10:06:23Z","updated_at":"2018-06-11T09:05:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ead3836cadcb862fc1016efd7a269ec2369f181e","assignee":null,"assignees":[],"requested_reviewers":[{"login":"SimonWoolf","id":5908687,"node_id":"MDQ6VXNlcjU5MDg2ODc=","avatar_url":"https://avatars1.githubusercontent.com/u/5908687?v=4","gravatar_id":"","url":"https://api.github.com/users/SimonWoolf","html_url":"https://github.com/SimonWoolf","followers_url":"https://api.github.com/users/SimonWoolf/followers","following_url":"https://api.github.com/users/SimonWoolf/following{/other_user}","gists_url":"https://api.github.com/users/SimonWoolf/gists{/gist_id}","starred_url":"https://api.github.com/users/SimonWoolf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SimonWoolf/subscriptions","organizations_url":"https://api.github.com/users/SimonWoolf/orgs","repos_url":"https://api.github.com/users/SimonWoolf/repos","events_url":"https://api.github.com/users/SimonWoolf/events{/privacy}","received_events_url":"https://api.github.com/users/SimonWoolf/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ably/ably-ruby/pulls/137/commits","review_comments_url":"https://api.github.com/repos/ably/ably-ruby/pulls/137/comments","review_comment_url":"https://api.github.com/repos/ably/ably-ruby/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ably/ably-ruby/issues/137/comments","statuses_url":"https://api.github.com/repos/ably/ably-ruby/statuses/1d03b75529d40c673cf311bc71f513a65f73221b","head":{"label":"ably:add-jwt-test","ref":"add-jwt-test","sha":"1d03b75529d40c673cf311bc71f513a65f73221b","user":{"login":"ably","id":1859245,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4NTkyNDU=","avatar_url":"https://avatars0.githubusercontent.com/u/1859245?v=4","gravatar_id":"","url":"https://api.github.com/users/ably","html_url":"https://github.com/ably","followers_url":"https://api.github.com/users/ably/followers","following_url":"https://api.github.com/users/ably/following{/other_user}","gists_url":"https://api.github.com/users/ably/gists{/gist_id}","starred_url":"https://api.github.com/users/ably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ably/subscriptions","organizations_url":"https://api.github.com/users/ably/orgs","repos_url":"https://api.github.com/users/ably/repos","events_url":"https://api.github.com/users/ably/events{/privacy}","received_events_url":"https://api.github.com/users/ably/received_events","type":"Organization","site_admin":false},"repo":{"id":24370613,"node_id":"MDEwOlJlcG9zaXRvcnkyNDM3MDYxMw==","name":"ably-ruby","full_name":"ably/ably-ruby","owner":{"login":"ably","id":1859245,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4NTkyNDU=","avatar_url":"https://avatars0.githubusercontent.com/u/1859245?v=4","gravatar_id":"","url":"https://api.github.com/users/ably","html_url":"https://github.com/ably","followers_url":"https://api.github.com/users/ably/followers","following_url":"https://api.github.com/users/ably/following{/other_user}","gists_url":"https://api.github.com/users/ably/gists{/gist_id}","starred_url":"https://api.github.com/users/ably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ably/subscriptions","organizations_url":"https://api.github.com/users/ably/orgs","repos_url":"https://api.github.com/users/ably/repos","events_url":"https://api.github.com/users/ably/events{/privacy}","received_events_url":"https://api.github.com/users/ably/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ably/ably-ruby","description":"Ruby client library SDK for Ably realtime messaging service","fork":false,"url":"https://api.github.com/repos/ably/ably-ruby","forks_url":"https://api.github.com/repos/ably/ably-ruby/forks","keys_url":"https://api.github.com/repos/ably/ably-ruby/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ably/ably-ruby/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ably/ably-ruby/teams","hooks_url":"https://api.github.com/repos/ably/ably-ruby/hooks","issue_events_url":"https://api.github.com/repos/ably/ably-ruby/issues/events{/number}","events_url":"https://api.github.com/repos/ably/ably-ruby/events","assignees_url":"https://api.github.com/repos/ably/ably-ruby/assignees{/user}","branches_url":"https://api.github.com/repos/ably/ably-ruby/branches{/branch}","tags_url":"https://api.github.com/repos/ably/ably-ruby/tags","blobs_url":"https://api.github.com/repos/ably/ably-ruby/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ably/ably-ruby/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ably/ably-ruby/git/refs{/sha}","trees_url":"https://api.github.com/repos/ably/ably-ruby/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ably/ably-ruby/statuses/{sha}","languages_url":"https://api.github.com/repos/ably/ably-ruby/languages","stargazers_url":"https://api.github.com/repos/ably/ably-ruby/stargazers","contributors_url":"https://api.github.com/repos/ably/ably-ruby/contributors","subscribers_url":"https://api.github.com/repos/ably/ably-ruby/subscribers","subscription_url":"https://api.github.com/repos/ably/ably-ruby/subscription","commits_url":"https://api.github.com/repos/ably/ably-ruby/commits{/sha}","git_commits_url":"https://api.github.com/repos/ably/ably-ruby/git/commits{/sha}","comments_url":"https://api.github.com/repos/ably/ably-ruby/comments{/number}","issue_comment_url":"https://api.github.com/repos/ably/ably-ruby/issues/comments{/number}","contents_url":"https://api.github.com/repos/ably/ably-ruby/contents/{+path}","compare_url":"https://api.github.com/repos/ably/ably-ruby/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ably/ably-ruby/merges","archive_url":"https://api.github.com/repos/ably/ably-ruby/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ably/ably-ruby/downloads","issues_url":"https://api.github.com/repos/ably/ably-ruby/issues{/number}","pulls_url":"https://api.github.com/repos/ably/ably-ruby/pulls{/number}","milestones_url":"https://api.github.com/repos/ably/ably-ruby/milestones{/number}","notifications_url":"https://api.github.com/repos/ably/ably-ruby/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ably/ably-ruby/labels{/name}","releases_url":"https://api.github.com/repos/ably/ably-ruby/releases{/id}","deployments_url":"https://api.github.com/repos/ably/ably-ruby/deployments","created_at":"2014-09-23T12:33:47Z","updated_at":"2018-05-23T08:56:44Z","pushed_at":"2018-06-11T07:41:31Z","git_url":"git://github.com/ably/ably-ruby.git","ssh_url":"git@github.com:ably/ably-ruby.git","clone_url":"https://github.com/ably/ably-ruby.git","svn_url":"https://github.com/ably/ably-ruby","homepage":"https://www.ably.io/download","size":2227,"stargazers_count":15,"watchers_count":15,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"archived":false,"open_issues_count":26,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":4,"open_issues":26,"watchers":15,"default_branch":"master"}},"base":{"label":"ably:master","ref":"master","sha":"d5e480f825a57c8fa8b9e54bc27f9c373fcf9bf4","user":{"login":"ably","id":1859245,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4NTkyNDU=","avatar_url":"https://avatars0.githubusercontent.com/u/1859245?v=4","gravatar_id":"","url":"https://api.github.com/users/ably","html_url":"https://github.com/ably","followers_url":"https://api.github.com/users/ably/followers","following_url":"https://api.github.com/users/ably/following{/other_user}","gists_url":"https://api.github.com/users/ably/gists{/gist_id}","starred_url":"https://api.github.com/users/ably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ably/subscriptions","organizations_url":"https://api.github.com/users/ably/orgs","repos_url":"https://api.github.com/users/ably/repos","events_url":"https://api.github.com/users/ably/events{/privacy}","received_events_url":"https://api.github.com/users/ably/received_events","type":"Organization","site_admin":false},"repo":{"id":24370613,"node_id":"MDEwOlJlcG9zaXRvcnkyNDM3MDYxMw==","name":"ably-ruby","full_name":"ably/ably-ruby","owner":{"login":"ably","id":1859245,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4NTkyNDU=","avatar_url":"https://avatars0.githubusercontent.com/u/1859245?v=4","gravatar_id":"","url":"https://api.github.com/users/ably","html_url":"https://github.com/ably","followers_url":"https://api.github.com/users/ably/followers","following_url":"https://api.github.com/users/ably/following{/other_user}","gists_url":"https://api.github.com/users/ably/gists{/gist_id}","starred_url":"https://api.github.com/users/ably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ably/subscriptions","organizations_url":"https://api.github.com/users/ably/orgs","repos_url":"https://api.github.com/users/ably/repos","events_url":"https://api.github.com/users/ably/events{/privacy}","received_events_url":"https://api.github.com/users/ably/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ably/ably-ruby","description":"Ruby client library SDK for Ably realtime messaging service","fork":false,"url":"https://api.github.com/repos/ably/ably-ruby","forks_url":"https://api.github.com/repos/ably/ably-ruby/forks","keys_url":"https://api.github.com/repos/ably/ably-ruby/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ably/ably-ruby/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ably/ably-ruby/teams","hooks_url":"https://api.github.com/repos/ably/ably-ruby/hooks","issue_events_url":"https://api.github.com/repos/ably/ably-ruby/issues/events{/number}","events_url":"https://api.github.com/repos/ably/ably-ruby/events","assignees_url":"https://api.github.com/repos/ably/ably-ruby/assignees{/user}","branches_url":"https://api.github.com/repos/ably/ably-ruby/branches{/branch}","tags_url":"https://api.github.com/repos/ably/ably-ruby/tags","blobs_url":"https://api.github.com/repos/ably/ably-ruby/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ably/ably-ruby/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ably/ably-ruby/git/refs{/sha}","trees_url":"https://api.github.com/repos/ably/ably-ruby/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ably/ably-ruby/statuses/{sha}","languages_url":"https://api.github.com/repos/ably/ably-ruby/languages","stargazers_url":"https://api.github.com/repos/ably/ably-ruby/stargazers","contributors_url":"https://api.github.com/repos/ably/ably-ruby/contributors","subscribers_url":"https://api.github.com/repos/ably/ably-ruby/subscribers","subscription_url":"https://api.github.com/repos/ably/ably-ruby/subscription","commits_url":"https://api.github.com/repos/ably/ably-ruby/commits{/sha}","git_commits_url":"https://api.github.com/repos/ably/ably-ruby/git/commits{/sha}","comments_url":"https://api.github.com/repos/ably/ably-ruby/comments{/number}","issue_comment_url":"https://api.github.com/repos/ably/ably-ruby/issues/comments{/number}","contents_url":"https://api.github.com/repos/ably/ably-ruby/contents/{+path}","compare_url":"https://api.github.com/repos/ably/ably-ruby/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ably/ably-ruby/merges","archive_url":"https://api.github.com/repos/ably/ably-ruby/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ably/ably-ruby/downloads","issues_url":"https://api.github.com/repos/ably/ably-ruby/issues{/number}","pulls_url":"https://api.github.com/repos/ably/ably-ruby/pulls{/number}","milestones_url":"https://api.github.com/repos/ably/ably-ruby/milestones{/number}","notifications_url":"https://api.github.com/repos/ably/ably-ruby/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ably/ably-ruby/labels{/name}","releases_url":"https://api.github.com/repos/ably/ably-ruby/releases{/id}","deployments_url":"https://api.github.com/repos/ably/ably-ruby/deployments","created_at":"2014-09-23T12:33:47Z","updated_at":"2018-05-23T08:56:44Z","pushed_at":"2018-06-11T07:41:31Z","git_url":"git://github.com/ably/ably-ruby.git","ssh_url":"git@github.com:ably/ably-ruby.git","clone_url":"https://github.com/ably/ably-ruby.git","svn_url":"https://github.com/ably/ably-ruby","homepage":"https://www.ably.io/download","size":2227,"stargazers_count":15,"watchers_count":15,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"archived":false,"open_issues_count":26,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":4,"open_issues":26,"watchers":15,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ably/ably-ruby/pulls/137"},"html":{"href":"https://github.com/ably/ably-ruby/pull/137"},"issue":{"href":"https://api.github.com/repos/ably/ably-ruby/issues/137"},"comments":{"href":"https://api.github.com/repos/ably/ably-ruby/issues/137/comments"},"review_comments":{"href":"https://api.github.com/repos/ably/ably-ruby/pulls/137/comments"},"review_comment":{"href":"https://api.github.com/repos/ably/ably-ruby/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ably/ably-ruby/pulls/137/commits"},"statuses":{"href":"https://api.github.com/repos/ably/ably-ruby/statuses/1d03b75529d40c673cf311bc71f513a65f73221b"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"paddybyers"}}