|
| 1 | +suite: registrymirror |
| 2 | +templates: |
| 3 | + - ../templates/registrymirror.yaml |
| 4 | +values: |
| 5 | + - ../values.yaml |
| 6 | +release: |
| 7 | + name: test-release |
| 8 | + namespace: test-ns |
| 9 | + |
| 10 | +tests: |
| 11 | + - it: "does not have mirrors, if they are not provided" |
| 12 | + set: |
| 13 | + imageSbomExtractor.mirrors: {} |
| 14 | + asserts: |
| 15 | + - hasDocuments: |
| 16 | + count: 0 |
| 17 | + |
| 18 | + - it: "has mirrors ConfigMap, when mirrors are set" |
| 19 | + set: |
| 20 | + imageSbomExtractor.mirrors: |
| 21 | + registryMirrors: |
| 22 | + - "insecure.mirror.acme.com" |
| 23 | + - "secure.mirror.acme.com" |
| 24 | + insecureRegistries: |
| 25 | + - "insecure.mirror.acme.com" |
| 26 | + asserts: |
| 27 | + - hasDocuments: |
| 28 | + count: 1 |
| 29 | + - containsDocument: |
| 30 | + kind: ConfigMap |
| 31 | + apiVersion: v1 |
| 32 | + name: test-release-cluster-scanner-registry-mirrors |
| 33 | + namespace: test-ns |
| 34 | + - equal: |
| 35 | + path: data["daemon.json"] |
| 36 | + value: |- |
| 37 | + { |
| 38 | + "registry-mirrors": ["insecure.mirror.acme.com","secure.mirror.acme.com"], |
| 39 | + "insecure-registries": ["insecure.mirror.acme.com"] |
| 40 | + } |
| 41 | +
|
| 42 | + - it: "has correct empty registry mirrors" |
| 43 | + set: |
| 44 | + imageSbomExtractor.mirrors: |
| 45 | + insecureRegistries: |
| 46 | + - "insecure.mirror.acme.com" |
| 47 | + asserts: |
| 48 | + - hasDocuments: |
| 49 | + count: 1 |
| 50 | + - containsDocument: |
| 51 | + kind: ConfigMap |
| 52 | + apiVersion: v1 |
| 53 | + name: test-release-cluster-scanner-registry-mirrors |
| 54 | + namespace: test-ns |
| 55 | + - equal: |
| 56 | + path: data["daemon.json"] |
| 57 | + value: |- |
| 58 | + { |
| 59 | + "registry-mirrors": [], |
| 60 | + "insecure-registries": ["insecure.mirror.acme.com"] |
| 61 | + } |
| 62 | +
|
| 63 | + - it: "has correct empty insecure registries mirrors" |
| 64 | + set: |
| 65 | + imageSbomExtractor.mirrors: |
| 66 | + registryMirrors: |
| 67 | + - "insecure.mirror.acme.com" |
| 68 | + - "secure.mirror.acme.com" |
| 69 | + - "one more mirror" |
| 70 | + asserts: |
| 71 | + - hasDocuments: |
| 72 | + count: 1 |
| 73 | + - containsDocument: |
| 74 | + kind: ConfigMap |
| 75 | + apiVersion: v1 |
| 76 | + name: test-release-cluster-scanner-registry-mirrors |
| 77 | + namespace: test-ns |
| 78 | + - equal: |
| 79 | + path: data["daemon.json"] |
| 80 | + value: |- |
| 81 | + { |
| 82 | + "registry-mirrors": ["insecure.mirror.acme.com","secure.mirror.acme.com","one more mirror"], |
| 83 | + "insecure-registries": [] |
| 84 | + } |
| 85 | +
|
| 86 | + - it: "fails if format of registry mirrors is wrong" |
| 87 | + set: |
| 88 | + imageSbomExtractor.mirrors: |
| 89 | + registryMirrors: |
| 90 | + nested: "object" |
| 91 | + asserts: |
| 92 | + - failedTemplate: |
| 93 | + errorMessage: "values don't meet the specifications of the schema(s) in the following chart(s):\ncluster-scanner:\n- imageSbomExtractor.mirrors.registryMirrors: Invalid type. Expected: array, given: object\n" |
| 94 | + |
| 95 | + - it: "fails if format of insecure registries is wrong" |
| 96 | + set: |
| 97 | + imageSbomExtractor.mirrors: |
| 98 | + insecureRegistries: 18 |
| 99 | + asserts: |
| 100 | + - failedTemplate: |
| 101 | + errorMessage: "values don't meet the specifications of the schema(s) in the following chart(s):\ncluster-scanner:\n- imageSbomExtractor.mirrors.insecureRegistries: Invalid type. Expected: array, given: integer\n" |
| 102 | + |
| 103 | + - it: "fails if format of mirrors is wrong" |
| 104 | + set: |
| 105 | + imageSbomExtractor.mirrors: 18 |
| 106 | + asserts: |
| 107 | + - failedTemplate: |
| 108 | + errorMessage: "values don't meet the specifications of the schema(s) in the following chart(s):\ncluster-scanner:\n- imageSbomExtractor.mirrors: Invalid type. Expected: object, given: integer\n" |
| 109 | + |
| 110 | + - it: "fails if mirrors contains unexpeceted property" |
| 111 | + set: |
| 112 | + imageSbomExtractor.mirrors: |
| 113 | + gigi: |
| 114 | + - "insecure.mirror.acme.com" |
| 115 | + - "secure.mirror.acme.com" |
| 116 | + insecureRegistries: |
| 117 | + - "insecure.mirror.acme.com" |
| 118 | + asserts: |
| 119 | + - failedTemplate: |
| 120 | + errorMessage: "values don't meet the specifications of the schema(s) in the following chart(s):\ncluster-scanner:\n- imageSbomExtractor.mirrors: Additional property gigi is not allowed\n" |
0 commit comments