3 * Copyright (C) 2009-2019 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package org.sonar.server.authentication.ws;
22 import java.util.Arrays;
23 import org.junit.Test;
24 import org.sonar.api.server.ws.WebService;
25 import org.sonar.server.ws.ServletFilterHandler;
26 import org.sonar.server.ws.WsTester;
28 import static org.assertj.core.api.Assertions.assertThat;
30 public class AuthenticationWsTest {
32 WsTester tester = new WsTester(new AuthenticationWs(Arrays.asList(
33 new LoginAction(null, null, null, null, null),
34 new LogoutAction(null, null),
35 new ValidateAction(null, null, null))));
38 public void define_ws() {
39 WebService.Controller controller = tester.controller("api/authentication");
40 assertThat(controller).isNotNull();
41 assertThat(controller.description()).isNotEmpty();
42 assertThat(controller.actions()).hasSize(3);
44 WebService.Action validate = controller.action("validate");
45 assertThat(validate).isNotNull();
46 assertThat(validate.handler()).isInstanceOf(ServletFilterHandler.class);
47 assertThat(validate.responseExampleAsString()).isNotEmpty();
48 assertThat(validate.params()).isEmpty();
50 WebService.Action login = controller.action("login");
51 assertThat(login).isNotNull();
52 assertThat(login.handler()).isInstanceOf(ServletFilterHandler.class);
53 assertThat(login.isPost()).isTrue();
54 assertThat(login.params()).hasSize(2);
56 WebService.Action logout = controller.action("logout");
57 assertThat(logout).isNotNull();
58 assertThat(logout.handler()).isInstanceOf(ServletFilterHandler.class);
59 assertThat(logout.isPost()).isTrue();
60 assertThat(logout.params()).isEmpty();