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;
|
||||
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,25 +20,30 @@ import org.springframework.test.context.TestPropertySource;
|
||||
"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());
|
||||
}
|
||||
|
||||
@@ -14,9 +14,6 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
|
||||
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.eclipse.hawkbit.im.authentication.SpRole;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.repository.test.util.WithUser;
|
||||
@@ -34,8 +31,10 @@ import org.springframework.test.web.servlet.ResultActions;
|
||||
CorsTest.ALLOWED_ORIGIN_SECOND,
|
||||
"hawkbit.server.security.cors.exposedHeaders=" +
|
||||
HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN })
|
||||
@Feature("Integration Test - Security")
|
||||
@Story("CORS")
|
||||
/**
|
||||
* Feature: Integration Test - Security<br/>
|
||||
* Story: CORS
|
||||
*/
|
||||
class CorsTest extends AbstractSecurityTest {
|
||||
|
||||
static final String ALLOWED_ORIGIN_FIRST = "http://test.first.origin";
|
||||
@@ -44,9 +43,10 @@ class CorsTest extends AbstractSecurityTest {
|
||||
private static final String INVALID_ORIGIN = "http://test.invalid.origin";
|
||||
private static final String INVALID_CORS_REQUEST = "Invalid CORS request";
|
||||
|
||||
@Test
|
||||
@Description("Ensures that Cors is working.")
|
||||
@WithUser(authorities = SpRole.TENANT_ADMIN, autoCreateTenant = false)
|
||||
/**
|
||||
* Ensures that Cors is working.
|
||||
*/
|
||||
@Test @WithUser(authorities = SpRole.TENANT_ADMIN, autoCreateTenant = false)
|
||||
void validateCorsRequest() throws Exception {
|
||||
performOptionsRequestToRestWithOrigin(ALLOWED_ORIGIN_FIRST).andExpect(status().isOk())
|
||||
.andExpect(header().string(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, ALLOWED_ORIGIN_FIRST));
|
||||
|
||||
@@ -15,46 +15,49 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
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.im.authentication.SpRole;
|
||||
import org.eclipse.hawkbit.repository.test.util.WithUser;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
@Feature("Integration Test - Security")
|
||||
@Story("PreAuthorized enabled")
|
||||
/**
|
||||
* Feature: Integration Test - Security<br/>
|
||||
* Story: PreAuthorized enabled
|
||||
*/
|
||||
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("/rest/v1/distributionsets"))
|
||||
.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.READ_REPOSITORY }, autoCreateTenant = false)
|
||||
/**
|
||||
* Tests whether request succeed if a role is granted for the user
|
||||
*/
|
||||
@Test @WithUser(authorities = { SpPermission.READ_REPOSITORY }, autoCreateTenant = false)
|
||||
void successIfHasRole() throws Exception {
|
||||
mvc.perform(get("/rest/v1/distributionsets"))
|
||||
.andExpect(result -> assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests whether request succeed if a role is granted for the user")
|
||||
@WithUser(authorities = { SpRole.TENANT_ADMIN }, autoCreateTenant = false)
|
||||
/**
|
||||
* Tests whether request succeed if a role is granted for the user
|
||||
*/
|
||||
@Test @WithUser(authorities = { SpRole.TENANT_ADMIN }, autoCreateTenant = false)
|
||||
void successIfHasTenantAdminRole() throws Exception {
|
||||
mvc.perform(get("/rest/v1/distributionsets"))
|
||||
.andExpect(result -> assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests whether read tenant config request fail if a tenant config (or read read) is not granted for the user")
|
||||
@WithUser(authorities = { SpPermission.READ_TARGET }, autoCreateTenant = false)
|
||||
/**
|
||||
* Tests whether read tenant config request fail if a tenant config (or read read) is not granted for the user
|
||||
*/
|
||||
@Test @WithUser(authorities = { SpPermission.READ_TARGET }, autoCreateTenant = false)
|
||||
void onlyDSIfNoTenantConfig() throws Exception {
|
||||
mvc.perform(get("/rest/v1/system/configs"))
|
||||
.andExpect(result -> {
|
||||
@@ -65,9 +68,10 @@ class PreAuthorizeEnabledTest extends AbstractSecurityTest {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests whether read tenant config request succeed if a tenant config (not read explicitly) is granted for the user")
|
||||
@WithUser(authorities = { SpPermission.TENANT_CONFIGURATION }, autoCreateTenant = false)
|
||||
/**
|
||||
* Tests whether read tenant config request succeed if a tenant config (not read explicitly) is granted for the user
|
||||
*/
|
||||
@Test @WithUser(authorities = { SpPermission.TENANT_CONFIGURATION }, autoCreateTenant = false)
|
||||
void successIfHasTenantConfig() throws Exception {
|
||||
mvc.perform(get("/rest/v1/system/configs"))
|
||||
.andExpect(result -> assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value()));
|
||||
|
||||
Reference in New Issue
Block a user