실패 테스트 모두 수정
This commit is contained in:
@@ -2,7 +2,9 @@ package org.egovframe.cloud.apigateway;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
@ActiveProfiles(profiles = "test")
|
||||
@SpringBootTest
|
||||
class ApigatewayApplicationTests {
|
||||
|
||||
|
||||
@@ -4,10 +4,12 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@ActiveProfiles(profiles = "test")
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
class MessageSourceConfigTest {
|
||||
|
||||
@@ -17,7 +19,7 @@ class MessageSourceConfigTest {
|
||||
@Test
|
||||
public void 메세지를_외부위치에서_읽어온다() throws Exception {
|
||||
// when
|
||||
String message = restTemplate.getForObject("http://localhost:8000/api/v1/messages/common.login/ko", String.class);
|
||||
String message = restTemplate.getForObject("/api/v1/messages/common.login/ko", String.class);
|
||||
|
||||
// then
|
||||
assertThat(message).isEqualTo("로그인");
|
||||
|
||||
@@ -1,27 +1,33 @@
|
||||
package org.egovframe.cloud.apigateway.config;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
|
||||
@SpringBootTest
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@EnableConfigurationProperties
|
||||
@TestPropertySource(properties = {"spring.config.location=classpath:application-test.yml"})
|
||||
@ActiveProfiles(profiles = "test")
|
||||
class ReactiveAuthorizationTest {
|
||||
|
||||
@Value("${server.port}")
|
||||
private String PORT;
|
||||
@Autowired
|
||||
private WebTestClient webTestClient;
|
||||
|
||||
@Test
|
||||
public void API요청시_토큰인증_만료된다() throws Exception {
|
||||
// given
|
||||
String baseUrl = "http://localhost:" + PORT;
|
||||
String notValidToken = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI2NWEwMGY2NS04NDYwLTQ5YWYtOThlYy0wNDI5NzdlNTZmNGIiLCJhdXRob3JpdGllcyI6IlJPTEVfVVNFUiIsImV4cCI6MTYyNjc4MjQ0N30.qiScvtr1m88SHPLpHqcJiklXFyIQ7WBJdiFcdcb2B8YSWC59QcdRRgMtXDGSZnjBgF194W-GRBpHUta6VCkrfQ";
|
||||
|
||||
// when, then
|
||||
WebTestClient.bindToServer().baseUrl(baseUrl).defaultHeader(HttpHeaders.AUTHORIZATION, notValidToken).build()
|
||||
webTestClient
|
||||
.get()
|
||||
.uri("/user-service/api/v1/users")
|
||||
.header(HttpHeaders.AUTHORIZATION, notValidToken)
|
||||
.exchange().expectStatus().isUnauthorized()
|
||||
;
|
||||
}
|
||||
|
||||
25
backend/apigateway/src/test/resources/application-test.yml
Normal file
25
backend/apigateway/src/test/resources/application-test.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
server:
|
||||
port: 8000
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: apigateway
|
||||
|
||||
file:
|
||||
directory: ${user.home}/msa-attach-volume
|
||||
messages:
|
||||
directory: ${file.directory}/messages
|
||||
|
||||
# jwt token
|
||||
token:
|
||||
secret: egovframe_user_token
|
||||
|
||||
# ftp server
|
||||
ftp:
|
||||
enabled: false # ftp 사용 여부, FTP 서버에 최상위 디렉토리 자동 생성 및 구현체를 결정하게 된다.
|
||||
|
||||
# eureka 가 포함되면 eureka server 도 등록되므로 해제한다.
|
||||
eureka:
|
||||
client:
|
||||
register-with-eureka: false
|
||||
fetch-registry: false
|
||||
Reference in New Issue
Block a user