payload: {"action":"created","comment":{"url":"https://api.github.com/repos/oat-sa/tao-core/pulls/comments/270087024","pull_request_review_id":220130188,"id":270087024,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI3MDA4NzAyNA==","diff_hunk":"@@ -0,0 +1,260 @@\n+/*\n+ * This program is free software; you can redistribute it and/or\n+ * modify it under the terms of the GNU General Public License\n+ * as published by the Free Software Foundation; under version 2\n+ * of the License (non-upgradable).\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ * GNU General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU General Public License\n+ * along with this program; if not, write to the Free Software\n+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\n+ *\n+ * Copyright (c) 2019 Open Assessment Technologies SA\n+ */\n+\n+/**\n+ * Store for tokens in memory as a FIFO queue\n+ * Modeled on taoQtiTest/views/js/runner/proxy/cache/itemStore.js\n+ *\n+ * @author Martin Nicholson <martin@taotesting.com>\n+ */\n+define([\n+    'lodash',\n+    'core/promise',\n+    'core/store',\n+], function(_, Promise, store) {\n+    'use strict';\n+\n+    /**\n+     * The default number of tokens to store\n+     */\n+    var defaultConfig = {\n+        maxSize: 6,\n+        tokenTimeLimit: 1000 * 60 * 24\n+    };\n+\n+    /**\n+     * Create a token store\n+     * @param {Object} [options]\n+     * @param {Number} [options.maxSize = 6] - the store limit\n+     * @param {Number} [options.tokenTimeLimit] - time in milliseconds each token remains valid for\n+     * @returns {tokenStore}\n+     */\n+    return function tokenStoreFactory(options) {","path":"views/js/core/tokenStore.js","position":47,"original_position":47,"commit_id":"267899c8177c3ba95789ac0219c4a561401878ca","original_commit_id":"267899c8177c3ba95789ac0219c4a561401878ca","user":{"login":"codeclimate[bot]","id":36754821,"node_id":"MDM6Qm90MzY3NTQ4MjE=","avatar_url":"https://avatars0.githubusercontent.com/in/9403?v=4","gravatar_id":"","url":"https://api.github.com/users/codeclimate%5Bbot%5D","html_url":"https://github.com/apps/codeclimate","followers_url":"https://api.github.com/users/codeclimate%5Bbot%5D/followers","following_url":"https://api.github.com/users/codeclimate%5Bbot%5D/following{/other_user}","gists_url":"https://api.github.com/users/codeclimate%5Bbot%5D/gists{/gist_id}","starred_url":"https://api.github.com/users/codeclimate%5Bbot%5D/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codeclimate%5Bbot%5D/subscriptions","organizations_url":"https://api.github.com/users/codeclimate%5Bbot%5D/orgs","repos_url":"https://api.github.com/users/codeclimate%5Bbot%5D/repos","events_url":"https://api.github.com/users/codeclimate%5Bbot%5D/events{/privacy}","received_events_url":"https://api.github.com/users/codeclimate%5Bbot%5D/received_events","type":"Bot","site_admin":false},"body":"Function `tokenStoreFactory` has 125 lines of code (exceeds 25 allowed). Consider refactoring.","created_at":"2019-03-28T16:21:29Z","updated_at":"2019-03-28T16:21:30Z","html_url":"https://github.com/oat-sa/tao-core/pull/2006#discussion_r270087024","pull_request_url":"https://api.github.com/repos/oat-sa/tao-core/pulls/2006","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/oat-sa/tao-core/pulls/comments/270087024"},"html":{"href":"https://github.com/oat-sa/tao-core/pull/2006#discussion_r270087024"},"pull_request":{"href":"https://api.github.com/repos/oat-sa/tao-core/pulls/2006"}}},"pull_request":{"url":"https://api.github.com/repos/oat-sa/tao-core/pulls/2006","id":254175212,"node_id":"MDExOlB1bGxSZXF1ZXN0MjU0MTc1MjEy","html_url":"https://github.com/oat-sa/tao-core/pull/2006","diff_url":"https://github.com/oat-sa/tao-core/pull/2006.diff","patch_url":"https://github.com/oat-sa/tao-core/pull/2006.patch","issue_url":"https://api.github.com/repos/oat-sa/tao-core/issues/2006","number":2006,"state":"open","locked":false,"title":"[WIP] Feature/tao 7305 frontend xsrf token handler","user":{"login":"oatymart","id":43652944,"node_id":"MDQ6VXNlcjQzNjUyOTQ0","avatar_url":"https://avatars2.githubusercontent.com/u/43652944?v=4","gravatar_id":"","url":"https://api.github.com/users/oatymart","html_url":"https://github.com/oatymart","followers_url":"https://api.github.com/users/oatymart/followers","following_url":"https://api.github.com/users/oatymart/following{/other_user}","gists_url":"https://api.github.com/users/oatymart/gists{/gist_id}","starred_url":"https://api.github.com/users/oatymart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oatymart/subscriptions","organizations_url":"https://api.github.com/users/oatymart/orgs","repos_url":"https://api.github.com/users/oatymart/repos","events_url":"https://api.github.com/users/oatymart/events{/privacy}","received_events_url":"https://api.github.com/users/oatymart/received_events","type":"User","site_admin":false},"body":"The ticket is https://oat-sa.atlassian.net/browse/TAO-7305\r\nBackend ticket is https://oat-sa.atlassian.net/browse/TAO-7304\r\n\r\nRelated PRs: https://github.com/oat-sa/extension-tao-testqti/pull/1439\r\n\r\nChanges done so far:\r\n- added `core/request` module, mixing old functionality of `core/dataProvider/request` and `qtiServiceProxy`\r\n- converted `core/dataProvider/request` to thin wrapper returning the response body\r\n- converted `taoQtiTest/runner/proxy/qtiServiceProxy` to work with this\r\n- converted `core/tokenHandler` to manage a store of multiple tokens (fully async, Promise-based)\r\n- added `core/tokenStore` to encapsulate the store functionality (fully async, Promise-based)\r\n- used the `core/store` backend to ensure a single source of truth for the token pool\r\n- async unit tests for all these modules\r\n\r\nTo Do:\r\n- ~~feedback message / UX~~\r\n- ~~expand test coverage~~\r\n- ~~remove failing tests in `dataProvider/request`, `communicator/poll` (and `taoQtiTest/runner/proxy/qtiServiceProxy`) expecting token to be returned in the body~~\r\n- disable/remove token expiry functions if not needed\r\n- ~~remove logging~~\r\n","created_at":"2019-02-19T09:27:11Z","updated_at":"2019-03-28T16:21:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"57c092613f3534fd1fbf8853b09fe0bddea9f77e","assignee":{"login":"krampstudio","id":468620,"node_id":"MDQ6VXNlcjQ2ODYyMA==","avatar_url":"https://avatars3.githubusercontent.com/u/468620?v=4","gravatar_id":"","url":"https://api.github.com/users/krampstudio","html_url":"https://github.com/krampstudio","followers_url":"https://api.github.com/users/krampstudio/followers","following_url":"https://api.github.com/users/krampstudio/following{/other_user}","gists_url":"https://api.github.com/users/krampstudio/gists{/gist_id}","starred_url":"https://api.github.com/users/krampstudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krampstudio/subscriptions","organizations_url":"https://api.github.com/users/krampstudio/orgs","repos_url":"https://api.github.com/users/krampstudio/repos","events_url":"https://api.github.com/users/krampstudio/events{/privacy}","received_events_url":"https://api.github.com/users/krampstudio/received_events","type":"User","site_admin":false},"assignees":[{"login":"krampstudio","id":468620,"node_id":"MDQ6VXNlcjQ2ODYyMA==","avatar_url":"https://avatars3.githubusercontent.com/u/468620?v=4","gravatar_id":"","url":"https://api.github.com/users/krampstudio","html_url":"https://github.com/krampstudio","followers_url":"https://api.github.com/users/krampstudio/followers","following_url":"https://api.github.com/users/krampstudio/following{/other_user}","gists_url":"https://api.github.com/users/krampstudio/gists{/gist_id}","starred_url":"https://api.github.com/users/krampstudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krampstudio/subscriptions","organizations_url":"https://api.github.com/users/krampstudio/orgs","repos_url":"https://api.github.com/users/krampstudio/repos","events_url":"https://api.github.com/users/krampstudio/events{/privacy}","received_events_url":"https://api.github.com/users/krampstudio/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/oat-sa/tao-core/pulls/2006/commits","review_comments_url":"https://api.github.com/repos/oat-sa/tao-core/pulls/2006/comments","review_comment_url":"https://api.github.com/repos/oat-sa/tao-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/oat-sa/tao-core/issues/2006/comments","statuses_url":"https://api.github.com/repos/oat-sa/tao-core/statuses/267899c8177c3ba95789ac0219c4a561401878ca","head":{"label":"oat-sa:feature/TAO-7305_frontend-xsrf-token-handler","ref":"feature/TAO-7305_frontend-xsrf-token-handler","sha":"267899c8177c3ba95789ac0219c4a561401878ca","user":{"login":"oat-sa","id":7581081,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc1ODEwODE=","avatar_url":"https://avatars3.githubusercontent.com/u/7581081?v=4","gravatar_id":"","url":"https://api.github.com/users/oat-sa","html_url":"https://github.com/oat-sa","followers_url":"https://api.github.com/users/oat-sa/followers","following_url":"https://api.github.com/users/oat-sa/following{/other_user}","gists_url":"https://api.github.com/users/oat-sa/gists{/gist_id}","starred_url":"https://api.github.com/users/oat-sa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oat-sa/subscriptions","organizations_url":"https://api.github.com/users/oat-sa/orgs","repos_url":"https://api.github.com/users/oat-sa/repos","events_url":"https://api.github.com/users/oat-sa/events{/privacy}","received_events_url":"https://api.github.com/users/oat-sa/received_events","type":"Organization","site_admin":false},"repo":{"id":21277401,"node_id":"MDEwOlJlcG9zaXRvcnkyMTI3NzQwMQ==","name":"tao-core","full_name":"oat-sa/tao-core","private":false,"owner":{"login":"oat-sa","id":7581081,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc1ODEwODE=","avatar_url":"https://avatars3.githubusercontent.com/u/7581081?v=4","gravatar_id":"","url":"https://api.github.com/users/oat-sa","html_url":"https://github.com/oat-sa","followers_url":"https://api.github.com/users/oat-sa/followers","following_url":"https://api.github.com/users/oat-sa/following{/other_user}","gists_url":"https://api.github.com/users/oat-sa/gists{/gist_id}","starred_url":"https://api.github.com/users/oat-sa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oat-sa/subscriptions","organizations_url":"https://api.github.com/users/oat-sa/orgs","repos_url":"https://api.github.com/users/oat-sa/repos","events_url":"https://api.github.com/users/oat-sa/events{/privacy}","received_events_url":"https://api.github.com/users/oat-sa/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/oat-sa/tao-core","description":"main extension of TAO","fork":false,"url":"https://api.github.com/repos/oat-sa/tao-core","forks_url":"https://api.github.com/repos/oat-sa/tao-core/forks","keys_url":"https://api.github.com/repos/oat-sa/tao-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/oat-sa/tao-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/oat-sa/tao-core/teams","hooks_url":"https://api.github.com/repos/oat-sa/tao-core/hooks","issue_events_url":"https://api.github.com/repos/oat-sa/tao-core/issues/events{/number}","events_url":"https://api.github.com/repos/oat-sa/tao-core/events","assignees_url":"https://api.github.com/repos/oat-sa/tao-core/assignees{/user}","branches_url":"https://api.github.com/repos/oat-sa/tao-core/branches{/branch}","tags_url":"https://api.github.com/repos/oat-sa/tao-core/tags","blobs_url":"https://api.github.com/repos/oat-sa/tao-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/oat-sa/tao-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/oat-sa/tao-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/oat-sa/tao-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/oat-sa/tao-core/statuses/{sha}","languages_url":"https://api.github.com/repos/oat-sa/tao-core/languages","stargazers_url":"https://api.github.com/repos/oat-sa/tao-core/stargazers","contributors_url":"https://api.github.com/repos/oat-sa/tao-core/contributors","subscribers_url":"https://api.github.com/repos/oat-sa/tao-core/subscribers","subscription_url":"https://api.github.com/repos/oat-sa/tao-core/subscription","commits_url":"https://api.github.com/repos/oat-sa/tao-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/oat-sa/tao-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/oat-sa/tao-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/oat-sa/tao-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/oat-sa/tao-core/contents/{+path}","compare_url":"https://api.github.com/repos/oat-sa/tao-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/oat-sa/tao-core/merges","archive_url":"https://api.github.com/repos/oat-sa/tao-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/oat-sa/tao-core/downloads","issues_url":"https://api.github.com/repos/oat-sa/tao-core/issues{/number}","pulls_url":"https://api.github.com/repos/oat-sa/tao-core/pulls{/number}","milestones_url":"https://api.github.com/repos/oat-sa/tao-core/milestones{/number}","notifications_url":"https://api.github.com/repos/oat-sa/tao-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/oat-sa/tao-core/labels{/name}","releases_url":"https://api.github.com/repos/oat-sa/tao-core/releases{/id}","deployments_url":"https://api.github.com/repos/oat-sa/tao-core/deployments","created_at":"2014-06-27T13:54:01Z","updated_at":"2019-03-19T16:41:00Z","pushed_at":"2019-03-28T16:18:53Z","git_url":"git://github.com/oat-sa/tao-core.git","ssh_url":"git@github.com:oat-sa/tao-core.git","clone_url":"https://github.com/oat-sa/tao-core.git","svn_url":"https://github.com/oat-sa/tao-core","homepage":"http://www.taotesting.com","size":149667,"stargazers_count":29,"watchers_count":29,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":22,"mirror_url":null,"archived":false,"open_issues_count":34,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0","node_id":"MDc6TGljZW5zZTg="},"forks":22,"open_issues":34,"watchers":29,"default_branch":"master"}},"base":{"label":"oat-sa:develop","ref":"develop","sha":"896495f1dc2faee3a672ddf8d0a807f315f00793","user":{"login":"oat-sa","id":7581081,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc1ODEwODE=","avatar_url":"https://avatars3.githubusercontent.com/u/7581081?v=4","gravatar_id":"","url":"https://api.github.com/users/oat-sa","html_url":"https://github.com/oat-sa","followers_url":"https://api.github.com/users/oat-sa/followers","following_url":"https://api.github.com/users/oat-sa/following{/other_user}","gists_url":"https://api.github.com/users/oat-sa/gists{/gist_id}","starred_url":"https://api.github.com/users/oat-sa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oat-sa/subscriptions","organizations_url":"https://api.github.com/users/oat-sa/orgs","repos_url":"https://api.github.com/users/oat-sa/repos","events_url":"https://api.github.com/users/oat-sa/events{/privacy}","received_events_url":"https://api.github.com/users/oat-sa/received_events","type":"Organization","site_admin":false},"repo":{"id":21277401,"node_id":"MDEwOlJlcG9zaXRvcnkyMTI3NzQwMQ==","name":"tao-core","full_name":"oat-sa/tao-core","private":false,"owner":{"login":"oat-sa","id":7581081,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc1ODEwODE=","avatar_url":"https://avatars3.githubusercontent.com/u/7581081?v=4","gravatar_id":"","url":"https://api.github.com/users/oat-sa","html_url":"https://github.com/oat-sa","followers_url":"https://api.github.com/users/oat-sa/followers","following_url":"https://api.github.com/users/oat-sa/following{/other_user}","gists_url":"https://api.github.com/users/oat-sa/gists{/gist_id}","starred_url":"https://api.github.com/users/oat-sa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oat-sa/subscriptions","organizations_url":"https://api.github.com/users/oat-sa/orgs","repos_url":"https://api.github.com/users/oat-sa/repos","events_url":"https://api.github.com/users/oat-sa/events{/privacy}","received_events_url":"https://api.github.com/users/oat-sa/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/oat-sa/tao-core","description":"main extension of TAO","fork":false,"url":"https://api.github.com/repos/oat-sa/tao-core","forks_url":"https://api.github.com/repos/oat-sa/tao-core/forks","keys_url":"https://api.github.com/repos/oat-sa/tao-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/oat-sa/tao-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/oat-sa/tao-core/teams","hooks_url":"https://api.github.com/repos/oat-sa/tao-core/hooks","issue_events_url":"https://api.github.com/repos/oat-sa/tao-core/issues/events{/number}","events_url":"https://api.github.com/repos/oat-sa/tao-core/events","assignees_url":"https://api.github.com/repos/oat-sa/tao-core/assignees{/user}","branches_url":"https://api.github.com/repos/oat-sa/tao-core/branches{/branch}","tags_url":"https://api.github.com/repos/oat-sa/tao-core/tags","blobs_url":"https://api.github.com/repos/oat-sa/tao-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/oat-sa/tao-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/oat-sa/tao-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/oat-sa/tao-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/oat-sa/tao-core/statuses/{sha}","languages_url":"https://api.github.com/repos/oat-sa/tao-core/languages","stargazers_url":"https://api.github.com/repos/oat-sa/tao-core/stargazers","contributors_url":"https://api.github.com/repos/oat-sa/tao-core/contributors","subscribers_url":"https://api.github.com/repos/oat-sa/tao-core/subscribers","subscription_url":"https://api.github.com/repos/oat-sa/tao-core/subscription","commits_url":"https://api.github.com/repos/oat-sa/tao-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/oat-sa/tao-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/oat-sa/tao-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/oat-sa/tao-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/oat-sa/tao-core/contents/{+path}","compare_url":"https://api.github.com/repos/oat-sa/tao-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/oat-sa/tao-core/merges","archive_url":"https://api.github.com/repos/oat-sa/tao-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/oat-sa/tao-core/downloads","issues_url":"https://api.github.com/repos/oat-sa/tao-core/issues{/number}","pulls_url":"https://api.github.com/repos/oat-sa/tao-core/pulls{/number}","milestones_url":"https://api.github.com/repos/oat-sa/tao-core/milestones{/number}","notifications_url":"https://api.github.com/repos/oat-sa/tao-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/oat-sa/tao-core/labels{/name}","releases_url":"https://api.github.com/repos/oat-sa/tao-core/releases{/id}","deployments_url":"https://api.github.com/repos/oat-sa/tao-core/deployments","created_at":"2014-06-27T13:54:01Z","updated_at":"2019-03-19T16:41:00Z","pushed_at":"2019-03-28T16:18:53Z","git_url":"git://github.com/oat-sa/tao-core.git","ssh_url":"git@github.com:oat-sa/tao-core.git","clone_url":"https://github.com/oat-sa/tao-core.git","svn_url":"https://github.com/oat-sa/tao-core","homepage":"http://www.taotesting.com","size":149667,"stargazers_count":29,"watchers_count":29,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":22,"mirror_url":null,"archived":false,"open_issues_count":34,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0","node_id":"MDc6TGljZW5zZTg="},"forks":22,"open_issues":34,"watchers":29,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/oat-sa/tao-core/pulls/2006"},"html":{"href":"https://github.com/oat-sa/tao-core/pull/2006"},"issue":{"href":"https://api.github.com/repos/oat-sa/tao-core/issues/2006"},"comments":{"href":"https://api.github.com/repos/oat-sa/tao-core/issues/2006/comments"},"review_comments":{"href":"https://api.github.com/repos/oat-sa/tao-core/pulls/2006/comments"},"review_comment":{"href":"https://api.github.com/repos/oat-sa/tao-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/oat-sa/tao-core/pulls/2006/commits"},"statuses":{"href":"https://api.github.com/repos/oat-sa/tao-core/statuses/267899c8177c3ba95789ac0219c4a561401878ca"}},"author_association":"CONTRIBUTOR"}}
other: {"actor":{"display_login":"codeclimate"}}