|
| 1 | +suite: Security Context |
| 2 | +templates: |
| 3 | + - deployment.yaml |
| 4 | +tests: |
| 5 | + - it: should not have podSecurityContext by default |
| 6 | + asserts: |
| 7 | + - notExists: |
| 8 | + path: spec.template.spec.securityContext |
| 9 | + |
| 10 | + - it: should set podSecurityContext when configured |
| 11 | + set: |
| 12 | + podSecurityContext: |
| 13 | + runAsNonRoot: true |
| 14 | + runAsUser: 1000 |
| 15 | + asserts: |
| 16 | + - equal: |
| 17 | + path: spec.template.spec.securityContext.runAsNonRoot |
| 18 | + value: true |
| 19 | + - equal: |
| 20 | + path: spec.template.spec.securityContext.runAsUser |
| 21 | + value: 1000 |
| 22 | + |
| 23 | + - it: should not have containerSecurityContext by default |
| 24 | + asserts: |
| 25 | + - notExists: |
| 26 | + path: spec.template.spec.containers[0].securityContext |
| 27 | + |
| 28 | + - it: should set containerSecurityContext when configured |
| 29 | + set: |
| 30 | + containerSecurityContext: |
| 31 | + allowPrivilegeEscalation: false |
| 32 | + runAsNonRoot: true |
| 33 | + asserts: |
| 34 | + - equal: |
| 35 | + path: spec.template.spec.containers[0].securityContext.allowPrivilegeEscalation |
| 36 | + value: false |
| 37 | + - equal: |
| 38 | + path: spec.template.spec.containers[0].securityContext.runAsNonRoot |
| 39 | + value: true |
| 40 | + |
| 41 | + - it: should support capabilities drop in containerSecurityContext |
| 42 | + set: |
| 43 | + containerSecurityContext: |
| 44 | + capabilities: |
| 45 | + drop: |
| 46 | + - ALL |
| 47 | + asserts: |
| 48 | + - equal: |
| 49 | + path: spec.template.spec.containers[0].securityContext.capabilities.drop[0] |
| 50 | + value: ALL |
| 51 | +--- |
| 52 | +suite: Security Context - Workers |
| 53 | +templates: |
| 54 | + - worker.yaml |
| 55 | +tests: |
| 56 | + - it: should not have podSecurityContext in workers by default |
| 57 | + set: |
| 58 | + consumers: |
| 59 | + - name: "queue" |
| 60 | + command: "php bin/console messenger:consume" |
| 61 | + asserts: |
| 62 | + - notExists: |
| 63 | + path: spec.template.spec.securityContext |
| 64 | + |
| 65 | + - it: should set podSecurityContext in workers when configured |
| 66 | + set: |
| 67 | + consumers: |
| 68 | + - name: "queue" |
| 69 | + command: "php bin/console messenger:consume" |
| 70 | + podSecurityContext: |
| 71 | + runAsNonRoot: true |
| 72 | + asserts: |
| 73 | + - equal: |
| 74 | + path: spec.template.spec.securityContext.runAsNonRoot |
| 75 | + value: true |
| 76 | + |
| 77 | + - it: should set containerSecurityContext in workers when configured |
| 78 | + set: |
| 79 | + consumers: |
| 80 | + - name: "queue" |
| 81 | + command: "php bin/console messenger:consume" |
| 82 | + containerSecurityContext: |
| 83 | + allowPrivilegeEscalation: false |
| 84 | + asserts: |
| 85 | + - equal: |
| 86 | + path: spec.template.spec.containers[0].securityContext.allowPrivilegeEscalation |
| 87 | + value: false |
0 commit comments