Skip to content
Snippets Groups Projects
Commit 598c3aad authored by Jan Zickermann's avatar Jan Zickermann
Browse files

OZG-5176 OZG-5278 Use `@WithJwt` in security integration test

parent 3bf479f0
No related branches found
No related tags found
Loading
...@@ -33,11 +33,9 @@ import org.junit.jupiter.params.provider.ValueSource; ...@@ -33,11 +33,9 @@ import org.junit.jupiter.params.provider.ValueSource;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultActions; import org.springframework.test.web.servlet.ResultActions;
import de.ozgcloud.admin.common.user.UserRole;
import de.ozgcloud.common.test.DataITCase; import de.ozgcloud.common.test.DataITCase;
import lombok.SneakyThrows; import lombok.SneakyThrows;
...@@ -179,9 +177,18 @@ class SecurityConfigurationITCase { ...@@ -179,9 +177,18 @@ class SecurityConfigurationITCase {
@DisplayName("with admin role") @DisplayName("with admin role")
@Nested @Nested
class TestWithAdminRole { class TestWithAdminRole {
static final String CLAIMS = """
{
"preferredUsername": "testUser",
"scope": "openid testscope",
"resource_access": { "admin": { "roles": ["ADMIN_ADMIN"] } }
}""";
@Test @Test
@SneakyThrows @SneakyThrows
@WithMockUser(roles = UserRole.ADMIN_USER) @WithJwt(CLAIMS)
void shouldAllowSettings() { void shouldAllowSettings() {
var result = mockMvc.perform(get("/api/configuration/settings")); var result = mockMvc.perform(get("/api/configuration/settings"));
...@@ -190,7 +197,7 @@ class SecurityConfigurationITCase { ...@@ -190,7 +197,7 @@ class SecurityConfigurationITCase {
@Test @Test
@SneakyThrows @SneakyThrows
@WithMockUser(roles = UserRole.ADMIN_USER) @WithJwt(CLAIMS)
void shouldAllowConfiguration() { void shouldAllowConfiguration() {
var result = mockMvc.perform(get("/api/configuration")); var result = mockMvc.perform(get("/api/configuration"));
......
mongock: mongock:
enabled: false enabled: false
ozgcloud:
oauth2:
auth-server-url: https://sso.it-case.de
realm: by-kiel-dev
resource: admin
management:
server:
port: 8081
spring:
application:
name: OzgCloud_Administration
data:
mongodb:
authentication-database: admin
rest:
basePath: /api/configuration
cloud:
config:
server:
prefix: /configserver
security:
oauth2:
resourceserver:
jwt:
issuer-uri: ${ozgcloud.oauth2.auth-server-url}/realms/${ozgcloud.oauth2.realm}
ozgcloud:
oauth2:
auth-server-url: https://sso.dev.by.ozg-cloud.de
realm: by-kiel-dev
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment