Skip to content

Commit 3f69f2f

Browse files
Merge pull request #105 from prietyc123/podaccessiblewithoutreadonly
BUILD-478: Validate resource admission smoke test
2 parents 7ccb4ed + 8aa9a8c commit 3f69f2f

3 files changed

Lines changed: 24 additions & 6 deletions

File tree

‎smoke/features/csi-driver-e2e.feature‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Feature: SharedSecrets and SharedConfigMap
4141
| "openshift_csi_share_mount_failures_total" |
4242
| "openshift_csi_share_mount_requests_total" |
4343
Then the metrics value for configured resources should be "1"
44-
44+
4545
@automated @slowest
4646
Scenario: shared resource data gets removed if permission removed : CSI-01-TC03
4747
Given user has created resource type with shared resource
@@ -65,9 +65,19 @@ Feature: SharedSecrets and SharedConfigMap
6565
And creates a pod "my-csi-app-check" with a CSI volume citing the shared resource csi driver with read only true and requesting the previously defined "sharedsecret" in the Pod CSI volume's volume attributes
6666
And edits secret "my-secret" data from the first project
6767
Then pod "my-csi-app-check" in the second project should mount the data "hostpath" available in the "my-secret"
68-
68+
69+
@automated
70+
Scenario: Pod does not create if readonly set to false : CSI-01-TC05
71+
Given user has cluster scoped level permission to create CRD "sharedsecrets.sharedresource.openshift.io"
72+
When user creates the secret "my-secret" in a given namespace
73+
And defines shared secret "my-shared-secret" that references the "my-secret" secret from the first project to share across all namespace
74+
And creates another project that will access the cluster scoped shared secret that references the "my-secret" created in the first project
75+
And RBAC for the service account to use the "sharedsecret" in its pod
76+
And creates a pod "my-csi-app-check" with a CSI volume citing the shared resource csi driver with read only false and requesting the previously defined "sharedsecret" in the Pod CSI volume's volume attributes
77+
Then pod should not get created
78+
6979
@manual
70-
Scenario: Openshift buildconfig uses shared resource for rhel entitlement subscription : CSI-01-TC05
80+
Scenario: Openshift buildconfig uses shared resource for rhel entitlement subscription : CSI-01-TC06
7181
Given user has created openshift cluster using pull secret that has valid Red Hat subscription which helps in installing Red Hat RPMs
7282
Then log onto openshift console of the created cluster
7383
And click on "Openshift Cluster Manager" link

‎smoke/features/steps/openshift.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def search_resource_in_namespace(self, resource_plural, name_pattern, namespace)
5555
def is_resource_in(self, resource_type):
5656
output, exit_code = self.cmd.run(f'oc get {resource_type}')
5757
if exit_code != 0:
58-
print("Resource not found")
58+
print(f"Resource not found")
5959
return False
6060
return True
6161

@@ -311,5 +311,6 @@ def execute_command(self, cmd):
311311

312312
def shell_cmd(self, cmd, param):
313313
output, exit_status = self.cmd.run(f'sh {cmd} {param}')
314-
exit_status | should.be_equal_to(0)
314+
if exit_status != 0:
315+
print(f"Error occured please look into the response")
315316
return output

‎smoke/features/steps/steps.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,12 @@ def create_rbac(context, shared_resource):
119119
@when(u'creates a pod {pod_name} with a CSI volume citing the shared resource csi driver with read only {permission} and requesting the previously defined {shared_resource} in the Pod CSI volume\'s volume attributes')
120120
def create_pod(context, pod_name, shared_resource, permission):
121121
namespace = Project().current_project()
122+
expOut = "pod with ReadOnly false"
122123
print(f"creating pod {pod_name} within namespace: {namespace}")
123124
podFile = "./smoke/features/data/pod.sh"
124-
oc.shell_cmd(podFile, shared_resource + " " + permission)
125+
output = oc.shell_cmd(podFile, shared_resource + permission)
126+
if expOut in output:
127+
print(f"ERROR: server not allowed to schedule a pod with ReadOnly false SharedResourceCSIVolume, ensure to set readonly to true")
125128

126129
@when(u'edits configMap {share_config} data {value} from the first project')
127130
def edit_configmap_with_data(context, share_config, value):
@@ -211,3 +214,7 @@ def remove_data_with_permission_removal(context, pod_name):
211214
output = oc.exec_not_in_pod(pod_name, cmd, True, 60)
212215
if not output:
213216
print(f"mounted data removed successfully.")
217+
218+
@then(u'pod should not get created')
219+
def get_pod(context):
220+
oc.is_resource_in("pod")

0 commit comments

Comments
 (0)