Remove allure (phase2) (#2483)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -12,9 +12,6 @@ package org.eclipse.hawkbit.app.ddi;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Story;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
@@ -23,27 +20,32 @@ import org.springframework.test.context.TestPropertySource;
|
||||
"spring.flyway.enabled=true", // if hibernate is used there could be db inconsistencies when executing tests with and without flyway
|
||||
"hawkbit.server.security.allowedHostNames=localhost",
|
||||
"hawkbit.server.security.httpFirewallIgnoredPaths=/index.html" })
|
||||
@Feature("Integration Test - Security")
|
||||
@Story("Allowed Host Names")
|
||||
/**
|
||||
* Feature: Integration Test - Security<br/>
|
||||
* Story: Allowed Host Names
|
||||
*/
|
||||
class AllowedHostNamesTest extends AbstractSecurityTest {
|
||||
|
||||
@Test
|
||||
@Description("Tests whether a RequestRejectedException is thrown when not allowed host is used")
|
||||
void allowedHostNameWithNotAllowedHost() throws Exception {
|
||||
/**
|
||||
* Tests whether a RequestRejectedException is thrown when not allowed host is used
|
||||
*/
|
||||
@Test void allowedHostNameWithNotAllowedHost() throws Exception {
|
||||
mvc.perform(get("/").header(HttpHeaders.HOST, "www.google.com"))
|
||||
.andExpect(status().isBadRequest());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests whether request is redirected when allowed host is used")
|
||||
void allowedHostNameWithAllowedHost() throws Exception {
|
||||
/**
|
||||
* Tests whether request is redirected when allowed host is used
|
||||
*/
|
||||
@Test void allowedHostNameWithAllowedHost() throws Exception {
|
||||
mvc.perform(get("/").header(HttpHeaders.HOST, "localhost"))
|
||||
.andExpect(status().is3xxRedirection());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests whether request without allowed host name and with ignored path end up with a client error")
|
||||
void notAllowedHostnameWithIgnoredPath() throws Exception {
|
||||
/**
|
||||
* Tests whether request without allowed host name and with ignored path end up with a client error
|
||||
*/
|
||||
@Test void notAllowedHostnameWithIgnoredPath() throws Exception {
|
||||
mvc.perform(get("/index.html").header(HttpHeaders.HOST, "www.google.com"))
|
||||
.andExpect(status().is4xxClientError());
|
||||
}
|
||||
|
||||
@@ -12,31 +12,32 @@ package org.eclipse.hawkbit.app.ddi;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Story;
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.repository.test.util.WithUser;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
|
||||
@Feature("Integration Test - Security")
|
||||
@Story("PreAuthorized enabled")
|
||||
/**
|
||||
* Feature: Integration Test - Security<br/>
|
||||
* Story: PreAuthorized enabled
|
||||
*/
|
||||
@TestPropertySource(properties = { "spring.flyway.enabled=true" })
|
||||
class PreAuthorizeEnabledTest extends AbstractSecurityTest {
|
||||
|
||||
@Test
|
||||
@Description("Tests whether request fail if a role is forbidden for the user")
|
||||
@WithUser(authorities = { SpPermission.READ_TARGET }, autoCreateTenant = false)
|
||||
/**
|
||||
* Tests whether request fail if a role is forbidden for the user
|
||||
*/
|
||||
@Test @WithUser(authorities = { SpPermission.READ_TARGET }, autoCreateTenant = false)
|
||||
void failIfNoRole() throws Exception {
|
||||
mvc.perform(get("/DEFAULT/controller/v1/controllerId"))
|
||||
.andExpect(result -> assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.FORBIDDEN.value()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests whether request succeed if a role is granted for the user")
|
||||
@WithUser(authorities = { SpPermission.SpringEvalExpressions.CONTROLLER_ROLE }, autoCreateTenant = false)
|
||||
/**
|
||||
* Tests whether request succeed if a role is granted for the user
|
||||
*/
|
||||
@Test @WithUser(authorities = { SpPermission.SpringEvalExpressions.CONTROLLER_ROLE }, autoCreateTenant = false)
|
||||
void successIfHasRole() throws Exception {
|
||||
mvc.perform(get("/DEFAULT/controller/v1/controllerId"))
|
||||
.andExpect(result -> assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value()));
|
||||
|
||||
Reference in New Issue
Block a user