mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-01-03 06:09:46 +01:00
Add integration test for security filter
This commit is contained in:
26
scm-it/src/test/java/sonia/scm/it/AnonymousAccessITCase.java
Normal file
26
scm-it/src/test/java/sonia/scm/it/AnonymousAccessITCase.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package sonia.scm.it;
|
||||
|
||||
import io.restassured.RestAssured;
|
||||
import org.junit.Test;
|
||||
import sonia.scm.it.utils.RestUtil;
|
||||
import sonia.scm.it.utils.ScmRequests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class AnonymousAccessITCase {
|
||||
|
||||
@Test
|
||||
public void shouldAccessIndexResourceWithoutAuthentication() {
|
||||
ScmRequests.start()
|
||||
.requestIndexResource()
|
||||
.assertStatusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldRejectUserResourceWithoutAuthentication() {
|
||||
assertEquals(401, RestAssured.given()
|
||||
.when()
|
||||
.get(RestUtil.REST_BASE_URL.resolve("users/"))
|
||||
.statusCode());
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,10 @@ public class ScmRequests {
|
||||
return new ScmRequests();
|
||||
}
|
||||
|
||||
public IndexResponse requestIndexResource() {
|
||||
return new IndexResponse(applyGETRequest(RestUtil.REST_BASE_URL.toString()));
|
||||
}
|
||||
|
||||
public IndexResponse requestIndexResource(String username, String password) {
|
||||
setUsername(username);
|
||||
setPassword(password);
|
||||
|
||||
Reference in New Issue
Block a user