{"action":"created","comment":{"url":"https://api.github.com/repos/ably/ably-js/pulls/comments/51721468","id":51721468,"diff_hunk":"@@ -0,0 +1,118 @@\n+\"use strict\";\n+\n+define(['ably', 'shared_helper', 'async'], function(Ably, helper, async) {\n+\tvar currentTime, exports = {};\n+\n+\t/*\n+\t * Set up and time-sync.\n+\t */\n+\texports.setupauth = function(test) {\n+\t\ttest.expect(1);\n+\t\thelper.setupApp(function() {\n+\t\t\tvar rest = helper.AblyRest();\n+\t\t\t(function(callback) {\n+\t\t\t\trest.time(function(err, time) {\n+\t\t\t\t\tif(err) { callback(err); }\n+\t\t\t\t\tcallback(null, time);\n+\t\t\t\t});\n+\t\t\t})(function(err, time) {\n+\t\t\t\tif(err) {\n+\t\t\t\t\ttest.ok(false, helper.displayError(err));\n+\t\t\t\t\ttest.done();\n+\t\t\t\t\treturn;\n+\t\t\t\t}\n+\t\t\t\tcurrentTime = time;\n+\t\t\t\ttest.ok(true, 'Obtained time');\n+\t\t\t\ttest.done();\n+\t\t\t});\n+\t\t});\n+\t};\n+\n+\t/*\n+\t * tls:true initiates https connection\n+\t */\n+\texports.tls_connection = function(test) {\n+\t\ttest.expect(4);\n+\n+\t\tvar rest,\n+\t\tkeyStr = helper.getTestApp().keys[1].keyStr;\n+\n+\t\trest = helper.AblyRest({ tls: true, key: keyStr });\n+\n+\t\tasync.parallel([\n+\t\t\tfunction(cb) {\n+\t\t\t\trest.auth.requestToken(function(err, tokenDetails) {\n+\t\t\t\t\ttest.ok( tokenDetails.token, 'Verify that token is returned');\n+\t\t\t\t\tcb();\n+\t\t\t\t});\n+\t\t\t},\n+\t\t\tfunction(cb) {\n+\t\t\t\trest.stats(function(err, stats) {\n+\t\t\t\t\ttest.ok(err, 'Verify that an error was returned')\n+\t\t\t\t\ttest.equal(err.code, 40160, 'Verify that error returned is \"action not permitted\" (from server)');\n+\t\t\t\t\tcb();\n+\t\t\t\t});\n+\t\t\t}\n+\t\t], function() {\n+\t\t\ttest.equal(rest.baseUri().substr(0,5), \"https\", 'Requested token and stats fron tls endpoint');\n+\t\t\ttest.done();\n+\t\t});\n+\t};\n+\n+\t/*\n+\t * tls:false initiates an http connection if authentication is token-based.\n+\t */\n+\texports.non_tls_connection = function(test) {\n+\t\ttest.expect(3);\n+\n+\t\tvar rest = helper.AblyRest({ tls: false, useTokenAuth: true });\n+\n+\t\tasync.parallel([\n+\t\t\tfunction(cb) {\n+\t\t\t\trest.auth.requestToken(function(err, tokenDetails) {\n+\t\t\t\t\ttest.ok( tokenDetails.token, 'Verify that token is returned');\n+\t\t\t\t\tcb(err);\n+\t\t\t\t});\n+\t\t\t},\n+\t\t\tfunction(cb) {\n+\t\t\t\trest.stats(function(err, stats) {\n+\t\t\t\t\ttest.ok(stats, 'Verify that stats are returned');\n+\t\t\t\t\tcb(err);\n+\t\t\t\t});\n+\t\t\t}\n+\t\t], function(err) {\n+\t\t\tif(err)\n+\t\t\t\ttest.ok(false, \"Request returned an error: \" + helper.displayError(err));\n+\t\t\ttest.equal(rest.baseUri().substr(0,5), \"http:\", 'Requested token and stats fron non-tls endpoint');\n+\t\t\ttest.done();\n+\t\t});\n+\t};\n+\n+\t/*\n+\t *  The combination of tls:false and basic auth results in error (see RSC18, RSA1).\n+\t *  The error MUST NOT occur at instantiation, because we might need the Rest client \n+\t *  for things that don't require sending a key. The error MUST occur on any request ","path":"spec/rest/tls.test.js","position":94,"original_position":94,"commit_id":"4129c3d69a043238856b46df064ff634c3a2680e","original_commit_id":"4129c3d69a043238856b46df064ff634c3a2680e","user":{"login":"mattheworiordan","id":43789,"avatar_url":"https://avatars.githubusercontent.com/u/43789?v=3","gravatar_id":"","url":"https://api.github.com/users/mattheworiordan","html_url":"https://github.com/mattheworiordan","followers_url":"https://api.github.com/users/mattheworiordan/followers","following_url":"https://api.github.com/users/mattheworiordan/following{/other_user}","gists_url":"https://api.github.com/users/mattheworiordan/gists{/gist_id}","starred_url":"https://api.github.com/users/mattheworiordan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattheworiordan/subscriptions","organizations_url":"https://api.github.com/users/mattheworiordan/orgs","repos_url":"https://api.github.com/users/mattheworiordan/repos","events_url":"https://api.github.com/users/mattheworiordan/events{/privacy}","received_events_url":"https://api.github.com/users/mattheworiordan/received_events","type":"User","site_admin":false},"body":"> we might need the Rest client for things that don't require sending a key.\r\n\r\nLike what?","created_at":"2016-02-03T13:44:20Z","updated_at":"2016-02-03T13:44:20Z","html_url":"https://github.com/ably/ably-js/pull/224#discussion_r51721468","pull_request_url":"https://api.github.com/repos/ably/ably-js/pulls/224","_links":{"self":{"href":"https://api.github.com/repos/ably/ably-js/pulls/comments/51721468"},"html":{"href":"https://github.com/ably/ably-js/pull/224#discussion_r51721468"},"pull_request":{"href":"https://api.github.com/repos/ably/ably-js/pulls/224"}}},"pull_request":{"url":"https://api.github.com/repos/ably/ably-js/pulls/224","id":57673532,"html_url":"https://github.com/ably/ably-js/pull/224","diff_url":"https://github.com/ably/ably-js/pull/224.diff","patch_url":"https://github.com/ably/ably-js/pull/224.patch","issue_url":"https://api.github.com/repos/ably/ably-js/issues/224","number":224,"state":"open","locked":false,"title":"RSC18 client options tls","user":{"login":"alex-georgiou","id":2937881,"avatar_url":"https://avatars.githubusercontent.com/u/2937881?v=3","gravatar_id":"","url":"https://api.github.com/users/alex-georgiou","html_url":"https://github.com/alex-georgiou","followers_url":"https://api.github.com/users/alex-georgiou/followers","following_url":"https://api.github.com/users/alex-georgiou/following{/other_user}","gists_url":"https://api.github.com/users/alex-georgiou/gists{/gist_id}","starred_url":"https://api.github.com/users/alex-georgiou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alex-georgiou/subscriptions","organizations_url":"https://api.github.com/users/alex-georgiou/orgs","repos_url":"https://api.github.com/users/alex-georgiou/repos","events_url":"https://api.github.com/users/alex-georgiou/events{/privacy}","received_events_url":"https://api.github.com/users/alex-georgiou/received_events","type":"User","site_admin":false},"body":"This is my attempt at RSC18.\r\n\r\nFirst I verified that the requirement for not sending a secret key over HTTP was NOT implemented. I used the stats request for this.\r\n\r\nThen I modified the `Auth` object so that the error is generated exactly at the two functions where the key is added to the headers. This should ensure that all requests using the basic authentication headers will check for TLS.\r\n\r\nNotes:\r\n1. I have put in some other TLS-related tests in, perhaps some overlap with other tests in `/spec/rest/defaults.test.js`. Please review and let me know if it's overkill.\r\n2. I am returning an `ErrorInfo`. I see we do not have any mechanism that will pull error message strings from `errors.json` so I repeated the strings in the code.\r\n3. I am printing the error to the logger as it occurs, even though it is also printed when sent higher up to `PaginatedResource.get()`. I don't know how verbose we want our error reporting to be, but in theory the `Auth` functions could be called elsewhere, hence I'm printing out the error as it occurs for safety.","created_at":"2016-01-29T16:59:51Z","updated_at":"2016-02-03T13:44:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"496f78d499b4bd4586c14316fa725a69f2ee9d58","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ably/ably-js/pulls/224/commits","review_comments_url":"https://api.github.com/repos/ably/ably-js/pulls/224/comments","review_comment_url":"https://api.github.com/repos/ably/ably-js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ably/ably-js/issues/224/comments","statuses_url":"https://api.github.com/repos/ably/ably-js/statuses/4129c3d69a043238856b46df064ff634c3a2680e","head":{"label":"alex-georgiou:RSC18_ClientOptions_tls","ref":"RSC18_ClientOptions_tls","sha":"4129c3d69a043238856b46df064ff634c3a2680e","user":{"login":"alex-georgiou","id":2937881,"avatar_url":"https://avatars.githubusercontent.com/u/2937881?v=3","gravatar_id":"","url":"https://api.github.com/users/alex-georgiou","html_url":"https://github.com/alex-georgiou","followers_url":"https://api.github.com/users/alex-georgiou/followers","following_url":"https://api.github.com/users/alex-georgiou/following{/other_user}","gists_url":"https://api.github.com/users/alex-georgiou/gists{/gist_id}","starred_url":"https://api.github.com/users/alex-georgiou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alex-georgiou/subscriptions","organizations_url":"https://api.github.com/users/alex-georgiou/orgs","repos_url":"https://api.github.com/users/alex-georgiou/repos","events_url":"https://api.github.com/users/alex-georgiou/events{/privacy}","received_events_url":"https://api.github.com/users/alex-georgiou/received_events","type":"User","site_admin":false},"repo":{"id":50049111,"name":"ably-js","full_name":"alex-georgiou/ably-js","owner":{"login":"alex-georgiou","id":2937881,"avatar_url":"https://avatars.githubusercontent.com/u/2937881?v=3","gravatar_id":"","url":"https://api.github.com/users/alex-georgiou","html_url":"https://github.com/alex-georgiou","followers_url":"https://api.github.com/users/alex-georgiou/followers","following_url":"https://api.github.com/users/alex-georgiou/following{/other_user}","gists_url":"https://api.github.com/users/alex-georgiou/gists{/gist_id}","starred_url":"https://api.github.com/users/alex-georgiou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alex-georgiou/subscriptions","organizations_url":"https://api.github.com/users/alex-georgiou/orgs","repos_url":"https://api.github.com/users/alex-georgiou/repos","events_url":"https://api.github.com/users/alex-georgiou/events{/privacy}","received_events_url":"https://api.github.com/users/alex-georgiou/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alex-georgiou/ably-js","description":"Ably Realtime Messaging Javascript library to connect from your browser or Node.js","fork":true,"url":"https://api.github.com/repos/alex-georgiou/ably-js","forks_url":"https://api.github.com/repos/alex-georgiou/ably-js/forks","keys_url":"https://api.github.com/repos/alex-georgiou/ably-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alex-georgiou/ably-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alex-georgiou/ably-js/teams","hooks_url":"https://api.github.com/repos/alex-georgiou/ably-js/hooks","issue_events_url":"https://api.github.com/repos/alex-georgiou/ably-js/issues/events{/number}","events_url":"https://api.github.com/repos/alex-georgiou/ably-js/events","assignees_url":"https://api.github.com/repos/alex-georgiou/ably-js/assignees{/user}","branches_url":"https://api.github.com/repos/alex-georgiou/ably-js/branches{/branch}","tags_url":"https://api.github.com/repos/alex-georgiou/ably-js/tags","blobs_url":"https://api.github.com/repos/alex-georgiou/ably-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alex-georgiou/ably-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alex-georgiou/ably-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/alex-georgiou/ably-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alex-georgiou/ably-js/statuses/{sha}","languages_url":"https://api.github.com/repos/alex-georgiou/ably-js/languages","stargazers_url":"https://api.github.com/repos/alex-georgiou/ably-js/stargazers","contributors_url":"https://api.github.com/repos/alex-georgiou/ably-js/contributors","subscribers_url":"https://api.github.com/repos/alex-georgiou/ably-js/subscribers","subscription_url":"https://api.github.com/repos/alex-georgiou/ably-js/subscription","commits_url":"https://api.github.com/repos/alex-georgiou/ably-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/alex-georgiou/ably-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/alex-georgiou/ably-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/alex-georgiou/ably-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/alex-georgiou/ably-js/contents/{+path}","compare_url":"https://api.github.com/repos/alex-georgiou/ably-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alex-georgiou/ably-js/merges","archive_url":"https://api.github.com/repos/alex-georgiou/ably-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alex-georgiou/ably-js/downloads","issues_url":"https://api.github.com/repos/alex-georgiou/ably-js/issues{/number}","pulls_url":"https://api.github.com/repos/alex-georgiou/ably-js/pulls{/number}","milestones_url":"https://api.github.com/repos/alex-georgiou/ably-js/milestones{/number}","notifications_url":"https://api.github.com/repos/alex-georgiou/ably-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alex-georgiou/ably-js/labels{/name}","releases_url":"https://api.github.com/repos/alex-georgiou/ably-js/releases{/id}","deployments_url":"https://api.github.com/repos/alex-georgiou/ably-js/deployments","created_at":"2016-01-20T18:00:33Z","updated_at":"2016-01-20T18:00:35Z","pushed_at":"2016-02-01T17:41:29Z","git_url":"git://github.com/alex-georgiou/ably-js.git","ssh_url":"git@github.com:alex-georgiou/ably-js.git","clone_url":"https://github.com/alex-georgiou/ably-js.git","svn_url":"https://github.com/alex-georgiou/ably-js","homepage":null,"size":11958,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ably:master","ref":"master","sha":"be64c9aa91d8b4b07ab20b8888f0543045ce0f71","user":{"login":"ably","id":1859245,"avatar_url":"https://avatars.githubusercontent.com/u/1859245?v=3","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":6676523,"name":"ably-js","full_name":"ably/ably-js","owner":{"login":"ably","id":1859245,"avatar_url":"https://avatars.githubusercontent.com/u/1859245?v=3","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-js","description":"Ably Realtime Messaging Javascript library to connect from your browser or Node.js","fork":false,"url":"https://api.github.com/repos/ably/ably-js","forks_url":"https://api.github.com/repos/ably/ably-js/forks","keys_url":"https://api.github.com/repos/ably/ably-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ably/ably-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ably/ably-js/teams","hooks_url":"https://api.github.com/repos/ably/ably-js/hooks","issue_events_url":"https://api.github.com/repos/ably/ably-js/issues/events{/number}","events_url":"https://api.github.com/repos/ably/ably-js/events","assignees_url":"https://api.github.com/repos/ably/ably-js/assignees{/user}","branches_url":"https://api.github.com/repos/ably/ably-js/branches{/branch}","tags_url":"https://api.github.com/repos/ably/ably-js/tags","blobs_url":"https://api.github.com/repos/ably/ably-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ably/ably-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ably/ably-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/ably/ably-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ably/ably-js/statuses/{sha}","languages_url":"https://api.github.com/repos/ably/ably-js/languages","stargazers_url":"https://api.github.com/repos/ably/ably-js/stargazers","contributors_url":"https://api.github.com/repos/ably/ably-js/contributors","subscribers_url":"https://api.github.com/repos/ably/ably-js/subscribers","subscription_url":"https://api.github.com/repos/ably/ably-js/subscription","commits_url":"https://api.github.com/repos/ably/ably-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/ably/ably-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/ably/ably-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/ably/ably-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/ably/ably-js/contents/{+path}","compare_url":"https://api.github.com/repos/ably/ably-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ably/ably-js/merges","archive_url":"https://api.github.com/repos/ably/ably-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ably/ably-js/downloads","issues_url":"https://api.github.com/repos/ably/ably-js/issues{/number}","pulls_url":"https://api.github.com/repos/ably/ably-js/pulls{/number}","milestones_url":"https://api.github.com/repos/ably/ably-js/milestones{/number}","notifications_url":"https://api.github.com/repos/ably/ably-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ably/ably-js/labels{/name}","releases_url":"https://api.github.com/repos/ably/ably-js/releases{/id}","deployments_url":"https://api.github.com/repos/ably/ably-js/deployments","created_at":"2012-11-13T19:41:13Z","updated_at":"2016-01-24T15:57:03Z","pushed_at":"2016-02-02T23:40:29Z","git_url":"git://github.com/ably/ably-js.git","ssh_url":"git@github.com:ably/ably-js.git","clone_url":"https://github.com/ably/ably-js.git","svn_url":"https://github.com/ably/ably-js","homepage":null,"size":12119,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":40,"forks":4,"open_issues":40,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ably/ably-js/pulls/224"},"html":{"href":"https://github.com/ably/ably-js/pull/224"},"issue":{"href":"https://api.github.com/repos/ably/ably-js/issues/224"},"comments":{"href":"https://api.github.com/repos/ably/ably-js/issues/224/comments"},"review_comments":{"href":"https://api.github.com/repos/ably/ably-js/pulls/224/comments"},"review_comment":{"href":"https://api.github.com/repos/ably/ably-js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ably/ably-js/pulls/224/commits"},"statuses":{"href":"https://api.github.com/repos/ably/ably-js/statuses/4129c3d69a043238856b46df064ff634c3a2680e"}}}}