aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-07-10 23:18:12 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-07-11 08:58:34 +0200
commitbd01d8cfb90e5e447cec3a058fb0a74053ecc8e4 (patch)
tree78f6853b2efe9113aebaa51e24892a558686e28b /tests/src
parent75e926deef21688a74904b1feae2a687309a6ab3 (diff)
downloadsonarqube-bd01d8cfb90e5e447cec3a058fb0a74053ecc8e4.tar.gz
sonarqube-bd01d8cfb90e5e447cec3a058fb0a74053ecc8e4.zip
Refactor QualityProfileAdminPermissionTest
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/test/java/org/sonarqube/tests/authorisation/QualityProfileAdminPermissionTest.java50
-rw-r--r--tests/src/test/resources/authorisation/QualityProfileAdminPermissionTest/normal-user.html5
-rw-r--r--tests/src/test/resources/authorisation/QualityProfileAdminPermissionTest/profile-admin.html5
3 files changed, 17 insertions, 43 deletions
diff --git a/tests/src/test/java/org/sonarqube/tests/authorisation/QualityProfileAdminPermissionTest.java b/tests/src/test/java/org/sonarqube/tests/authorisation/QualityProfileAdminPermissionTest.java
index 65193eb1bee..6983a6757a3 100644
--- a/tests/src/test/java/org/sonarqube/tests/authorisation/QualityProfileAdminPermissionTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/authorisation/QualityProfileAdminPermissionTest.java
@@ -20,19 +20,15 @@
package org.sonarqube.tests.authorisation;
import com.sonar.orchestrator.Orchestrator;
-import org.sonarqube.tests.Category1Suite;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
import org.junit.ClassRule;
+import org.junit.Rule;
import org.junit.Test;
-import org.sonarqube.ws.client.PostRequest;
-import org.sonarqube.ws.client.WsClient;
+import org.sonarqube.tests.Category1Suite;
+import org.sonarqube.tests.Tester;
import org.sonarqube.ws.client.permission.AddUserWsRequest;
-import util.user.UserRule;
+import org.sonarqube.ws.client.qualityprofile.CreateRequest;
-import static util.ItUtils.newAdminWsClient;
import static util.ItUtils.runProjectAnalysis;
-import static util.selenium.Selenese.runSelenese;
/**
* SONAR-4210
@@ -42,42 +38,30 @@ public class QualityProfileAdminPermissionTest {
@ClassRule
public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR;
- @ClassRule
- public static UserRule userRule = UserRule.from(orchestrator);
-
- private static WsClient adminWsClient;
-
- @BeforeClass
- public static void init() {
- orchestrator.resetData();
- adminWsClient = newAdminWsClient(orchestrator);
- runProjectAnalysis(orchestrator, "shared/xoo-sample");
- }
-
- @AfterClass
- public static void clearUsers() throws Exception {
- userRule.resetUsers();
- }
+ @Rule
+ public Tester tester = new Tester(orchestrator).disableOrganizations();
@Test
public void permission_should_grant_access_to_profile() {
- userRule.createUser("not_profileadm", "userpwd");
- userRule.createUser("profileadm", "papwd");
- adminWsClient.permissions().addUser(new AddUserWsRequest().setLogin("profileadm").setPermission("profileadmin"));
+ runProjectAnalysis(orchestrator, "shared/xoo-sample");
+
+ tester.users().generate(u -> u.setLogin("not_profileadm").setPassword("userpwd"));
+ tester.users().generate(u -> u.setLogin("profileadm").setPassword("papwd"));
+ tester.wsClient().permissions().addUser(new AddUserWsRequest().setLogin("profileadm").setPermission("profileadmin"));
createProfile("xoo", "foo");
- runSelenese(orchestrator,
+ tester.runHtmlTests(
// Verify normal user is not allowed to do any modification
"/authorisation/QualityProfileAdminPermissionTest/normal-user.html",
// Verify profile admin is allowed to do modifications
"/authorisation/QualityProfileAdminPermissionTest/profile-admin.html");
}
- private static void createProfile(String language, String name) {
- adminWsClient.wsConnector().call(
- new PostRequest("api/qualityprofiles/create")
- .setParam("language", language)
- .setParam("name", name));
+ private void createProfile(String language, String name) {
+ tester.wsClient().qualityProfiles().create(CreateRequest.builder()
+ .setLanguage(language)
+ .setProfileName(name)
+ .build());
}
}
diff --git a/tests/src/test/resources/authorisation/QualityProfileAdminPermissionTest/normal-user.html b/tests/src/test/resources/authorisation/QualityProfileAdminPermissionTest/normal-user.html
index b9190a27027..1e4b156a020 100644
--- a/tests/src/test/resources/authorisation/QualityProfileAdminPermissionTest/normal-user.html
+++ b/tests/src/test/resources/authorisation/QualityProfileAdminPermissionTest/normal-user.html
@@ -10,11 +10,6 @@
<tbody>
<tr>
<td>open</td>
- <td>/sessions/logout</td>
- <td></td>
- </tr>
- <tr>
- <td>open</td>
<td>/sessions/new</td>
<td></td>
</tr>
diff --git a/tests/src/test/resources/authorisation/QualityProfileAdminPermissionTest/profile-admin.html b/tests/src/test/resources/authorisation/QualityProfileAdminPermissionTest/profile-admin.html
index 86d6b26ece8..251518aac0c 100644
--- a/tests/src/test/resources/authorisation/QualityProfileAdminPermissionTest/profile-admin.html
+++ b/tests/src/test/resources/authorisation/QualityProfileAdminPermissionTest/profile-admin.html
@@ -8,11 +8,6 @@
<body>
<table cellpadding="1" cellspacing="1" border="1">
<tbody>
- <tr>
- <td>open</td>
- <td>/sessions/logout</td>
- <td></td>
-</tr>
<tr>
<td>open</td>
<td>/sessions/new</td>