|
| 1 | +suite: test operator security context settings for values.yaml |
| 2 | +templates: |
| 3 | + - operator.yaml |
| 4 | +tests: |
| 5 | + - it: default values are properly set |
| 6 | + asserts: |
| 7 | + - exists: |
| 8 | + path: spec.template.spec.securityContext |
| 9 | + - equal: |
| 10 | + path: spec.template.spec.securityContext.runAsNonRoot |
| 11 | + value: true |
| 12 | + - equal: |
| 13 | + path: spec.template.spec.securityContext.runAsUser |
| 14 | + # noinspection YAMLIncompatibleTypes |
| 15 | + value: 2000 |
| 16 | + - notExists: |
| 17 | + path: spec.template.spec.containers[?(@.name=="mongodb-kubernetes-operator")].securityContext |
| 18 | + - it: drop podSecurityContext and securityContext completely |
| 19 | + set: |
| 20 | + operator.podSecurityContext: |
| 21 | + operator.securityContext: |
| 22 | + asserts: |
| 23 | + - notExists: |
| 24 | + path: spec.template.spec.securityContext |
| 25 | + - notExists: |
| 26 | + path: spec.template.spec.containers[?(@.name=="mongodb-kubernetes-operator")].securityContext |
| 27 | + - it: drop podSecurityContext and securityContext completely when managedSecurityContext is true |
| 28 | + set: |
| 29 | + managedSecurityContext: true |
| 30 | + asserts: |
| 31 | + - notExists: |
| 32 | + path: spec.template.spec.securityContext |
| 33 | + - notExists: |
| 34 | + path: spec.template.spec.containers[?(@.name=="mongodb-kubernetes-operator")].securityContext |
| 35 | + - it: custom values are properly set |
| 36 | + set: |
| 37 | + operator.podSecurityContext.runAsNonRoot: false |
| 38 | + operator.podSecurityContext.seccompProfile.type: RuntimeDefault |
| 39 | + operator.securityContext.allowPrivilegeEscalation: false |
| 40 | + operator.securityContext.capabilities.drop: [ALL] |
| 41 | + asserts: |
| 42 | + - exists: |
| 43 | + path: spec.template.spec.securityContext |
| 44 | + - equal: |
| 45 | + path: spec.template.spec.securityContext.runAsNonRoot |
| 46 | + value: false |
| 47 | + - equal: |
| 48 | + path: spec.template.spec.securityContext.seccompProfile.type |
| 49 | + # noinspection YAMLIncompatibleTypes |
| 50 | + value: RuntimeDefault |
| 51 | + - equal: |
| 52 | + path: spec.template.spec.securityContext.runAsUser |
| 53 | + # noinspection YAMLIncompatibleTypes |
| 54 | + value: 2000 |
| 55 | + - exists: |
| 56 | + path: spec.template.spec.containers[?(@.name=="mongodb-kubernetes-operator")].securityContext |
| 57 | + - equal: |
| 58 | + path: spec.template.spec.containers[?(@.name=="mongodb-kubernetes-operator")].securityContext.allowPrivilegeEscalation |
| 59 | + value: false |
| 60 | + - equal: |
| 61 | + path: spec.template.spec.containers[?(@.name=="mongodb-kubernetes-operator")].securityContext.capabilities.drop |
| 62 | + value: [ALL] |
| 63 | + - it: default values are properly set when managedSecurityContext is true for openShift |
| 64 | + values: |
| 65 | + - ../values-openshift.yaml |
| 66 | + asserts: |
| 67 | + - notExists: |
| 68 | + path: spec.template.spec.securityContext |
| 69 | + - notExists: |
| 70 | + path: spec.template.spec.containers[?(@.name=="mongodb-kubernetes-operator")].securityContext |
| 71 | + - exists: |
| 72 | + path: spec.template.spec.containers[?(@.name=="mongodb-kubernetes-operator")].env[?(@.name=="MANAGED_SECURITY_CONTEXT")] |
| 73 | + - equal: |
| 74 | + path: spec.template.spec.containers[?(@.name=="mongodb-kubernetes-operator")].env[?(@.name=="MANAGED_SECURITY_CONTEXT")].value |
| 75 | + # noinspection YAMLIncompatibleTypes |
| 76 | + value: "true" |
| 77 | + - it: default values are properly set for multi-cluster deployment |
| 78 | + values: |
| 79 | + - ../values-multi-cluster.yaml |
| 80 | + asserts: |
| 81 | + - exists: |
| 82 | + path: spec.template.spec.securityContext |
| 83 | + - equal: |
| 84 | + path: spec.template.spec.securityContext.runAsNonRoot |
| 85 | + value: true |
| 86 | + - equal: |
| 87 | + path: spec.template.spec.securityContext.runAsUser |
| 88 | + # noinspection YAMLIncompatibleTypes |
| 89 | + value: 2000 |
| 90 | + - notExists: |
| 91 | + path: spec.template.spec.containers[?(@.name=="mongodb-kubernetes-operator-multi-cluster")].securityContext |
| 92 | + - it: drop podSecurityContext and securityContext completely for multi-cluster deployment |
| 93 | + values: |
| 94 | + - ../values-multi-cluster.yaml |
| 95 | + set: |
| 96 | + operator.podSecurityContext: |
| 97 | + operator.securityContext: |
| 98 | + asserts: |
| 99 | + - notExists: |
| 100 | + path: spec.template.spec.securityContext |
| 101 | + - notExists: |
| 102 | + path: spec.template.spec.containers[?(@.name=="mongodb-kubernetes-operator-multi-cluster")].securityContext |
| 103 | + - it: drop podSecurityContext and securityContext completely when managedSecurityContext is true for multi-cluster deployment |
| 104 | + values: |
| 105 | + - ../values-multi-cluster.yaml |
| 106 | + set: |
| 107 | + managedSecurityContext: true |
| 108 | + asserts: |
| 109 | + - notExists: |
| 110 | + path: spec.template.spec.securityContext |
| 111 | + - notExists: |
| 112 | + path: spec.template.spec.containers[?(@.name=="mongodb-kubernetes-operator-multi-cluster")].securityContext |
| 113 | + - it: custom values are properly set for multi-cluster deployment |
| 114 | + values: |
| 115 | + - ../values-multi-cluster.yaml |
| 116 | + set: |
| 117 | + operator.podSecurityContext.runAsNonRoot: false |
| 118 | + operator.podSecurityContext.seccompProfile.type: RuntimeDefault |
| 119 | + operator.securityContext.allowPrivilegeEscalation: false |
| 120 | + operator.securityContext.capabilities.drop: [ ALL ] |
| 121 | + asserts: |
| 122 | + - exists: |
| 123 | + path: spec.template.spec.securityContext |
| 124 | + - equal: |
| 125 | + path: spec.template.spec.securityContext.runAsNonRoot |
| 126 | + value: false |
| 127 | + - equal: |
| 128 | + path: spec.template.spec.securityContext.seccompProfile.type |
| 129 | + # noinspection YAMLIncompatibleTypes |
| 130 | + value: RuntimeDefault |
| 131 | + - equal: |
| 132 | + path: spec.template.spec.securityContext.runAsUser |
| 133 | + # noinspection YAMLIncompatibleTypes |
| 134 | + value: 2000 |
| 135 | + - exists: |
| 136 | + path: spec.template.spec.containers[?(@.name=="mongodb-kubernetes-operator-multi-cluster")].securityContext |
| 137 | + - equal: |
| 138 | + path: spec.template.spec.containers[?(@.name=="mongodb-kubernetes-operator-multi-cluster")].securityContext.allowPrivilegeEscalation |
| 139 | + value: false |
| 140 | + - equal: |
| 141 | + path: spec.template.spec.containers[?(@.name=="mongodb-kubernetes-operator-multi-cluster")].securityContext.capabilities.drop |
| 142 | + value: [ ALL ] |
0 commit comments