Merged heads

This commit is contained in:
Philipp Czora
2018-07-24 13:42:51 +02:00
6 changed files with 87 additions and 14 deletions

2
Jenkinsfile vendored
View File

@@ -31,7 +31,7 @@ node() { // No specific label
}
stage('Unit Test') {
mvn 'test -Dsonia.scm.test.skip.hg=true'
mvn 'test -Dsonia.scm.test.skip.hg=true -Dmaven.test.failure.ignore=true'
}
stage('SonarQube') {

View File

@@ -27,7 +27,8 @@
"build-js": "react-scripts build",
"build": "npm-run-all build-css build-js",
"test": "jest",
"test-coverage": "yarn run test --coverage",
"test-coverage": "jest --coverage",
"test-ci": "jest --ci --coverage",
"eject": "react-scripts eject",
"flow": "flow"
},
@@ -42,6 +43,7 @@
"fetch-mock": "^6.5.0",
"flow-bin": "^0.75.0",
"flow-typed": "^2.5.1",
"jest-junit": "^5.1.0",
"node-sass-chokidar": "^1.3.0",
"npm-run-all": "^4.1.3",
"prettier": "^1.13.7",
@@ -52,5 +54,15 @@
"presets": [
"react-app"
]
},
"jest": {
"coverageDirectory": "target/jest-reports/coverage",
"coveragePathIgnorePatterns": [
"src/tests/.*"
],
"reporters": [ "default", "jest-junit" ]
},
"jest-junit": {
"output": "./target/jest-reports/TEST-all.xml"
}
}

View File

@@ -16,6 +16,15 @@
<version>2.0.0-SNAPSHOT</version>
<name>scm-ui</name>
<properties>
<sonar.language>js</sonar.language>
<sonar.sources>src</sonar.sources>
<sonar.test.exclusions>**/*.test.js,src/tests/**</sonar.test.exclusions>
<sonar.coverage.exclusions>**/*.test.js,src/tests/**</sonar.coverage.exclusions>
<sonar.javascript.jstest.reportsPath>target/jest-reports</sonar.javascript.jstest.reportsPath>
<sonar.javascript.lcov.reportPaths>target/jest-reports/coverage/lcov.info</sonar.javascript.lcov.reportPaths>
</properties>
<build>
<plugins>
@@ -29,7 +38,7 @@
</node>
<pkgManager>
<type>YARN</type>
<version>1.3.2</version>
<version>1.7.0</version>
</pkgManager>
<script>run</script>
</configuration>
@@ -51,10 +60,19 @@
<script>build</script>
</configuration>
</execution>
<execution>
<id>test</id>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<script>test-ci</script>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -4368,6 +4368,10 @@ jest-environment-node@^20.0.3:
jest-mock "^20.0.3"
jest-util "^20.0.3"
jest-get-type@^22.1.0:
version "22.4.3"
resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-22.4.3.tgz#e3a8504d8479342dd4420236b322869f18900ce4"
jest-haste-map@^20.0.4:
version "20.0.5"
resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-20.0.5.tgz#abad74efb1a005974a7b6517e11010709cab9112"
@@ -4393,6 +4397,15 @@ jest-jasmine2@^20.0.4:
once "^1.4.0"
p-map "^1.1.1"
jest-junit@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/jest-junit/-/jest-junit-5.1.0.tgz#e8e497d810a829bf02783125aab74b5df6caa8fe"
dependencies:
jest-validate "^23.0.1"
mkdirp "^0.5.1"
strip-ansi "^4.0.0"
xml "^1.0.1"
jest-matcher-utils@^20.0.3:
version "20.0.3"
resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-20.0.3.tgz#b3a6b8e37ca577803b0832a98b164f44b7815612"
@@ -4491,6 +4504,15 @@ jest-validate@^20.0.3:
leven "^2.1.0"
pretty-format "^20.0.3"
jest-validate@^23.0.1:
version "23.4.0"
resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-23.4.0.tgz#d96eede01ef03ac909c009e9c8e455197d48c201"
dependencies:
chalk "^2.0.1"
jest-get-type "^22.1.0"
leven "^2.1.0"
pretty-format "^23.2.0"
jest@20.0.4:
version "20.0.4"
resolved "https://registry.yarnpkg.com/jest/-/jest-20.0.4.tgz#3dd260c2989d6dad678b1e9cc4d91944f6d602ac"
@@ -6218,6 +6240,13 @@ pretty-format@^20.0.3:
ansi-regex "^2.1.1"
ansi-styles "^3.0.0"
pretty-format@^23.2.0:
version "23.2.0"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-23.2.0.tgz#3b0aaa63c018a53583373c1cb3a5d96cc5e83017"
dependencies:
ansi-regex "^3.0.0"
ansi-styles "^3.2.0"
private@^0.1.6, private@^0.1.7, private@^0.1.8:
version "0.1.8"
resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff"
@@ -8242,6 +8271,10 @@ xml-name-validator@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-2.0.1.tgz#4d8b8f1eccd3419aa362061becef515e1e559635"
xml@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"
xtend@^4.0.0:
version "4.0.1"
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af"

View File

@@ -70,11 +70,6 @@ public class SecurityFilter extends HttpFilter
@VisibleForTesting
static final String ATTRIBUTE_REMOTE_USER = "principal";
/** Field description */
public static final String URL_AUTHENTICATION = "/api/rest/auth";
public static final String URLV2_AUTHENTICATION = "/api/rest/v2/auth";
private final ScmConfiguration configuration;
@Inject

View File

@@ -100,14 +100,29 @@ public class SecurityFilterTest {
}
/**
* Tests filter on authentication endpoint.
*
* Tests filter on authentication endpoint v1.
*
* @throws IOException
* @throws ServletException
*/
@Test
public void testDoOnAuthenticationUrl() throws IOException, ServletException {
when(request.getRequestURI()).thenReturn("/scm/api/rest/authentication");
public void testDoOnAuthenticationUrlV1() throws IOException, ServletException {
checkIfAuthenticationUrlIsPassedThrough("/scm/api/rest/auth/access_token");
}
/**
* Tests filter on authentication endpoint v2.
*
* @throws IOException
* @throws ServletException
*/
@Test
public void testDoOnAuthenticationUrlV2() throws IOException, ServletException {
checkIfAuthenticationUrlIsPassedThrough("/scm/api/rest/v2/auth/access_token");
}
private void checkIfAuthenticationUrlIsPassedThrough(String uri) throws IOException, ServletException {
when(request.getRequestURI()).thenReturn(uri);
securityFilter.doFilter(request, response, chain);
verify(request, never()).setAttribute(Mockito.anyString(), Mockito.any());
verify(chain).doFilter(request, response);
@@ -235,4 +250,4 @@ public class SecurityFilterTest {
}
}
}