Skip to content

Commit

Permalink
improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lijamie98 committed Jun 14, 2023
1 parent 2fad087 commit 73989f1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void validateConfig(Errors errors) {
} catch (IllegalArgumentException iaex) {
errors.rejectValue(
"homeDomain",
"sep10-home-domain-invalid",
"sep10-home-domain-too-long",
format(
"The sep10.home_domain (%s) is longer than the maximum length (64) of a domain. Error=%s",
homeDomain, iaex));
Expand All @@ -113,7 +113,7 @@ void validateConfig(Errors errors) {
} catch (IllegalArgumentException iaex) {
errors.rejectValue(
"webAuthDomain",
"sep10-web-auth-domain-invalid",
"sep10-web-auth-domain-too-long",
format(
"The sep10.web_auth_home_domain (%s) is longer than the maximum length (64) of a domain. Error=%s",
webAuthDomain, iaex));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.CsvSource
import org.junit.jupiter.params.provider.MethodSource
import org.junit.jupiter.params.provider.NullSource
import org.junit.jupiter.params.provider.ValueSource
Expand Down Expand Up @@ -138,41 +139,40 @@ class Sep10ConfigTest {
}

@ParameterizedTest
@ValueSource(
strings =
@CsvSource(
value =
[
"this-is-longer-than-64-bytes-which-is-the-maximum-length-for-a-web-auth-domain.stellar.org",
"stellar .org",
"abc",
"299.0.0.1",
"0123456789012345678901234567890123456789012345678912.stellar.org",
"this-is-longer-than-64-bytes-which-is-the-maximum-length-for-a-web-auth-domain.stellar.org,sep10-web-auth-domain-too-long",
"stellar .org,sep10-web-auth-domain-invalid",
"abc,sep10-web-auth-domain-invalid",
"299.0.0.1,sep10-web-auth-domain-invalid",
]
)
fun `test invalid web auth domains`(value: String) {
fun `test invalid web auth domains`(value: String, expectedErrorCode: String) {
config.webAuthDomain = value
config.validateConfig(errors)
assertTrue(errors.hasErrors())
assertErrorCode(errors, "sep10-web-auth-domain-invalid")
assertErrorCode(errors, expectedErrorCode)
}

@ParameterizedTest
@ValueSource(
strings =
@CsvSource(
value =
[
"this-is-longer-than-64-bytes-which-is-the-maximum-length-for-a-home-domain.stellar.org",
"stellar .org",
"abc",
"299.0.0.1",
"http://stellar.org",
"https://stellar.org",
"://stellar.org",
"this-is-longer-than-64-bytes-which-is-the-maximum-length-for-a-home-domain.stellar.org,sep10-home-domain-too-long",
"stellar .org,sep10-home-domain-invalid",
"abc,sep10-home-domain-invalid",
"299.0.0.1,sep10-home-domain-invalid",
"http://stellar.org,sep10-home-domain-invalid",
"https://stellar.org,sep10-home-domain-invalid",
"://stellar.org,sep10-home-domain-invalid",
]
)
fun `test invalid home domains`(value: String) {
fun `test invalid home domains`(value: String, expectedErrorCode: String) {
config.homeDomain = value
config.validateConfig(errors)
assertTrue(errors.hasErrors())
assertErrorCode(errors, "sep10-home-domain-invalid")
assertErrorCode(errors, expectedErrorCode)
}

@Test
Expand Down

0 comments on commit 73989f1

Please sign in to comment.