]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-17705 Remove users/dismiss_sonarlint_ad endpoint
authorLéo Geoffroy <99647462+leo-geoffroy-sonarsource@users.noreply.github.com>
Wed, 25 Jan 2023 17:17:23 +0000 (18:17 +0100)
committersonartech <sonartech@sonarsource.com>
Fri, 3 Feb 2023 14:26:00 +0000 (14:26 +0000)
server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/DismissSonarlintAdAction.java [deleted file]
server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/UsersWsModule.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/DismissSonarlintAdActionTest.java [deleted file]
sonar-ws/src/main/java/org/sonarqube/ws/client/user/UsersWsParameters.java

diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/DismissSonarlintAdAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/DismissSonarlintAdAction.java
deleted file mode 100644 (file)
index 01c4d5e..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2023 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;
-import org.sonar.server.user.UserSession;
-
-import static org.sonar.server.user.ws.DismissNoticeAction.SONARLINT_AD;
-import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_DISMISS_SONARLINT_AD;
-
-/**
- * @deprecated use DismissNoticeAction
- */
-@Deprecated(since = "9.6", forRemoval = true)
-public class DismissSonarlintAdAction implements UsersWsAction {
-  private final UserSession userSession;
-  private final DismissNoticeAction dismissNoticeAction;
-
-  public DismissSonarlintAdAction(UserSession userSession, DismissNoticeAction dismissNoticeAction) {
-    this.userSession = userSession;
-    this.dismissNoticeAction = dismissNoticeAction;
-  }
-
-  @Override
-  public void define(WebService.NewController controller) {
-    controller.createAction(ACTION_DISMISS_SONARLINT_AD)
-      .setDescription("Dismiss SonarLint advertisement. Deprecated since 9.6, replaced api/users/dismiss_notice")
-      .setSince("9.2")
-      .setPost(true)
-      .setDeprecatedSince("9.6")
-      .setHandler(this);
-  }
-
-  @Override
-  public void handle(Request request, Response response) throws Exception {
-    userSession.checkLoggedIn();
-    dismissNoticeAction.dismissNotice(response, userSession.getUuid(), SONARLINT_AD);
-  }
-}
index f97f22edfd90864af07da7afed878f1d38807d7b..eae85baf6bbdb94c114efc5998bbfe95afbc9246 100644 (file)
@@ -33,7 +33,6 @@ public class UsersWsModule extends Module {
       UpdateLoginAction.class,
       DeactivateAction.class,
       UserDeactivator.class,
-      DismissSonarlintAdAction.class,
       ChangePasswordAction.class,
       CurrentAction.class,
       SearchAction.class,
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/DismissSonarlintAdActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/DismissSonarlintAdActionTest.java
deleted file mode 100644 (file)
index 24484d4..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2023 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.Rule;
-import org.junit.Test;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
-import org.sonar.db.user.UserDto;
-import org.sonar.server.exceptions.UnauthorizedException;
-import org.sonar.server.tester.UserSessionRule;
-import org.sonar.server.ws.TestRequest;
-import org.sonar.server.ws.WsActionTester;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_DISMISS_SONARLINT_AD;
-
-public class DismissSonarlintAdActionTest {
-  @Rule
-  public UserSessionRule userSession = UserSessionRule.standalone();
-  @Rule
-  public DbTester db = DbTester.create(System2.INSTANCE);
-
-  private final DismissNoticeAction dismissNoticeAction = new DismissNoticeAction(userSession, db.getDbClient());
-  private final WsActionTester underTest = new WsActionTester(new DismissSonarlintAdAction(userSession, dismissNoticeAction));
-
-  @Test
-  public void test_definition() {
-    WebService.Action definition = underTest.getDef();
-    assertThat(definition.key()).isEqualTo(ACTION_DISMISS_SONARLINT_AD);
-    assertThat(definition.description()).isEqualTo("Dismiss SonarLint advertisement. Deprecated since 9.6, replaced api/users/dismiss_notice");
-    assertThat(definition.since()).isEqualTo("9.2");
-    assertThat(definition.isPost()).isTrue();
-    assertThat(definition.params()).isEmpty();
-    assertThat(definition.changelog()).isEmpty();
-  }
-
-  @Test
-  public void endpoint_throw_exception_if_no_user_login() {
-    final TestRequest request = underTest.newRequest();
-    assertThatThrownBy(request::execute)
-      .isInstanceOf(UnauthorizedException.class);
-  }
-
-  @Test
-  public void calling_endpoint_should_set_sonarlint_ad_seen_true() {
-    UserDto user = db.users().insertUser(u -> u
-      .setLogin("obiwan.kenobi")
-      .setName("Obiwan Kenobi")
-      .setEmail(null));
-    userSession.logIn(user);
-    assertThat(db.properties().findFirstUserProperty(userSession.getUuid(), "user.dismissedNotices.sonarlintAd")).isEmpty();
-
-    underTest.newRequest().execute();
-    UserDto updatedUser = db.users().selectUserByLogin(user.getLogin()).get();
-    assertThat(db.properties().findFirstUserProperty(userSession.getUuid(), "user.dismissedNotices.sonarlintAd")).isPresent();
-  }
-}
index 99be8a4191d159120d05dbd7cc54ebb0bfcbdb7a..315502e4c16c5dafd1d1b78bf9fdd17aed64824b 100644 (file)
@@ -29,7 +29,6 @@ public class UsersWsParameters {
   public static final String ACTION_UPDATE = "update";
   public static final String ACTION_CURRENT = "current";
   public static final String ACTION_UPDATE_IDENTITY_PROVIDER = "update_identity_provider";
-  public static final String ACTION_DISMISS_SONARLINT_AD = "dismiss_sonarlint_ad";
 
   public static final String PARAM_LOGIN = "login";
   public static final String PARAM_PASSWORD = "password";