-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
111 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: '2' | ||
services: | ||
|
||
artifactory-badge: | ||
image: devatherock/artifactory-badge:latest | ||
network_mode: "host" | ||
environment: | ||
- ARTIFACTORY_URL=http://localhost:8081 | ||
- ARTIFACTORY_API_KEY=dummyKey | ||
- LOGBACK_CONFIGURATION_FILE=https://raw.githubusercontent.com/devatherock/artifactory-badge/master/src/main/resources/logback-json.xml | ||
ports: | ||
- "8080:8080" |
This file contains 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
10 changes: 10 additions & 0 deletions
10
...est/groovy/io/github/devatherock/artifactory/controllers/RemoteUrlsIntegrationSpec.groovy
This file contains 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.github.devatherock.artifactory.controllers | ||
|
||
import io.micronaut.test.extensions.spock.annotation.MicronautTest | ||
|
||
/** | ||
* Integration test that calls remote endpoints | ||
*/ | ||
@MicronautTest(propertySources = 'classpath:application-integration.yml', startApplication = false) | ||
class RemoteUrlsIntegrationSpec extends RemoteUrlsSpec { | ||
} |
This file contains 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
65 changes: 65 additions & 0 deletions
65
src/test/groovy/io/github/devatherock/artifactory/controllers/RemoteUrlsSpec.groovy
This file contains 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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package io.github.devatherock.artifactory.controllers | ||
|
||
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo | ||
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo | ||
|
||
import javax.inject.Inject | ||
|
||
import io.github.devatherock.artifactory.service.DockerBadgeService | ||
import io.github.devatherock.test.TestUtil | ||
|
||
import com.github.tomakehurst.wiremock.WireMockServer | ||
import com.github.tomakehurst.wiremock.client.WireMock | ||
import io.micronaut.http.HttpRequest | ||
import io.micronaut.http.client.HttpClient | ||
import io.micronaut.http.client.annotation.Client | ||
import io.micronaut.http.uri.UriBuilder | ||
import spock.lang.Shared | ||
import spock.lang.Specification | ||
|
||
/** | ||
* Test that calls remote endpoints. Needed for proper netty SSL reflection config | ||
*/ | ||
abstract class RemoteUrlsSpec extends Specification { | ||
|
||
@Shared | ||
WireMockServer mockServer = new WireMockServer(8081) | ||
|
||
@Inject | ||
@Client('${test.server.url}') | ||
HttpClient httpClient | ||
|
||
void setupSpec() { | ||
WireMock.configureFor(8081) | ||
mockServer.start() | ||
} | ||
|
||
void cleanupSpec() { | ||
mockServer.stop() | ||
} | ||
|
||
void cleanup() { | ||
mockServer.resetAll() | ||
} | ||
|
||
void 'test get image size'() { | ||
given: | ||
String packageName = 'docker/devatherock/simple-slack' | ||
|
||
and: | ||
WireMock.givenThat(WireMock.get("/artifactory/${packageName}/latest/manifest.json") | ||
.willReturn(WireMock.okJson(TestUtil.getManifest()))) | ||
|
||
when: | ||
String badge = httpClient.toBlocking().retrieve( | ||
HttpRequest.GET(UriBuilder.of('/docker/image-size') | ||
.queryParam('package', packageName).build())) | ||
|
||
then: | ||
WireMock.verify(1, | ||
WireMock.getRequestedFor(urlEqualTo("/artifactory/${packageName}/latest/manifest.json")) | ||
.withHeader(DockerBadgeService.HDR_API_KEY, equalTo('dummyKey'))) | ||
badge.startsWith('<svg') | ||
badge.endsWith('</svg>') | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/test/groovy/io/github/devatherock/artifactory/controllers/RemoteUrlsTestSpec.groovy
This file contains 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.github.devatherock.artifactory.controllers | ||
|
||
import io.micronaut.test.extensions.spock.annotation.MicronautTest | ||
|
||
/** | ||
* Unit test that calls remote endpoints | ||
*/ | ||
@MicronautTest(propertySources = ['classpath:application-test.yml', 'classpath:application-remote.yml']) | ||
class RemoteUrlsTestSpec extends RemoteUrlsSpec { | ||
} |
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
artifactory: | ||
badge: | ||
shields-io: | ||
url: https://img.shields.io |