From 08625970e3edaee0209c29c780740d81d637082e Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Fri, 27 Nov 2015 15:20:46 +0100 Subject: [PATCH] test how to generate and revoke tokens through web ui --- .../src/test/java/it/Category1Suite.java | 3 + .../java/it/administration/UsersUITest.java | 41 +++++++ .../generate_and_revoke_user_token.html | 100 ++++++++++++++++++ .../js/apps/users/templates/users-tokens.hbs | 4 +- .../src/main/js/apps/users/tokens-view.js | 4 +- 5 files changed, 148 insertions(+), 4 deletions(-) create mode 100644 it/it-tests/src/test/java/it/administration/UsersUITest.java create mode 100644 it/it-tests/src/test/resources/administration/UsersUITest/generate_and_revoke_user_token.html diff --git a/it/it-tests/src/test/java/it/Category1Suite.java b/it/it-tests/src/test/java/it/Category1Suite.java index bc011b61cfd..77c9d9913cd 100644 --- a/it/it-tests/src/test/java/it/Category1Suite.java +++ b/it/it-tests/src/test/java/it/Category1Suite.java @@ -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 index 00000000000..e88d14f5873 --- /dev/null +++ b/it/it-tests/src/test/java/it/administration/UsersUITest.java @@ -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 index 00000000000..f6328a560dc --- /dev/null +++ b/it/it-tests/src/test/resources/administration/UsersUITest/generate_and_revoke_user_token.html @@ -0,0 +1,100 @@ + + + + + + + generate_and_revoke_user_token + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
generate_and_revoke_user_token
open/sonar/sessions/logout
open/sonar/sessions/new
typeid=loginadmin
typeid=passwordadmin
clickAndWaitname=commit
open/sonar/users
waitForElementPresentcss=.js-user-tokens
clickcss=.js-user-tokens
waitForElementPresentcss=.js-generate-token-form input
typecss=.js-generate-token-form inputtest-token
clickcss=.js-generate-token-form button
waitForElementPresentcss=.modal code
waitForElementPresentcss=.js-revoke-token-form
clickcss=.js-revoke-token-form button
clickcss=.js-revoke-token-form button
assertElementNotPresentcss=.js-revoke-token-form
+ + diff --git a/server/sonar-web/src/main/js/apps/users/templates/users-tokens.hbs b/server/sonar-web/src/main/js/apps/users/templates/users-tokens.hbs index 0d96f081f01..f994ee4d588 100644 --- a/server/sonar-web/src/main/js/apps/users/templates/users-tokens.hbs +++ b/server/sonar-web/src/main/js/apps/users/templates/users-tokens.hbs @@ -25,7 +25,7 @@
-
+ {{#if deleting}} {{else}} @@ -54,7 +54,7 @@
{{msg}}
{{/each}} - +
diff --git a/server/sonar-web/src/main/js/apps/users/tokens-view.js b/server/sonar-web/src/main/js/apps/users/tokens-view.js index e986e84e7ac..c9c34eb2556 100644 --- a/server/sonar-web/src/main/js/apps/users/tokens-view.js +++ b/server/sonar-web/src/main/js/apps/users/tokens-view.js @@ -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' }); }, -- 2.39.5