-
Notifications
You must be signed in to change notification settings - Fork 0
Support conventional server URL variable #468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e95f957
WIP
gabrielfeo 80bfa76
Fix indentation
gabrielfeo 0d81170
Add custom URL test case
gabrielfeo dff4ab4
Test URL validation in ConfigTest
gabrielfeo efeded8
Strongly type develocityUrl property
gabrielfeo 668deca
Rename property to server; improve javadoc
gabrielfeo a10b391
Dump new API
gabrielfeo 95ebc82
Refactor
gabrielfeo ca0c16c
Move to URI
gabrielfeo 49485bd
Remove unnecessary test setup
gabrielfeo 5d3a098
Update workflow env
gabrielfeo b83d643
Dump new API
gabrielfeo b77fa6b
Remove redundant tests
gabrielfeo 548b61d
Improve error message
gabrielfeo 266b323
Improve error test cases
gabrielfeo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
library/src/test/kotlin/com/gabrielfeo/develocity/api/CacheConfigTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,20 @@ | ||
package com.gabrielfeo.develocity.api | ||
|
||
import com.gabrielfeo.develocity.api.internal.FakeEnv | ||
import com.gabrielfeo.develocity.api.internal.FakeSystemProperties | ||
import com.gabrielfeo.develocity.api.internal.auth.AccessKeyResolver | ||
import com.gabrielfeo.develocity.api.internal.auth.accessKeyResolver | ||
import com.gabrielfeo.develocity.api.internal.env | ||
import com.gabrielfeo.develocity.api.internal.systemProperties | ||
import com.gabrielfeo.develocity.api.internal.* | ||
import com.gabrielfeo.develocity.api.internal.auth.* | ||
import okio.Path.Companion.toPath | ||
import okio.fakefilesystem.FakeFileSystem | ||
import org.junit.jupiter.api.DynamicTest.dynamicTest | ||
import org.junit.jupiter.api.TestFactory | ||
import org.junit.jupiter.api.assertDoesNotThrow | ||
import kotlin.test.BeforeTest | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertFails | ||
import java.net.URI | ||
import kotlin.test.* | ||
|
||
class ConfigTest { | ||
|
||
@BeforeTest | ||
fun before() { | ||
env = FakeEnv("DEVELOCITY_API_URL" to "https://example.com/api/") | ||
env = FakeEnv("DEVELOCITY_URL" to "https://example.com/") | ||
systemProperties = FakeSystemProperties() | ||
accessKeyResolver = AccessKeyResolver( | ||
env, | ||
|
@@ -30,38 +26,64 @@ class ConfigTest { | |
@Test | ||
fun `Given no URL set in env, error`() { | ||
env = FakeEnv() | ||
assertFails { | ||
assertFailsWith<IllegalArgumentException> { | ||
Config() | ||
} | ||
} | ||
|
||
@Test | ||
fun `Given URL set in env, apiUrl is env URL`() { | ||
(env as FakeEnv)["DEVELOCITY_API_URL"] = "https://example.com/api/" | ||
assertEquals("https://example.com/api/", Config().apiUrl) | ||
fun `Given server URL set in env, server is correct URL`() { | ||
(env as FakeEnv)["DEVELOCITY_URL"] = "https://example.com/" | ||
assertEquals(URI("https://example.com/"), Config().server) | ||
} | ||
|
||
@Test | ||
fun `Given server URL set in code, server is correct URL`() { | ||
val config = Config(server = URI("https://custom.example.com/")) | ||
assertEquals(URI("https://custom.example.com/"), config.server) | ||
} | ||
|
||
@TestFactory | ||
fun `Given malformed URL, error`() = listOf( | ||
"mailto:[email protected]", | ||
"file:///example/foo", | ||
"http://example.com?foo", | ||
"https://example.com?foo", | ||
"https://example.com/foo", | ||
"https://example.com/foo?bar=1", | ||
"https://example.com/foo/bar/baz", | ||
"https://example.com/foo/bar/baz?qux=1", | ||
).map { url -> | ||
dynamicTest(url) { | ||
assertFailsWith<IllegalArgumentException> { | ||
Config(server = URI(url)) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun `Given default access key function and resolvable key, accessKey is key`() { | ||
(env as FakeEnv)["DEVELOCITY_API_URL"] = "https://example.com/api/" | ||
(env as FakeEnv)["DEVELOCITY_URL"] = "https://example.com/" | ||
(env as FakeEnv)["DEVELOCITY_ACCESS_KEY"] = "example.com=foo" | ||
assertEquals("foo", Config().accessKey()) | ||
} | ||
|
||
@Test | ||
fun `Given default access key and no resolvable key, error`() { | ||
(env as FakeEnv)["DEVELOCITY_API_URL"] = "https://example.com/api/" | ||
fun `Given default access key function and no resolvable key, error`() { | ||
(env as FakeEnv)["DEVELOCITY_URL"] = "https://example.com/" | ||
(env as FakeEnv)["DEVELOCITY_ACCESS_KEY"] = "notexample.com=foo" | ||
assertFails { | ||
assertFailsWith<IllegalArgumentException> { | ||
Config().accessKey() | ||
} | ||
} | ||
|
||
@Test | ||
fun `Given custom access key function fails, error`() { | ||
assertFails { | ||
Config(accessKey = { error("foo") }).accessKey() | ||
fun `Given custom access key function fails, uncaught and unwrapped error`() { | ||
val error = assertFails { | ||
Config(accessKey = { throw RuntimeException("foo") }).accessKey() | ||
} | ||
assertIs<RuntimeException>(error) | ||
assertEquals("foo", error.message) | ||
} | ||
|
||
@Test | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.