Skip to content
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

fixed failing test #539

Merged
merged 3 commits into from
Jul 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 43 additions & 16 deletions src/test/groovy/io/seqera/wave/core/ContainerAugmenterTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ package io.seqera.wave.core
import spock.lang.Shared
import spock.lang.Specification

import java.net.http.HttpHeaders
import java.net.http.HttpResponse
import java.nio.file.Files

import groovy.json.JsonSlurper
Expand Down Expand Up @@ -817,32 +819,57 @@ class ContainerAugmenterTest extends Specification {

def 'should fetch container manifest for legacy image' () {
given:
def REGISTRY = 'quay.io'
def IMAGE = 'biocontainers/kmerinshort'
def TAG = '1.0.1--0'
def registry = lookupService.lookup(REGISTRY)
def creds = credentialsProvider.getDefaultCredentials(REGISTRY)
def httpClient = HttpClientFactory.neverRedirectsHttpClient()
def REGISTRY = 'mockreg.io'
def IMAGE = 'repo/image'
def TAG = '1.0.0'
and:

def client = new ProxyClient(httpClient, httpConfig)
.withRoute(Mock(RoutePath))
.withImage(IMAGE)
.withRegistry(registry)
.withCredentials(creds)
.withLoginService(loginService)
def client = Mock(ProxyClient)

and:
def headers = ['content-type': List.of('application/vnd.docker.distribution.manifest.v1+prettyjws'),
'docker-content-digest': List.of('sha256:samplesha')]
def response1 = Mock(HttpResponse)
response1.headers() >> HttpHeaders.of(headers, (a, b)->true)
and:
String manifest = """
{
"schemaVersion": 1,
"name": "mockImage",
"tag": "latest",
"architecture": "amd64",
"fsLayers": [
{"blobSum": "sha256:mockBlobSum1"},
{"blobSum": "sha256:mockBlobSum2"}
],
"history": [
{
"v1Compatibility": "{\\"id\\":\\"mockId1\\",\\"architecture\\": \\"amd64\\",\\"config\\": {\\"Cmd\\": [\\"/bin/sh\\"],\\"Env\\": [\\"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\\"],\\"Entrypoint\\": null,\\"WorkingDir\\": \\"\\"},\\"created\\": \\"2021-09-23T23:47:57.442225064Z\\",\\"docker_version\\": \\"20.10.7\\",\\"os\\": \\"linux\\",\\"parent\\": \\"mockParent1\\"}"
}
]
}
"""
def response2 = Mock(HttpResponse)
response2.headers() >> HttpHeaders.of(Map.of('content-type', List.of('application/vnd.docker.distribution.manifest.v1+prettyjws')), (a, b)->true)
response2.body() >> manifest
and:
def scanner = new ContainerAugmenter()
.withClient(client)
.withPlatform('amd64')

when:
def spec = scanner.getContainerSpec(IMAGE, TAG, WaveDefault.ACCEPT_HEADERS)

then:
client.head("/v2/$IMAGE/manifests/$TAG", _) >> response1
client.getString(_, _ ) >> response2
client.route >> new RoutePath('docker', REGISTRY, IMAGE)
client.getRegistry() >> new RegistryInfo(REGISTRY, new URI(REGISTRY), Mock(RegistryAuth))
then:
spec.registry == 'quay.io'
spec.imageName == 'biocontainers/kmerinshort'
spec.reference == '1.0.1--0'
spec.digest == 'sha256:056e3de6174c48a7b342c8f91541896c39d2e30a64e62d62e51ae43227c36278'
spec.registry == 'mockreg.io'
spec.imageName == 'repo/image'
spec.reference == '1.0.0'
spec.digest == 'sha256:samplesha'
and:
spec.isV1()
!spec.isV2()
Expand Down
Loading