mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
Fix cypress by using new stage "TESTING"
Cypress did not work because of the stricter security header. We introduced a new stage named "TESTING" which ignores this security headers and allow testing tools to work as intended. Committed-by: Konstantin Schaper <konstantin.schaper@cloudogu.com>
This commit is contained in:
@@ -43,7 +43,13 @@ public enum Stage
|
|||||||
/**
|
/**
|
||||||
* This value indicates SCM-Manager is right now productive.
|
* This value indicates SCM-Manager is right now productive.
|
||||||
*/
|
*/
|
||||||
PRODUCTION(com.google.inject.Stage.PRODUCTION);
|
PRODUCTION(com.google.inject.Stage.PRODUCTION),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This value indicates SCM-Manager is right now in development but specifically configured for testing.
|
||||||
|
* @since 2.47.0
|
||||||
|
*/
|
||||||
|
TESTING(com.google.inject.Stage.DEVELOPMENT);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new Stage
|
* Constructs a new Stage
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ describe("Repository File Search", () => {
|
|||||||
// Create user and login
|
// Create user and login
|
||||||
username = hri.random();
|
username = hri.random();
|
||||||
password = hri.random();
|
password = hri.random();
|
||||||
|
cy.restSetConfig({ enabledFileSearch: true });
|
||||||
cy.restCreateUser(username, password);
|
cy.restCreateUser(username, password);
|
||||||
cy.restLogin(username, password);
|
cy.restLogin(username, password);
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ffmpeg-installer/ffmpeg": "^1.0.20",
|
"@ffmpeg-installer/ffmpeg": "^1.0.20",
|
||||||
"@scm-manager/integration-test-runner": "^3.3.0",
|
"@scm-manager/integration-test-runner": "^3.4.3",
|
||||||
"fluent-ffmpeg": "^2.1.2"
|
"fluent-ffmpeg": "^2.1.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -26,4 +26,4 @@
|
|||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,11 @@
|
|||||||
package sonia.scm.filter;
|
package sonia.scm.filter;
|
||||||
|
|
||||||
import sonia.scm.Priority;
|
import sonia.scm.Priority;
|
||||||
|
import sonia.scm.SCMContextProvider;
|
||||||
|
import sonia.scm.Stage;
|
||||||
import sonia.scm.web.filter.HttpFilter;
|
import sonia.scm.web.filter.HttpFilter;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
import javax.servlet.FilterChain;
|
import javax.servlet.FilterChain;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@@ -36,47 +39,57 @@ import java.io.IOException;
|
|||||||
@Priority(7000)
|
@Priority(7000)
|
||||||
@WebElement("*")
|
@WebElement("*")
|
||||||
public class SecurityHeadersFilter extends HttpFilter {
|
public class SecurityHeadersFilter extends HttpFilter {
|
||||||
|
|
||||||
|
private final SCMContextProvider contextProvider;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public SecurityHeadersFilter(SCMContextProvider contextProvider) {
|
||||||
|
this.contextProvider = contextProvider;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
|
protected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||||
response.setHeader("X-Frame-Options", "deny");
|
if (contextProvider.getStage() != Stage.TESTING) {
|
||||||
response.setHeader("X-Content-Type-Options", "nosniff");
|
response.setHeader("X-Frame-Options", "deny");
|
||||||
response.setHeader("Content-Security-Policy",
|
response.setHeader("X-Content-Type-Options", "nosniff");
|
||||||
|
response.setHeader("Content-Security-Policy",
|
||||||
"form-action 'self'; " +
|
"form-action 'self'; " +
|
||||||
"object-src 'none'; " +
|
"object-src 'none'; " +
|
||||||
"frame-ancestors 'none'; " +
|
"frame-ancestors 'none'; " +
|
||||||
"block-all-mixed-content"
|
"block-all-mixed-content"
|
||||||
);
|
);
|
||||||
response.setHeader("Permissions-Policy",
|
response.setHeader("Permissions-Policy",
|
||||||
"accelerometer=()," +
|
"accelerometer=()," +
|
||||||
"ambient-light-sensor=()," +
|
"ambient-light-sensor=()," +
|
||||||
"autoplay=()," +
|
"autoplay=()," +
|
||||||
"battery=()," +
|
"battery=()," +
|
||||||
"camera=()," +
|
"camera=()," +
|
||||||
"display-capture=()," +
|
"display-capture=()," +
|
||||||
"document-domain=()," +
|
"document-domain=()," +
|
||||||
"encrypted-media=()," +
|
"encrypted-media=()," +
|
||||||
"fullscreen=()," +
|
"fullscreen=()," +
|
||||||
"gamepad=()," +
|
"gamepad=()," +
|
||||||
"geolocation=()," +
|
"geolocation=()," +
|
||||||
"gyroscope=()," +
|
"gyroscope=()," +
|
||||||
"layout-animations=(self)," +
|
"layout-animations=(self)," +
|
||||||
"legacy-image-formats=(self)," +
|
"legacy-image-formats=(self)," +
|
||||||
"magnetometer=()," +
|
"magnetometer=()," +
|
||||||
"microphone=()," +
|
"microphone=()," +
|
||||||
"midi=()," +
|
"midi=()," +
|
||||||
"oversized-images=(self)," +
|
"oversized-images=(self)," +
|
||||||
"payment=()," +
|
"payment=()," +
|
||||||
"picture-in-picture=()," +
|
"picture-in-picture=()," +
|
||||||
"publickey-credentials-get=()," +
|
"publickey-credentials-get=()," +
|
||||||
"speaker-selection=()," +
|
"speaker-selection=()," +
|
||||||
"sync-xhr=(self)," +
|
"sync-xhr=(self)," +
|
||||||
"unoptimized-images=(self)," +
|
"unoptimized-images=(self)," +
|
||||||
"unsized-media=(self)," +
|
"unsized-media=(self)," +
|
||||||
"usb=()," +
|
"usb=()," +
|
||||||
"screen-wake-lock=()," +
|
"screen-wake-lock=()," +
|
||||||
"web-share=()," +
|
"web-share=()," +
|
||||||
"xr-spatial-tracking=()"
|
"xr-spatial-tracking=()"
|
||||||
);
|
);
|
||||||
|
}
|
||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3091,10 +3091,10 @@
|
|||||||
eslint-plugin-react-hooks "^2.1.2"
|
eslint-plugin-react-hooks "^2.1.2"
|
||||||
jest "^26.6.3"
|
jest "^26.6.3"
|
||||||
|
|
||||||
"@scm-manager/integration-test-runner@^3.3.0":
|
"@scm-manager/integration-test-runner@^3.4.3":
|
||||||
version "3.4.1"
|
version "3.4.3"
|
||||||
resolved "https://registry.npmjs.org/@scm-manager/integration-test-runner/-/integration-test-runner-3.4.1.tgz"
|
resolved "https://registry.yarnpkg.com/@scm-manager/integration-test-runner/-/integration-test-runner-3.4.3.tgz#6a2e44f5c360fb1c40c3701cf9e8ddadd5031666"
|
||||||
integrity sha512-BiJ5h3ZEedqGcuymd+xLjJzd6x0Qpw2pHoHpJ1Rd7oEjs9Eny0yeI5b3ElRgI4E/ybHWs0o3s/wVQ2LE5pmw9Q==
|
integrity sha512-tA3B5iDAsNWQgXUiMhnrz7sX5dc0674R5Xb+Fch5kSysxMjwn5gMeDUIXA6j5S6OXsp8jlIj/y70m5foplO2WQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@ffmpeg-installer/ffmpeg" "^1.0.20"
|
"@ffmpeg-installer/ffmpeg" "^1.0.20"
|
||||||
"@octokit/rest" "^18.0.9"
|
"@octokit/rest" "^18.0.9"
|
||||||
|
|||||||
Reference in New Issue
Block a user