From 51e06582b33444c5905ba4c66961dea19a51d423 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Sat, 11 Nov 2017 15:16:37 +0100 Subject: [PATCH] Add missing functions to Testers --- .../java/org/sonarqube/qa/util/SettingTester.java | 4 ++++ .../main/java/org/sonarqube/qa/util/UserTester.java | 12 ++++++++++-- .../org/sonarqube/qa/util/pageobjects/LoginPage.java | 3 +++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/SettingTester.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/SettingTester.java index 460ea8d8ae9..399e2c305fc 100644 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/SettingTester.java +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/SettingTester.java @@ -61,6 +61,10 @@ public class SettingTester { session.wsClient().settings().reset(ResetRequest.builder().setKeys(keys).build()); } + public void resetProjectSettings(String projectKey, String... keys){ + session.wsClient().settings().reset(ResetRequest.builder().setComponent(projectKey).setKeys(keys).build()); + } + public void setGlobalSetting(String key, @Nullable String value) { setSetting(null, key, value); } diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/UserTester.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/UserTester.java index 6c57c8a81aa..72e3cb5126e 100644 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/UserTester.java +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/UserTester.java @@ -37,6 +37,7 @@ import static java.util.Arrays.stream; public class UserTester { private static final AtomicInteger ID_GENERATOR = new AtomicInteger(); + private static final String DEFAULT_ORGANIZATION_KEY = "default-organization"; private final TesterSession session; @@ -94,9 +95,9 @@ public class UserTester { @SafeVarargs public final User generateAdministratorOnDefaultOrganization(Consumer... populators) { User user = generate(populators); - session.wsClient().organizations().addMember("default-organization", user.getLogin()); + session.wsClient().organizations().addMember(DEFAULT_ORGANIZATION_KEY, user.getLogin()); session.wsClient().userGroups().addUser(AddUserWsRequest.builder() - .setOrganization("default-organization") + .setOrganization(DEFAULT_ORGANIZATION_KEY) .setLogin(user.getLogin()) .setName("sonar-administrators") .build()); @@ -110,6 +111,13 @@ public class UserTester { return user; } + @SafeVarargs + public final User generateMemberOfDefaultOrganization(Consumer... populators) { + User user = generate(populators); + session.wsClient().organizations().addMember(DEFAULT_ORGANIZATION_KEY, user.getLogin()); + return user; + } + public UsersService service() { return session.wsClient().users(); } diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/LoginPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/LoginPage.java index 8fb508c4ed3..fc1b794f43b 100644 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/LoginPage.java +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/LoginPage.java @@ -30,6 +30,9 @@ public class LoginPage { Selenide.$("#login_form").should(Condition.exist); } + /** + * The password is the same as the login. + */ public Navigation submitCredentials(String login) { return submitCredentials(login, login, Navigation.class); } -- 2.39.5