55
66import java .util .List ;
77import org .junit .jupiter .api .Nested ;
8- import org .junit .jupiter .api .Test ;
98import org .junit .jupiter .params .ParameterizedTest ;
109import org .junit .jupiter .params .provider .NullAndEmptySource ;
1110import org .junit .jupiter .params .provider .ValueSource ;
11+ import timeeat .exception .InitializeException ;
1212
1313class OauthPropertiesTest {
1414
@@ -19,23 +19,23 @@ class Validate {
1919 @ NullAndEmptySource
2020 void 클라이언트_아이디가_비어있는_경우_예외를_던진다 (String clientId ) {
2121 assertThatThrownBy (() -> new OauthProperties (clientId , "/path" , List .of ("http://localhost:8080" )))
22- .isInstanceOf (RuntimeException .class )
22+ .isInstanceOf (InitializeException .class )
2323 .hasMessage ("Client ID must not be null or empty" );
2424 }
2525
2626 @ ParameterizedTest
2727 @ ValueSource (strings = {"path" , ".path" , "path/" , "" })
2828 void 리다이렉트_경로가_경로_형식이_아닌_경우_예외를_던진다 (String redirectPath ) {
2929 assertThatThrownBy (() -> new OauthProperties ("client-id" , redirectPath , List .of ("http://localhost:8080" )))
30- .isInstanceOf (RuntimeException .class )
30+ .isInstanceOf (InitializeException .class )
3131 .hasMessage ("Redirect path must not be null or start with '/'" );
3232 }
3333
3434 @ ParameterizedTest
3535 @ ValueSource (strings = {"invalid-url" , "http://" , "http://:8080" , "http://localhost:8080/path" , " " })
3636 void 허용된_오리진이_유효하지_않은_URL인_경우_예외를_던진다 (String origin ) {
3737 assertThatThrownBy (() -> new OauthProperties ("client-id" , "/path" , List .of (origin )))
38- .isInstanceOf (RuntimeException .class )
38+ .isInstanceOf (InitializeException .class )
3939 .hasMessageContaining ("Allowed origin must be a valid origin form" );
4040 }
4141 }
@@ -44,7 +44,8 @@ class Validate {
4444 class IsAllowedOrigin {
4545
4646 @ ParameterizedTest
47- @ ValueSource (strings = {"http://localhost:8080" , " http://localhost:8080 " , "https://example.com" })
47+ @ ValueSource (strings = {"http://localhost:8080" , " http://localhost:8080 " ,
48+ "https://example.com" , "https://example.com/" })
4849 void 허용된_오리진인_경우_true를_반환한다 (String allowedOrigin ) {
4950 List <String > origins = List .of ("http://localhost:8080" , "https://example.com" );
5051 OauthProperties oauthProperties = new OauthProperties ("client-id" , "/path" , origins );
@@ -54,7 +55,8 @@ class IsAllowedOrigin {
5455 assertThat (isAllowed ).isTrue ();
5556 }
5657
57- @ Test
58+ @ ParameterizedTest
59+ @ ValueSource (strings = {"https://not-allowed.com" , "http://localhost:8080/path" , "http://localhost:8080nono" })
5860 void 허용되지_않은_오리진인_경우_false를_반환한다 () {
5961 OauthProperties oauthProperties = new OauthProperties ("client-id" , "/path" ,
6062 List .of ("http://localhost:8080" ));
0 commit comments