{"action":"created","comment":{"url":"https://api.github.com/repos/ajitdev/autologout/pulls/comments/47531128","id":47531128,"diff_hunk":"@@ -0,0 +1,228 @@\n+<?php\n+namespace Drupal\\autologout\\Tests;\n+use Drupal\\simpletest\\WebTestBase;\n+\n+/**\n+ * Tests the autologout's features.\n+ *\n+ * @description Ensure that the autologout module functions as expected\n+ * @group autologout\n+ */\n+\n+class AutologoutTestCaseTest extends WebTestBase {\n+  /**\n+   * Modules to enable.\n+   *\n+   * @var array\n+   */\n+  public static $modules = array('autologout','user','node');\n+  /**\n+  * User with admin rights.\n+  */\n+  protected $privileged_user;\n+\n+  /**\n+  * setUp() performs any pre-requisite tasks that need to happen.\n+  */\n+  public function setUp() {\n+    parent::setUp();\n+  // Create and log in our privileged user.\n+    $this->privileged_user = $this->drupalCreateUser(array('access content', 'administer site configuration', 'access site reports', 'access administration pages', 'bypass node access', 'administer content types', 'administer nodes', 'administer autologout', 'change own logout threshold'));\n+    $this->drupalLogin($this->privileged_user);\n+\n+\n+  // For the purposes of the test, set the timeout periods to 10 seconds.\n+    $autologout_settings = \\Drupal::configFactory()->getEditable('autologout.settings');\n+    $autologout_settings->set('timeout', 10)\n+    ->save();\n+\n+  }\n+\n+  /**\n+  * Test a user is logged out after the default timeout period.\n+  */\n+  public function testAutologoutDefaultTimeout() {\n+  // Check that the user can access the page after login.\n+  $this->drupalGet('node');\n+  $this->assertResponse(200, t('Homepage is accessible'));\n+  $this->assertText(t('Log out'), t('User is still logged in.'));\n+\n+  // Wait for timeout period to elapse.\n+  sleep(20);\n+\n+  // Check we are now logged out.\n+  $this->drupalGet('node');\n+  $this->assertResponse(200, t('Homepage is accessible'));\n+  $this->assertNoText(t('Log out'), t('User is no longer logged in.'));\n+  $this->assertText(t('You have been logged out due to inactivity.'), t('User sees inactivity message.'));\n+  }\n+\n+  /**\n+  * Test a user is not logged out within the default timeout period.\n+  */\n+  public function testAutologoutNoLogoutInsideTimeout() {\n+  // Check that the user can access the page after login.\n+  $this->drupalGet('node');\n+  $this->assertResponse(200, t('Homepage is accessible'));\n+  $this->assertText(t('Log out'), t('User is still logged in.'));\n+\n+  // Wait within the timeout period.\n+  sleep(10);\n+\n+  // Check we are still logged in.\n+  $this->drupalGet('node');\n+  $this->assertResponse(200, t('Homepage is accessible'));\n+  $this->assertText(t('Log out'), t('User is still logged in.'));\n+  $this->assertNoText(t('You have been logged out due to inactivity.'), t('User does not see inactivity message.'));\n+  }\n+\n+  /**\n+  * Test the behaviour of the settings for submission.\n+  */\n+  public function testAutologoutSettingsForm() {\n+    $edit = array();\n+    $autologout_settings = \\Drupal::config('autologout.settings');\n+    $autologout_settings->set('max_timeout', 1000)\n+      ->save();\n+\n+  // Test that it is possible to set a value above the max_timeout\n+  // threshold.\n+  $edit['timeout'] = 1500;\n+  $edit['max_timeout'] = 2000;\n+  $edit['padding'] = 60;\n+  $edit['role_logout'] = TRUE;\n+  $edit['autologout_redirect_url'] = TRUE;\n+\n+  $this->drupalPostForm('admin/config/people/autologout', $edit, t('Save configuration'));\n+  $this->assertText(t('The configuration options have been saved.'), t('Unable to save autologout config when modifying the max timeout.'));\n+\n+  // Test that out of range values are picked up.\n+  $edit['autologout_timeout'] = 2500;\n+  $edit['autologout_max_timeout'] = 2000;\n+  $edit['autologout_padding'] = 60;\n+  $edit['autologout_redirect_url'] = TRUE;\n+\n+  $this->drupalPostForm('admin/config/people/autologout', $edit, t('Save configuration'));\n+  $this->assertNoText(t('The configuration options have been saved.'), t('Saved configuration despite the autologout_timeout being too large.'));\n+\n+  // Test that out of range values are picked up.\n+  $edit['autologout_timeout'] = 1500;\n+  $edit['autologout_max_timeout'] = 2000;\n+  $edit['autologout_padding'] = 60;\n+  $edit['autologout_redirect_url'] = TRUE;\n+\n+  $this->drupalPostForm('admin/config/people/autologout', $edit, t('Save configuration'));\n+  $this->assertNoText(t('The configuration options have been saved.'), t('Saved configuration despite a role timeout being too large.'));\n+\n+  // Test that role timeouts are not validated for\n+  // disabled roles.\n+  $edit['autologout_timeout'] = 1500;\n+  $edit['autologout_max_timeout'] = 2000;\n+  $edit['autologout_padding'] = 60;\n+  $edit['autologout_role_logout'] = TRUE;\n+  $edit['autologout_redirect_url'] = TRUE;\n+\n+  $this->drupalPostForm('admin/config/people/autologout', $edit, t('Save configuration'));\n+  $this->assertText(t('The configuration options have been saved.'), t('Unable to save autologout due to out of range role timeout for a role which is not enabled..'));\n+  }\n+\n+  /**\n+  * Test enforce logout on admin page settings.\n+  */\n+  public function testAutlogoutOfAdminPages() {\n+\n+  // Set an admin page path.\n+  $_GET['q'] = 'admin';\n+\n+  // Check if user will be kept logged in on admin paths with enforce dsabled.\n+    $autologout_settings = \\Drupal::config('autologout.settings');\n+    $autologout_settings->set('enforce_admin', FALSE)\n+      ->save();\n+  $this->assertEqual(autologout_autologout_refresh_only(), TRUE, t('Autologout does logout of admin pages without enforce on admin checked.'));\n+\n+  // Check if user will not be kept logged in on admin paths if enforce enabled.\n+    $autologout_settings = \\Drupal::config('autologout.settings');\n+    $autologout_settings->set('enforce_admin', TRUE)","path":"src/Tests/AutologoutTestCaseTest.php","position":145,"original_position":145,"commit_id":"b28979e2c201e286f60f4f6abfc087a15fa46826","original_commit_id":"b28979e2c201e286f60f4f6abfc087a15fa46826","user":{"login":"ajitdev","id":3738249,"avatar_url":"https://avatars.githubusercontent.com/u/3738249?v=3","gravatar_id":"","url":"https://api.github.com/users/ajitdev","html_url":"https://github.com/ajitdev","followers_url":"https://api.github.com/users/ajitdev/followers","following_url":"https://api.github.com/users/ajitdev/following{/other_user}","gists_url":"https://api.github.com/users/ajitdev/gists{/gist_id}","starred_url":"https://api.github.com/users/ajitdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajitdev/subscriptions","organizations_url":"https://api.github.com/users/ajitdev/orgs","repos_url":"https://api.github.com/users/ajitdev/repos","events_url":"https://api.github.com/users/ajitdev/events{/privacy}","received_events_url":"https://api.github.com/users/ajitdev/received_events","type":"User","site_admin":false},"body":"2 extra spaces here and on the line above.","created_at":"2015-12-14T17:51:08Z","updated_at":"2015-12-14T17:51:08Z","html_url":"https://github.com/ajitdev/autologout/pull/23#discussion_r47531128","pull_request_url":"https://api.github.com/repos/ajitdev/autologout/pulls/23","_links":{"self":{"href":"https://api.github.com/repos/ajitdev/autologout/pulls/comments/47531128"},"html":{"href":"https://github.com/ajitdev/autologout/pull/23#discussion_r47531128"},"pull_request":{"href":"https://api.github.com/repos/ajitdev/autologout/pulls/23"}}},"pull_request":{"url":"https://api.github.com/repos/ajitdev/autologout/pulls/23","id":53583492,"html_url":"https://github.com/ajitdev/autologout/pull/23","diff_url":"https://github.com/ajitdev/autologout/pull/23.diff","patch_url":"https://github.com/ajitdev/autologout/pull/23.patch","issue_url":"https://api.github.com/repos/ajitdev/autologout/issues/23","number":23,"state":"open","locked":false,"title":"Webtest cases written","user":{"login":"neetumorwani","id":3287488,"avatar_url":"https://avatars.githubusercontent.com/u/3287488?v=3","gravatar_id":"","url":"https://api.github.com/users/neetumorwani","html_url":"https://github.com/neetumorwani","followers_url":"https://api.github.com/users/neetumorwani/followers","following_url":"https://api.github.com/users/neetumorwani/following{/other_user}","gists_url":"https://api.github.com/users/neetumorwani/gists{/gist_id}","starred_url":"https://api.github.com/users/neetumorwani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neetumorwani/subscriptions","organizations_url":"https://api.github.com/users/neetumorwani/orgs","repos_url":"https://api.github.com/users/neetumorwani/repos","events_url":"https://api.github.com/users/neetumorwani/events{/privacy}","received_events_url":"https://api.github.com/users/neetumorwani/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-12-14T16:00:48Z","updated_at":"2015-12-14T17:51:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"95aea1fb7de10a2484d7bbdec7b0e6ff7d8cb725","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ajitdev/autologout/pulls/23/commits","review_comments_url":"https://api.github.com/repos/ajitdev/autologout/pulls/23/comments","review_comment_url":"https://api.github.com/repos/ajitdev/autologout/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ajitdev/autologout/issues/23/comments","statuses_url":"https://api.github.com/repos/ajitdev/autologout/statuses/b28979e2c201e286f60f4f6abfc087a15fa46826","head":{"label":"neetumorwani:8.x-1.x","ref":"8.x-1.x","sha":"b28979e2c201e286f60f4f6abfc087a15fa46826","user":{"login":"neetumorwani","id":3287488,"avatar_url":"https://avatars.githubusercontent.com/u/3287488?v=3","gravatar_id":"","url":"https://api.github.com/users/neetumorwani","html_url":"https://github.com/neetumorwani","followers_url":"https://api.github.com/users/neetumorwani/followers","following_url":"https://api.github.com/users/neetumorwani/following{/other_user}","gists_url":"https://api.github.com/users/neetumorwani/gists{/gist_id}","starred_url":"https://api.github.com/users/neetumorwani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neetumorwani/subscriptions","organizations_url":"https://api.github.com/users/neetumorwani/orgs","repos_url":"https://api.github.com/users/neetumorwani/repos","events_url":"https://api.github.com/users/neetumorwani/events{/privacy}","received_events_url":"https://api.github.com/users/neetumorwani/received_events","type":"User","site_admin":false},"repo":{"id":46470473,"name":"autologout","full_name":"neetumorwani/autologout","owner":{"login":"neetumorwani","id":3287488,"avatar_url":"https://avatars.githubusercontent.com/u/3287488?v=3","gravatar_id":"","url":"https://api.github.com/users/neetumorwani","html_url":"https://github.com/neetumorwani","followers_url":"https://api.github.com/users/neetumorwani/followers","following_url":"https://api.github.com/users/neetumorwani/following{/other_user}","gists_url":"https://api.github.com/users/neetumorwani/gists{/gist_id}","starred_url":"https://api.github.com/users/neetumorwani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neetumorwani/subscriptions","organizations_url":"https://api.github.com/users/neetumorwani/orgs","repos_url":"https://api.github.com/users/neetumorwani/repos","events_url":"https://api.github.com/users/neetumorwani/events{/privacy}","received_events_url":"https://api.github.com/users/neetumorwani/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/neetumorwani/autologout","description":"Drupal 8 port of Automated Logout (https://www.drupal.org/project/autologout) module.","fork":true,"url":"https://api.github.com/repos/neetumorwani/autologout","forks_url":"https://api.github.com/repos/neetumorwani/autologout/forks","keys_url":"https://api.github.com/repos/neetumorwani/autologout/keys{/key_id}","collaborators_url":"https://api.github.com/repos/neetumorwani/autologout/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/neetumorwani/autologout/teams","hooks_url":"https://api.github.com/repos/neetumorwani/autologout/hooks","issue_events_url":"https://api.github.com/repos/neetumorwani/autologout/issues/events{/number}","events_url":"https://api.github.com/repos/neetumorwani/autologout/events","assignees_url":"https://api.github.com/repos/neetumorwani/autologout/assignees{/user}","branches_url":"https://api.github.com/repos/neetumorwani/autologout/branches{/branch}","tags_url":"https://api.github.com/repos/neetumorwani/autologout/tags","blobs_url":"https://api.github.com/repos/neetumorwani/autologout/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/neetumorwani/autologout/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/neetumorwani/autologout/git/refs{/sha}","trees_url":"https://api.github.com/repos/neetumorwani/autologout/git/trees{/sha}","statuses_url":"https://api.github.com/repos/neetumorwani/autologout/statuses/{sha}","languages_url":"https://api.github.com/repos/neetumorwani/autologout/languages","stargazers_url":"https://api.github.com/repos/neetumorwani/autologout/stargazers","contributors_url":"https://api.github.com/repos/neetumorwani/autologout/contributors","subscribers_url":"https://api.github.com/repos/neetumorwani/autologout/subscribers","subscription_url":"https://api.github.com/repos/neetumorwani/autologout/subscription","commits_url":"https://api.github.com/repos/neetumorwani/autologout/commits{/sha}","git_commits_url":"https://api.github.com/repos/neetumorwani/autologout/git/commits{/sha}","comments_url":"https://api.github.com/repos/neetumorwani/autologout/comments{/number}","issue_comment_url":"https://api.github.com/repos/neetumorwani/autologout/issues/comments{/number}","contents_url":"https://api.github.com/repos/neetumorwani/autologout/contents/{+path}","compare_url":"https://api.github.com/repos/neetumorwani/autologout/compare/{base}...{head}","merges_url":"https://api.github.com/repos/neetumorwani/autologout/merges","archive_url":"https://api.github.com/repos/neetumorwani/autologout/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/neetumorwani/autologout/downloads","issues_url":"https://api.github.com/repos/neetumorwani/autologout/issues{/number}","pulls_url":"https://api.github.com/repos/neetumorwani/autologout/pulls{/number}","milestones_url":"https://api.github.com/repos/neetumorwani/autologout/milestones{/number}","notifications_url":"https://api.github.com/repos/neetumorwani/autologout/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/neetumorwani/autologout/labels{/name}","releases_url":"https://api.github.com/repos/neetumorwani/autologout/releases{/id}","created_at":"2015-11-19T05:44:41Z","updated_at":"2015-11-19T05:44:42Z","pushed_at":"2015-12-14T17:06:21Z","git_url":"git://github.com/neetumorwani/autologout.git","ssh_url":"git@github.com:neetumorwani/autologout.git","clone_url":"https://github.com/neetumorwani/autologout.git","svn_url":"https://github.com/neetumorwani/autologout","homepage":null,"size":176,"stargazers_count":0,"watchers_count":0,"language":"PHP","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":"8.x-1.x"}},"base":{"label":"ajitdev:8.x-1.x","ref":"8.x-1.x","sha":"ac976bbb4b47a6624ffff1d4e340bee6686d696d","user":{"login":"ajitdev","id":3738249,"avatar_url":"https://avatars.githubusercontent.com/u/3738249?v=3","gravatar_id":"","url":"https://api.github.com/users/ajitdev","html_url":"https://github.com/ajitdev","followers_url":"https://api.github.com/users/ajitdev/followers","following_url":"https://api.github.com/users/ajitdev/following{/other_user}","gists_url":"https://api.github.com/users/ajitdev/gists{/gist_id}","starred_url":"https://api.github.com/users/ajitdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajitdev/subscriptions","organizations_url":"https://api.github.com/users/ajitdev/orgs","repos_url":"https://api.github.com/users/ajitdev/repos","events_url":"https://api.github.com/users/ajitdev/events{/privacy}","received_events_url":"https://api.github.com/users/ajitdev/received_events","type":"User","site_admin":false},"repo":{"id":29085475,"name":"autologout","full_name":"ajitdev/autologout","owner":{"login":"ajitdev","id":3738249,"avatar_url":"https://avatars.githubusercontent.com/u/3738249?v=3","gravatar_id":"","url":"https://api.github.com/users/ajitdev","html_url":"https://github.com/ajitdev","followers_url":"https://api.github.com/users/ajitdev/followers","following_url":"https://api.github.com/users/ajitdev/following{/other_user}","gists_url":"https://api.github.com/users/ajitdev/gists{/gist_id}","starred_url":"https://api.github.com/users/ajitdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajitdev/subscriptions","organizations_url":"https://api.github.com/users/ajitdev/orgs","repos_url":"https://api.github.com/users/ajitdev/repos","events_url":"https://api.github.com/users/ajitdev/events{/privacy}","received_events_url":"https://api.github.com/users/ajitdev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ajitdev/autologout","description":"Drupal 8 port of Automated Logout (https://www.drupal.org/project/autologout) module.","fork":false,"url":"https://api.github.com/repos/ajitdev/autologout","forks_url":"https://api.github.com/repos/ajitdev/autologout/forks","keys_url":"https://api.github.com/repos/ajitdev/autologout/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ajitdev/autologout/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ajitdev/autologout/teams","hooks_url":"https://api.github.com/repos/ajitdev/autologout/hooks","issue_events_url":"https://api.github.com/repos/ajitdev/autologout/issues/events{/number}","events_url":"https://api.github.com/repos/ajitdev/autologout/events","assignees_url":"https://api.github.com/repos/ajitdev/autologout/assignees{/user}","branches_url":"https://api.github.com/repos/ajitdev/autologout/branches{/branch}","tags_url":"https://api.github.com/repos/ajitdev/autologout/tags","blobs_url":"https://api.github.com/repos/ajitdev/autologout/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ajitdev/autologout/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ajitdev/autologout/git/refs{/sha}","trees_url":"https://api.github.com/repos/ajitdev/autologout/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ajitdev/autologout/statuses/{sha}","languages_url":"https://api.github.com/repos/ajitdev/autologout/languages","stargazers_url":"https://api.github.com/repos/ajitdev/autologout/stargazers","contributors_url":"https://api.github.com/repos/ajitdev/autologout/contributors","subscribers_url":"https://api.github.com/repos/ajitdev/autologout/subscribers","subscription_url":"https://api.github.com/repos/ajitdev/autologout/subscription","commits_url":"https://api.github.com/repos/ajitdev/autologout/commits{/sha}","git_commits_url":"https://api.github.com/repos/ajitdev/autologout/git/commits{/sha}","comments_url":"https://api.github.com/repos/ajitdev/autologout/comments{/number}","issue_comment_url":"https://api.github.com/repos/ajitdev/autologout/issues/comments{/number}","contents_url":"https://api.github.com/repos/ajitdev/autologout/contents/{+path}","compare_url":"https://api.github.com/repos/ajitdev/autologout/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ajitdev/autologout/merges","archive_url":"https://api.github.com/repos/ajitdev/autologout/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ajitdev/autologout/downloads","issues_url":"https://api.github.com/repos/ajitdev/autologout/issues{/number}","pulls_url":"https://api.github.com/repos/ajitdev/autologout/pulls{/number}","milestones_url":"https://api.github.com/repos/ajitdev/autologout/milestones{/number}","notifications_url":"https://api.github.com/repos/ajitdev/autologout/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ajitdev/autologout/labels{/name}","releases_url":"https://api.github.com/repos/ajitdev/autologout/releases{/id}","created_at":"2015-01-11T08:10:34Z","updated_at":"2015-06-15T06:07:25Z","pushed_at":"2015-12-14T17:06:21Z","git_url":"git://github.com/ajitdev/autologout.git","ssh_url":"git@github.com:ajitdev/autologout.git","clone_url":"https://github.com/ajitdev/autologout.git","svn_url":"https://github.com/ajitdev/autologout","homepage":null,"size":170,"stargazers_count":1,"watchers_count":1,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":1,"forks":6,"open_issues":1,"watchers":1,"default_branch":"8.x-1.x"}},"_links":{"self":{"href":"https://api.github.com/repos/ajitdev/autologout/pulls/23"},"html":{"href":"https://github.com/ajitdev/autologout/pull/23"},"issue":{"href":"https://api.github.com/repos/ajitdev/autologout/issues/23"},"comments":{"href":"https://api.github.com/repos/ajitdev/autologout/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/ajitdev/autologout/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/ajitdev/autologout/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ajitdev/autologout/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/ajitdev/autologout/statuses/b28979e2c201e286f60f4f6abfc087a15fa46826"}}}}