From 46cc39ed2381e71b9d9a899483b1b1ab4a3bea20 Mon Sep 17 00:00:00 2001 From: DOHA Date: Mon, 30 May 2016 11:48:04 +0200 Subject: [PATCH] add swagger test --- .../baeldung/spring/SecurityJavaConfig.java | 2 +- .../org/baeldung/web/SwaggerLiveTest.java | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 spring-security-rest/src/test/java/org/baeldung/web/SwaggerLiveTest.java diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/SecurityJavaConfig.java b/spring-security-rest/src/main/java/org/baeldung/spring/SecurityJavaConfig.java index 23c8155491..3302482f48 100644 --- a/spring-security-rest/src/main/java/org/baeldung/spring/SecurityJavaConfig.java +++ b/spring-security-rest/src/main/java/org/baeldung/spring/SecurityJavaConfig.java @@ -44,7 +44,7 @@ public class SecurityJavaConfig extends WebSecurityConfigurerAdapter { .authorizeRequests() .antMatchers("/api/csrfAttacker*").permitAll() .antMatchers("/api/customer/**").permitAll() - .antMatchers("/api/**").authenticated() + .antMatchers("/api/foos/**").authenticated() .and() .formLogin() .successHandler(authenticationSuccessHandler) diff --git a/spring-security-rest/src/test/java/org/baeldung/web/SwaggerLiveTest.java b/spring-security-rest/src/test/java/org/baeldung/web/SwaggerLiveTest.java new file mode 100644 index 0000000000..792b3e28ce --- /dev/null +++ b/spring-security-rest/src/test/java/org/baeldung/web/SwaggerLiveTest.java @@ -0,0 +1,20 @@ +package org.baeldung.web; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +import com.jayway.restassured.RestAssured; +import com.jayway.restassured.response.Response; + +public class SwaggerLiveTest { + private static final String URL_PREFIX = "http://localhost:8080/spring-security-rest/api"; + + @Test + public void whenVerifySpringFoxIsWorking_thenOK() { + final Response response = RestAssured.get(URL_PREFIX + "/v2/api-docs"); + assertEquals(200, response.statusCode()); + System.out.println(response.asString()); + + } +}