]> source.dussan.org Git - sonarqube.git/commitdiff
test how to generate and revoke tokens through web ui
authorStas Vilchik <vilchiks@gmail.com>
Fri, 27 Nov 2015 14:20:46 +0000 (15:20 +0100)
committerStas Vilchik <vilchiks@gmail.com>
Fri, 27 Nov 2015 14:20:46 +0000 (15:20 +0100)
it/it-tests/src/test/java/it/Category1Suite.java
it/it-tests/src/test/java/it/administration/UsersUITest.java [new file with mode: 0644]
it/it-tests/src/test/resources/administration/UsersUITest/generate_and_revoke_user_token.html [new file with mode: 0644]
server/sonar-web/src/main/js/apps/users/templates/users-tokens.hbs
server/sonar-web/src/main/js/apps/users/tokens-view.js

index bc011b61cfd99f004f4bfc276c1e4d8241a132a1..77c9d9913cd674b6c164b9533f1ce24a717cf8bb 100644 (file)
@@ -41,6 +41,7 @@ package it;/*
 import com.sonar.orchestrator.Orchestrator;
 import it.actionPlan.ActionPlanTest;
 import it.actionPlan.ActionPlanUiTest;
+import it.administration.UsersUITest;
 import it.authorisation.AuthenticationTest;
 import it.authorisation.IssuePermissionTest;
 import it.authorisation.PermissionTest;
@@ -70,6 +71,8 @@ import static util.ItUtils.xooPlugin;
 
 @RunWith(Suite.class)
 @Suite.SuiteClasses({
+  // administration
+  UsersUITest.class,
   // project administration
   BulkDeletionTest.class,
   ProjectAdministrationTest.class,
diff --git a/it/it-tests/src/test/java/it/administration/UsersUITest.java b/it/it-tests/src/test/java/it/administration/UsersUITest.java
new file mode 100644 (file)
index 0000000..e88d14f
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package it.administration;
+
+import com.sonar.orchestrator.Orchestrator;
+import com.sonar.orchestrator.selenium.Selenese;
+import it.Category1Suite;
+import org.junit.ClassRule;
+import org.junit.Test;
+import util.selenium.SeleneseTest;
+
+public class UsersUITest {
+
+  @ClassRule
+  public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR;
+
+  @Test
+  public void generate_and_revoke_user_token() throws Exception {
+    Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("generate_and_revoke_user_token",
+      "/administration/UsersUITest/generate_and_revoke_user_token.html"
+    ).build();
+    new SeleneseTest(selenese).runOn(orchestrator);
+  }
+}
diff --git a/it/it-tests/src/test/resources/administration/UsersUITest/generate_and_revoke_user_token.html b/it/it-tests/src/test/resources/administration/UsersUITest/generate_and_revoke_user_token.html
new file mode 100644 (file)
index 0000000..f6328a5
--- /dev/null
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+  <link rel="selenium.base" href="http://localhost:49506"/>
+  <title>generate_and_revoke_user_token</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+  <thead>
+  <tr>
+    <td rowspan="1" colspan="3">generate_and_revoke_user_token</td>
+  </tr>
+  </thead>
+  <tbody>
+  <tr>
+       <td>open</td>
+       <td>/sonar/sessions/logout</td>
+       <td></td>
+</tr>
+<tr>
+       <td>open</td>
+       <td>/sonar/sessions/new</td>
+       <td></td>
+</tr>
+<tr>
+       <td>type</td>
+       <td>id=login</td>
+       <td>admin</td>
+</tr>
+<tr>
+       <td>type</td>
+       <td>id=password</td>
+       <td>admin</td>
+</tr>
+<tr>
+       <td>clickAndWait</td>
+       <td>name=commit</td>
+       <td></td>
+</tr>
+<tr>
+       <td>open</td>
+       <td>/sonar/users</td>
+       <td></td>
+</tr>
+<tr>
+       <td>waitForElementPresent</td>
+       <td>css=.js-user-tokens</td>
+       <td></td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>css=.js-user-tokens</td>
+       <td></td>
+</tr>
+<tr>
+       <td>waitForElementPresent</td>
+       <td>css=.js-generate-token-form input</td>
+       <td></td>
+</tr>
+<tr>
+       <td>type</td>
+       <td>css=.js-generate-token-form input</td>
+       <td>test-token</td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>css=.js-generate-token-form button</td>
+       <td></td>
+</tr>
+<tr>
+       <td>waitForElementPresent</td>
+       <td>css=.modal code</td>
+       <td></td>
+</tr>
+<tr>
+       <td>waitForElementPresent</td>
+       <td>css=.js-revoke-token-form</td>
+       <td></td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>css=.js-revoke-token-form button</td>
+       <td></td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>css=.js-revoke-token-form button</td>
+       <td></td>
+</tr>
+<tr>
+       <td>assertElementNotPresent</td>
+       <td>css=.js-revoke-token-form</td>
+       <td></td>
+</tr>
+</tbody>
+</table>
+</body>
+</html>
index 0d96f081f010b53dcb1576ed1caf07b99322d360..f994ee4d5883f4416729464316ec52d1e1620c29 100644 (file)
@@ -25,7 +25,7 @@
           </td>
           <td class="thin nowrap text-right">
             <div class="big-spacer-left">
-              <form id="revoke-token-form" data-token="{{name}}">
+              <form class="js-revoke-token-form" data-token="{{name}}">
                 {{#if deleting}}
                   <button class="button-red">Sure?</button>
                 {{else}}
@@ -54,7 +54,7 @@
     <div class="alert alert-danger">{{msg}}</div>
   {{/each}}
 
-  <form id="generate-token-form">
+  <form class="js-generate-token-form">
     <input type="text" required maxlength="30" placeholder="Enter Token Name">
     <button>Generate</button>
   </form>
index e986e84e7ac1e5fef36bb705b2f3f6186a853436..c9c34eb25567ba72fc03e374e85a402b1622945b 100644 (file)
@@ -12,8 +12,8 @@ export default Modal.extend({
 
   events () {
     return _.extend(Modal.prototype.events.apply(this, arguments), {
-      'submit #generate-token-form': 'onGenerateTokenFormSubmit',
-      'submit #revoke-token-form': 'onRevokeTokenFormSubmit'
+      'submit .js-generate-token-form': 'onGenerateTokenFormSubmit',
+      'submit .js-revoke-token-form': 'onRevokeTokenFormSubmit'
     });
   },