]> source.dussan.org Git - archiva.git/blob
eff49c12c9afb344f735dbbe19966ec0ff1f85f8
[archiva.git] /
1 package org.apache.archiva.rest.services.v2;
2
3 /*
4  * Licensed to the Apache Software Foundation (ASF) under one
5  * or more contributor license agreements.  See the NOTICE file
6  * distributed with this work for additional information
7  * regarding copyright ownership.  The ASF licenses this file
8  * to you under the Apache License, Version 2.0 (the
9  * "License"); you may not use this file except in compliance
10  * with the License.  You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  */
20
21 import io.restassured.response.Response;
22 import org.junit.jupiter.api.AfterAll;
23 import org.junit.jupiter.api.BeforeAll;
24 import org.junit.jupiter.api.DisplayName;
25 import org.junit.jupiter.api.MethodOrderer;
26 import org.junit.jupiter.api.Tag;
27 import org.junit.jupiter.api.Test;
28 import org.junit.jupiter.api.TestInstance;
29 import org.junit.jupiter.api.TestMethodOrder;
30 import org.junit.jupiter.api.extension.ExtendWith;
31 import org.springframework.test.context.ContextConfiguration;
32 import org.springframework.test.context.junit.jupiter.SpringExtension;
33
34 import static io.restassured.RestAssured.given;
35 import static io.restassured.http.ContentType.JSON;
36 import static org.junit.jupiter.api.Assertions.*;
37
38 /**
39  * @author Martin Stockhammer <martin_s@apache.org>
40  */
41 @TestInstance( TestInstance.Lifecycle.PER_CLASS )
42 @Tag( "rest-native" )
43 @TestMethodOrder( MethodOrderer.Random.class )
44 @DisplayName( "Native REST tests for V2 SecurityConfigurationService" )
45 public class NativeSecurityConfigurationServiceTest extends AbstractNativeRestServices
46 {
47     @Override
48     protected String getServicePath( )
49     {
50         return "/security";
51     }
52
53     @BeforeAll
54     void setup( ) throws Exception
55     {
56         super.setupNative( );
57     }
58
59     @AfterAll
60     void destroy( ) throws Exception
61     {
62         super.shutdownNative( );
63     }
64
65     @Test
66     void testGetConfiguration() {
67         String token = getAdminToken( );
68             Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
69                 .when( )
70                 .get( "config" )
71                 .prettyPeek()
72                 .then( ).statusCode( 200 ).extract( ).response( );
73         assertNotNull( response );
74         assertEquals( "jpa", response.getBody( ).jsonPath( ).getString( "active_user_managers[0]" ) );
75         assertEquals( "jpa", response.getBody( ).jsonPath( ).getString( "active_rbac_managers[0]" ) );
76         assertEquals( "memory", response.getBody( ).jsonPath( ).getString( "properties.\"authentication.jwt.keystoreType\"" ) );
77         assertEquals("10",response.getBody( ).jsonPath( ).getString( "properties.\"security.policy.allowed.login.attempt\""));
78         assertTrue( response.getBody( ).jsonPath( ).getBoolean( "user_cache_enabled" ) );
79         assertFalse( response.getBody( ).jsonPath( ).getBoolean( "ldap_active" ) );
80     }
81
82 }