|
| 1 | +suite: "global targetNamespaces" |
| 2 | +templates: |
| 3 | +- templates/pod-rolebindings.yaml |
| 4 | +- templates/pod-roles.yaml |
| 5 | +- templates/auto-upgrader-rolebindings.yaml |
| 6 | +- templates/auto-upgrader-roles.yaml |
| 7 | +tests: |
| 8 | +- it: "uses global targetNamespaces when local is not set" |
| 9 | + set: |
| 10 | + global: |
| 11 | + targetNamespaces: ["global-ns-1", "global-ns-2"] |
| 12 | + scriptPods: |
| 13 | + serviceAccount: |
| 14 | + targetNamespaces: [] |
| 15 | + agent.deploymentTarget.enabled: true |
| 16 | + persistence.nfs.watchdog.enabled: false |
| 17 | + template: templates/pod-rolebindings.yaml |
| 18 | + asserts: |
| 19 | + - hasDocuments: |
| 20 | + count: 2 |
| 21 | + - equal: |
| 22 | + path: metadata.namespace |
| 23 | + value: global-ns-1 |
| 24 | + documentIndex: 0 |
| 25 | + - equal: |
| 26 | + path: metadata.namespace |
| 27 | + value: global-ns-2 |
| 28 | + documentIndex: 1 |
| 29 | + |
| 30 | +- it: "local targetNamespaces override global" |
| 31 | + set: |
| 32 | + global: |
| 33 | + targetNamespaces: ["global-ns-1", "global-ns-2"] |
| 34 | + scriptPods: |
| 35 | + serviceAccount: |
| 36 | + targetNamespaces: ["local-ns-1", "local-ns-2", "local-ns-3"] |
| 37 | + agent.deploymentTarget.enabled: true |
| 38 | + persistence.nfs.watchdog.enabled: false |
| 39 | + template: templates/pod-rolebindings.yaml |
| 40 | + asserts: |
| 41 | + - hasDocuments: |
| 42 | + count: 3 |
| 43 | + - equal: |
| 44 | + path: metadata.namespace |
| 45 | + value: local-ns-1 |
| 46 | + documentIndex: 0 |
| 47 | + - equal: |
| 48 | + path: metadata.namespace |
| 49 | + value: local-ns-2 |
| 50 | + documentIndex: 1 |
| 51 | + - equal: |
| 52 | + path: metadata.namespace |
| 53 | + value: local-ns-3 |
| 54 | + documentIndex: 2 |
| 55 | + |
| 56 | +- it: "creates no rolebindings when both global and local are empty" |
| 57 | + set: |
| 58 | + global: |
| 59 | + targetNamespaces: [] |
| 60 | + scriptPods: |
| 61 | + serviceAccount: |
| 62 | + targetNamespaces: [] |
| 63 | + agent.deploymentTarget.enabled: true |
| 64 | + template: templates/pod-rolebindings.yaml |
| 65 | + asserts: |
| 66 | + - hasDocuments: |
| 67 | + count: 1 |
| 68 | + |
| 69 | +- it: "global targetNamespaces work with namespace-scoped roles" |
| 70 | + set: |
| 71 | + global: |
| 72 | + targetNamespaces: ["global-ns-1", "global-ns-2"] |
| 73 | + scriptPods: |
| 74 | + serviceAccount: |
| 75 | + targetNamespaces: [] |
| 76 | + useNamespacedRoles: true |
| 77 | + template: templates/pod-roles.yaml |
| 78 | + asserts: |
| 79 | + - hasDocuments: |
| 80 | + count: 2 |
| 81 | + - equal: |
| 82 | + path: kind |
| 83 | + value: Role |
| 84 | + documentIndex: 0 |
| 85 | + - equal: |
| 86 | + path: metadata.namespace |
| 87 | + value: global-ns-1 |
| 88 | + documentIndex: 0 |
| 89 | + - equal: |
| 90 | + path: metadata.namespace |
| 91 | + value: global-ns-2 |
| 92 | + documentIndex: 1 |
| 93 | + |
| 94 | +- it: "global targetNamespaces work with auto-upgrader rolebindings" |
| 95 | + set: |
| 96 | + global: |
| 97 | + targetNamespaces: ["global-ns-1", "global-ns-2"] |
| 98 | + scriptPods: |
| 99 | + serviceAccount: |
| 100 | + targetNamespaces: [] |
| 101 | + useNamespacedRoles: true |
| 102 | + template: templates/auto-upgrader-rolebindings.yaml |
| 103 | + asserts: |
| 104 | + - hasDocuments: |
| 105 | + count: 3 |
| 106 | + - equal: |
| 107 | + path: kind |
| 108 | + value: RoleBinding |
| 109 | + documentIndex: 0 |
| 110 | + - matchRegex: |
| 111 | + path: metadata.name |
| 112 | + pattern: self-binding$ |
| 113 | + documentIndex: 0 |
| 114 | + - equal: |
| 115 | + path: metadata.namespace |
| 116 | + value: global-ns-1 |
| 117 | + documentIndex: 1 |
| 118 | + - equal: |
| 119 | + path: metadata.namespace |
| 120 | + value: global-ns-2 |
| 121 | + documentIndex: 2 |
| 122 | + |
| 123 | +- it: "global targetNamespaces work with auto-upgrader roles" |
| 124 | + set: |
| 125 | + global: |
| 126 | + targetNamespaces: ["global-ns-1", "global-ns-2"] |
| 127 | + scriptPods: |
| 128 | + serviceAccount: |
| 129 | + targetNamespaces: [] |
| 130 | + useNamespacedRoles: true |
| 131 | + template: templates/auto-upgrader-roles.yaml |
| 132 | + asserts: |
| 133 | + - hasDocuments: |
| 134 | + count: 3 |
| 135 | + - equal: |
| 136 | + path: kind |
| 137 | + value: Role |
| 138 | + documentIndex: 0 |
| 139 | + - matchRegex: |
| 140 | + path: metadata.name |
| 141 | + pattern: self-role$ |
| 142 | + documentIndex: 0 |
| 143 | + - equal: |
| 144 | + path: metadata.namespace |
| 145 | + value: global-ns-1 |
| 146 | + documentIndex: 1 |
| 147 | + - equal: |
| 148 | + path: metadata.namespace |
| 149 | + value: global-ns-2 |
| 150 | + documentIndex: 2 |
| 151 | + |
| 152 | +- it: "matches snapshot with global targetNamespaces" |
| 153 | + set: |
| 154 | + global: |
| 155 | + targetNamespaces: ["global-ns-1"] |
| 156 | + scriptPods: |
| 157 | + serviceAccount: |
| 158 | + targetNamespaces: [] |
| 159 | + agent.deploymentTarget.enabled: true |
| 160 | + template: templates/pod-rolebindings.yaml |
| 161 | + asserts: |
| 162 | + - matchSnapshot: {} |
0 commit comments