]> source.dussan.org Git - sonarqube.git/commitdiff
Refactor QualityProfileAdminPermissionTest
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 10 Jul 2017 21:18:12 +0000 (23:18 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 11 Jul 2017 06:58:34 +0000 (08:58 +0200)
tests/src/test/java/org/sonarqube/tests/authorisation/QualityProfileAdminPermissionTest.java
tests/src/test/resources/authorisation/QualityProfileAdminPermissionTest/normal-user.html
tests/src/test/resources/authorisation/QualityProfileAdminPermissionTest/profile-admin.html

index 65193eb1bee8e1046c53abac897dd2d240d2e688..6983a6757a34d0cad40b8b38627aad11162d5d5a 100644 (file)
 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());
   }
 
 }
index b9190a270279026d75aa7b27639aad46ecbf819e..1e4b156a020cf8d86bd81eb215edae16ae4aee70 100644 (file)
@@ -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>
index 86d6b26ece89b7e5717b45195db2f7797e717087..251518aac0c2f71b292989b91aa5e981400f1b93 100644 (file)
@@ -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>