|
1 | 1 | package de.gesellix.docker.client.distribution
|
2 | 2 |
|
3 |
| -class ReferenceParserTest { |
| 3 | +import spock.lang.Specification |
| 4 | + |
| 5 | +class ReferenceParserTest extends Specification { |
| 6 | + |
| 7 | + ReferenceParser parser |
| 8 | + |
| 9 | + def setup() { |
| 10 | + parser = new ReferenceParser() |
| 11 | + } |
| 12 | + |
| 13 | + def "parse reference"() { |
| 14 | + when: |
| 15 | + def reference = parser.parse(s) |
| 16 | + then: |
| 17 | + reference == r |
| 18 | + where: |
| 19 | + s || r |
| 20 | + "docker.io/library/alpine:edge" || [repo: [domain: "docker.io", path: "library/alpine"], tag: "edge"] |
| 21 | + "test_com" || [domain: "", path: "test_com"] |
| 22 | + "test.com:tag" || [repo: [domain: "", path: "test.com"], tag: "tag"] |
| 23 | + "test.com:5000" || [repo: [domain: "", path: "test.com"], tag: "5000"] |
| 24 | + "test.com/repo:tag" || [repo: [domain: "test.com", path: "repo"], tag: "tag"] |
| 25 | + "test:5000/repo" || [domain: "test:5000", path: "repo"] |
| 26 | + "test:5000/repo:tag" || [repo: [domain: "test:5000", path: "repo"], tag: "tag"] |
| 27 | + "lowercase:Uppercase" || [repo: [domain: "", path: "lowercase"], tag: "Uppercase"] |
| 28 | + "foo_bar.com:8080" || [repo: [domain: "", path: "foo_bar.com"], tag: "8080"] |
| 29 | + "foo/foo_bar.com:8080" || [repo: [domain: "foo", path: "foo_bar.com"], tag: "8080"] |
| 30 | + "sub-dom1.foo.com/bar/baz/quux" || [domain: "sub-dom1.foo.com", path: "bar/baz/quux"] |
| 31 | + "sub-dom1.foo.com/bar/baz/quux:some-long-tag" || [repo: [domain: "sub-dom1.foo.com", path: "bar/baz/quux"], tag: "some-long-tag"] |
| 32 | + "b.gcr.io/test.example.com/my-app:test.example.com" || [repo: [domain: "b.gcr.io", path: "test.example.com/my-app"], tag: "test.example.com"] |
| 33 | + // ☃.com in punycode |
| 34 | + "xn--n3h.com/myimage:xn--n3h.com" || [repo: [domain: "xn--n3h.com", path: "myimage"], tag: "xn--n3h.com"] |
| 35 | + // 🐳.com in punycode |
| 36 | + "xn--7o8h.com/myimage:xn--7o8h.com@sha512:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" || [repo: [domain: "xn--7o8h.com", path: "myimage"], tag: "xn--7o8h.com", digest: "sha512:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"] |
| 37 | + "test:5000/repo@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" || [repo: [domain: "test:5000", path: "repo"], digest: "sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"] |
| 38 | + "test:5000/repo:tag@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" || [repo: [domain: "test:5000", path: "repo"], tag: "tag", digest: "sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"] |
| 39 | + } |
4 | 40 | }
|
0 commit comments