import it.user.LocalAuthenticationTest;
import it.user.MyAccountPageTest;
import it.user.OAuth2IdentityProviderTest;
+import it.user.SkipOnboardingTest;
import it.ws.WsLocalCallTest;
import it.ws.WsTest;
import org.junit.ClassRule;
// user
MyAccountPageTest.class,
FavoritesWsTest.class,
+ SkipOnboardingTest.class,
// authentication
ForceAuthenticationTest.class,
LocalAuthenticationTest.class,
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.user;
+
+import com.sonar.orchestrator.Orchestrator;
+import it.Category4Suite;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.sonarqube.ws.client.WsResponse;
+import util.ItUtils;
+import util.user.UserRule;
+
+import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class SkipOnboardingTest {
+
+ @ClassRule
+ public static final Orchestrator orchestrator = Category4Suite.ORCHESTRATOR;
+ @ClassRule
+ public static UserRule userRule = UserRule.from(orchestrator);
+
+ @Test
+ public void should_operate_silently() {
+ String login = randomAlphabetic(10).toLowerCase();
+ String password = randomAlphabetic(10).toLowerCase();
+ userRule.createUser(login, password);
+ WsResponse response;
+ try {
+
+ response = ItUtils.newUserWsClient(orchestrator, null, null).users().skipOnboardingTutorial();
+
+ } finally {
+ userRule.deactivateUsers(login);
+ }
+
+ assertThat(response.code()).isEqualTo(204);
+ assertThat(response.hasContent()).isFalse();
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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 org.sonar.server.user.ws;
+
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.Response;
+import org.sonar.api.server.ws.WebService;
+
+public class SkipOnboardingTutorialAction implements UsersWsAction {
+
+ @Override
+ public void define(WebService.NewController context) {
+ context.createAction("skipOnboardingTutorial")
+ .setPost(true)
+ .setInternal(true)
+ .setDescription("Stores that the user has skipped the onboarding tutorial and does not want to see it after future logins." +
+ " Calling this webservice several times will silently ignore subsequent requests.")
+ .setSince("6.5")
+ .setHandler(this);
+ }
+
+ @Override
+ public void handle(Request request, Response response) throws Exception {
+ response.noContent();
+ }
+}
GroupsAction.class,
IdentityProvidersAction.class,
UserPropertiesWs.class,
- UserJsonWriter.class);
+ UserJsonWriter.class,
+ SkipOnboardingTutorialAction.class);
}
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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 org.sonar.server.user.ws;
+
+import org.junit.Test;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.server.ws.TestResponse;
+import org.sonar.server.ws.WsActionTester;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class SkipOnboardingTutorialActionTest {
+
+ @Test
+ public void should_have_a_good_definition() {
+ WsActionTester ws = new WsActionTester(new SkipOnboardingTutorialAction());
+ WebService.Action def = ws.getDef();
+ assertThat(def.isPost()).isTrue();
+ assertThat(def.isInternal()).isTrue();
+ assertThat(def.since()).isEqualTo("6.5");
+ assertThat(def.params()).isEmpty();
+ }
+
+ @Test
+ public void should_return_silently() {
+ WsActionTester ws = new WsActionTester(new SkipOnboardingTutorialAction());
+ TestResponse response = ws.newRequest().setMethod("POST").execute();
+ assertThat(response.getStatus()).isEqualTo(204);
+ assertThat(response.getInput()).isEmpty();
+ }
+}
public void verify_count_of_added_components() {
ComponentContainer container = new ComponentContainer();
new UsersWsModule().configure(container);
- assertThat(container.size()).isEqualTo(2 + 11);
+ assertThat(container.size()).isEqualTo(2 + 12);
}
}
import org.sonarqube.ws.client.GetRequest;
import org.sonarqube.ws.client.PostRequest;
import org.sonarqube.ws.client.WsConnector;
+import org.sonarqube.ws.client.WsResponse;
import static org.sonar.api.server.ws.WebService.Param.FIELDS;
import static org.sonar.api.server.ws.WebService.Param.PAGE;
import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_CREATE;
import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_GROUPS;
import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_SEARCH;
+import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_SKIP_ONBOARDING_TUTORIAL;
import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_UPDATE;
import static org.sonarqube.ws.client.user.UsersWsParameters.CONTROLLER_USERS;
import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_EMAIL;
GroupsWsResponse.parser());
}
+ public WsResponse skipOnboardingTutorial() {
+ return call(new PostRequest(path(ACTION_SKIP_ONBOARDING_TUTORIAL)));
+ }
}
public static final String ACTION_CREATE = "create";
public static final String ACTION_UPDATE = "update";
public static final String ACTION_GROUPS = "groups";
+ public static final String ACTION_SKIP_ONBOARDING_TUTORIAL = "skipOnboardingTutorial";
public static final String PARAM_ORGANIZATION = "organization";
public static final String PARAM_LOGIN = "login";