import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.guava.api.Assertions.assertThat;
import static util.ItUtils.newAdminWsClient;
+import static util.ItUtils.resetSettings;
import static util.ItUtils.setServerProperty;
/**
public void cleanUpUsersAndGroupsAndProperties() throws Exception {
userRule.deactivateUsers(USER_LOGIN);
userRule.removeGroups(GROUP1, GROUP2, GROUP3);
- setServerProperty(ORCHESTRATOR, "sonar.auth.fake-base-id-provider.enabled", null);
- setServerProperty(ORCHESTRATOR, "sonar.auth.fake-base-id-provider.user", null);
- setServerProperty(ORCHESTRATOR, "sonar.auth.fake-base-id-provider.throwUnauthorizedMessage", null);
- setServerProperty(ORCHESTRATOR, "sonar.auth.fake-base-id-provider.enabledGroupsSync", null);
- setServerProperty(ORCHESTRATOR, "sonar.auth.fake-base-id-provider.groups", null);
+ resetSettings(ORCHESTRATOR, null, "sonar.auth.fake-base-id-provider.enabled", "sonar.auth.fake-base-id-provider.user",
+ "sonar.auth.fake-base-id-provider.throwUnauthorizedMessage", "sonar.auth.fake-base-id-provider.enabledGroupsSync", "sonar.auth.fake-base-id-provider.groups");
}
@Test
setUserCreatedByAuthPlugin(USER_LOGIN, USER_PROVIDER_ID, USER_NAME, USER_EMAIL);
new SeleneseTest(Selenese.builder().setHtmlTestsInClasspath("authenticate_through_ui",
- "/user/BaseIdentityProviderTest/authenticate_user.html"
- ).build()).runOn(ORCHESTRATOR);
+ "/user/BaseIdentityProviderTest/authenticate_user.html").build()).runOn(ORCHESTRATOR);
userRule.verifyUserExists(USER_LOGIN, USER_NAME, USER_EMAIL);
}
setServerProperty(ORCHESTRATOR, "sonar.auth.fake-base-id-provider.user", null);
new SeleneseTest(Selenese.builder().setHtmlTestsInClasspath("display_unauthorized_page_when_authentication_failed",
- "/user/BaseIdentityProviderTest/display_unauthorized_page_when_authentication_failed.html"
- ).build()).runOn(ORCHESTRATOR);
+ "/user/BaseIdentityProviderTest/display_unauthorized_page_when_authentication_failed.html").build()).runOn(ORCHESTRATOR);
userRule.verifyUserDoesNotExist(USER_LOGIN);
}
setServerProperty(ORCHESTRATOR, "sonar.auth.fake-base-id-provider.allowsUsersToSignUp", "false");
new SeleneseTest(Selenese.builder().setHtmlTestsInClasspath("fail_to_authenticate_when_not_allowed_to_sign_up",
- "/user/BaseIdentityProviderTest/fail_to_authenticate_when_not_allowed_to_sign_up.html"
- ).build()).runOn(ORCHESTRATOR);
+ "/user/BaseIdentityProviderTest/fail_to_authenticate_when_not_allowed_to_sign_up.html").build()).runOn(ORCHESTRATOR);
userRule.verifyUserDoesNotExist(USER_LOGIN);
}
setServerProperty(ORCHESTRATOR, "sonar.auth.fake-base-id-provider.throwUnauthorizedMessage", "true");
new SeleneseTest(Selenese.builder().setHtmlTestsInClasspath("fail_to_authenticate_when_not_allowed_to_sign_up",
- "/user/BaseIdentityProviderTest/fail_to_authenticate_when_not_allowed_to_sign_up.html"
- ).build()).runOn(ORCHESTRATOR);
+ "/user/BaseIdentityProviderTest/fail_to_authenticate_when_not_allowed_to_sign_up.html").build()).runOn(ORCHESTRATOR);
File logFile = ORCHESTRATOR.getServer().getLogs();
assertThat(FileUtils.readFileToString(logFile)).doesNotContain("A functional error has happened");
private static void setGroupsReturnedByAuthPlugin(String... groups) {
setServerProperty(ORCHESTRATOR, "sonar.auth.fake-base-id-provider.enabledGroupsSync", "true");
- setServerProperty(ORCHESTRATOR, "sonar.auth.fake-base-id-provider.groups", Joiner.on(",").join(groups));
+ if (groups.length > 0) {
+ setServerProperty(ORCHESTRATOR, "sonar.auth.fake-base-id-provider.groups", Joiner.on(",").join(groups));
+ }
}
private static void authenticateWithFakeAuthProvider() {
import java.lang.reflect.Type;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.sonarqube.ws.client.HttpConnector;
import org.sonarqube.ws.client.WsClient;
import org.sonarqube.ws.client.WsClientFactories;
+import org.sonarqube.ws.client.setting.ResetRequest;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.FluentIterable.from;
}
public static void resetSettings(Orchestrator orchestrator, @Nullable String componentKey, String... keys) {
- Arrays.stream(keys).forEach(key -> setServerProperty(orchestrator, componentKey, key, null));
+ newAdminWsClient(orchestrator).settingsService().reset(ResetRequest.builder().setKeys(keys).setComponentKey(componentKey).build());
}
public static void resetEmailSettings(Orchestrator orchestrator) {
}
public static void resetPeriods(Orchestrator orchestrator) {
- resetSettings(orchestrator, null, "sonar.timemachine.period1", "sonar.timemachine.period2", "sonar.timemachine.period3", "sonar.timemachine.period4",
- "sonar.timemachine.period5");
+ resetSettings(orchestrator, null, "sonar.timemachine.period1", "sonar.timemachine.period2", "sonar.timemachine.period3");
}
/**