Skip to content

Commit 1eee4a3

Browse files
committed
run antivirus tests on kubernetes
1 parent 9d8a2a9 commit 1eee4a3

File tree

15 files changed

+174
-37
lines changed

15 files changed

+174
-37
lines changed

.drone.star

Lines changed: 52 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,14 @@ config = {
127127
"suites": [
128128
"apiGraphUser",
129129
],
130-
"skip": False,
131130
"withRemotePhp": [True],
132131
},
133132
"spaces": {
134133
"suites": [
135134
"apiSpaces",
136135
],
137-
"skip": False,
136+
"skip": True,
137+
"k8s": False,
138138
},
139139
"spacesShares": {
140140
"suites": [
@@ -186,8 +186,8 @@ config = {
186186
"suites": [
187187
"apiSharingNgAdditionalShareRole",
188188
],
189-
"skip": False,
190-
"k8s": True,
189+
"skip": True,
190+
"k8s": False,
191191
"withRemotePhp": [True],
192192
},
193193
"sharingNgShareInvitation": {
@@ -302,8 +302,8 @@ config = {
302302
"coreApiShareManagementBasicToShares",
303303
"coreApiShareManagementToShares",
304304
],
305-
"skip": False,
306-
"k8s": True,
305+
"skip": True,
306+
"k8s": False,
307307
"withRemotePhp": [True],
308308
},
309309
"3": {
@@ -323,8 +323,7 @@ config = {
323323
"coreApiShareCreateSpecialToShares2",
324324
"coreApiShareUpdateToShares",
325325
],
326-
"skip": False,
327-
"k8s": True,
326+
"skip": True,
328327
"withRemotePhp": [True],
329328
},
330329
"5": {
@@ -343,7 +342,7 @@ config = {
343342
"coreApiWebdavOperations",
344343
"coreApiWebdavMove2",
345344
],
346-
"skip": False,
345+
"skip": True,
347346
},
348347
"7": {
349348
"suites": [
@@ -1104,19 +1103,19 @@ def localApiTestPipeline(ctx):
11041103
restoreBuildArtifactCache(ctx, "ocis-binary-amd64", "ocis/bin") +
11051104
(tikaService() if params["tikaNeeded"] else []) +
11061105
(waitForServices("online-offices", ["collabora:9980", "onlyoffice:443", "fakeoffice:8080"]) if params["collaborationServiceNeeded"] else []) +
1107-
(waitK3sCluster() + deployOcis() + waitForOcis(ocis_url = ocis_url) + ociswrapper() + waitForOciswrapper() if run_on_k8s else ocisServer(storage, extra_server_environment = params["extraServerEnvironment"], with_wrapper = True, tika_enabled = params["tikaNeeded"], volumes = ([stepVolumeOcisStorage]))) +
1108-
(waitForClamavService() if params["antivirusNeeded"] else []) +
1109-
(waitForEmailService() if params["emailNeeded"] else []) +
1106+
(waitK3sCluster() + (clamavServiceK8s() if params["antivirusNeeded"] and run_on_k8s else []) + (emailServiceK8s() if params["emailNeeded"] and run_on_k8s else []) + deployOcis() + waitForOcis(ocis_url = ocis_url) + ociswrapper() + waitForOciswrapper() if run_on_k8s else ocisServer(storage, extra_server_environment = params["extraServerEnvironment"], with_wrapper = True, tika_enabled = params["tikaNeeded"], volumes = ([stepVolumeOcisStorage]))) +
1107+
(waitForClamavService() if params["antivirusNeeded"] and not run_on_k8s else []) +
1108+
(waitForEmailService() if params["emailNeeded"] and not run_on_k8s else exposeEmailServiceK8s() if params["emailNeeded"] and run_on_k8s else []) +
11101109
(ocisServer(storage, deploy_type = "federation", extra_server_environment = params["extraServerEnvironment"]) if params["federationServer"] else []) +
11111110
((wopiCollaborationService("fakeoffice") + wopiCollaborationService("collabora") + wopiCollaborationService("onlyoffice")) if params["collaborationServiceNeeded"] else []) +
11121111
(ocisHealthCheck("wopi", ["wopi-collabora:9304", "wopi-onlyoffice:9304", "wopi-fakeoffice:9304"]) if params["collaborationServiceNeeded"] else []) +
11131112
localApiTests(name, params["suites"], storage, params["extraEnvironment"], run_with_remote_php, ocis_url = ocis_url, k8s = run_on_k8s) +
11141113
apiTestFailureLog() +
11151114
(generateCoverageFromAPITest(ctx, name) if not run_on_k8s else []),
1116-
"services": (emailService() if params["emailNeeded"] else []) +
1117-
(clamavService() if params["antivirusNeeded"] else []) +
1118-
((fakeOffice() + collaboraService() + onlyofficeService()) if params["collaborationServiceNeeded"] else []) +
1119-
(k3sCluster() if run_on_k8s else []),
1115+
"services": (k3sCluster() if run_on_k8s else []) +
1116+
(emailService() if params["emailNeeded"] and not run_on_k8s else []) +
1117+
(clamavService() if params["antivirusNeeded"] and not run_on_k8s else []) +
1118+
((fakeOffice() + collaboraService() + onlyofficeService()) if params["collaborationServiceNeeded"] else []),
11201119
"depends_on": getPipelineNames(buildOcisBinaryForTesting(ctx)),
11211120
"trigger": {
11221121
"ref": [
@@ -3814,15 +3813,13 @@ def deployOcis():
38143813
"image": "owncloudci/golang:latest",
38153814
"commands": [
38163815
"make -C %s build" % dirs["ocisWrapper"],
3817-
"mv %s/tests/config/drone/k3s/values.yaml %s/ocis-charts/charts/ocis/ci/deployment-values.yaml" % (dirs["base"], dirs["base"]),
3818-
"cp -r %s/tests/config/drone/k3s/authbasic %s/ocis-charts/charts/ocis/templates/" % (dirs["base"], dirs["base"]),
3816+
"mv %s/tests/config/drone/k8s/values.yaml %s/ocis-charts/charts/ocis/ci/deployment-values.yaml" % (dirs["base"], dirs["base"]),
3817+
"cp -r %s/tests/config/drone/k8s/authbasic %s/ocis-charts/charts/ocis/templates/" % (dirs["base"], dirs["base"]),
38193818
"cd %s/ocis-charts" % dirs["base"],
38203819
"sed -i '/{{- define \"ocis.basicServiceTemplates\" -}}/a\\\\ {{- $_ := set .scope \"appNameAuthBasic\" \"authbasic\" -}}' ./charts/ocis/templates/_common/_tplvalues.tpl",
38213820
"sed -i '/- name: IDM_ADMIN_PASSWORD/{n;N;N;N;d;}' ./charts/ocis/templates/idm/deployment.yaml",
38223821
"sed -i '/- name: IDM_ADMIN_PASSWORD/a\\\\\\n value: \"admin\"' ./charts/ocis/templates/idm/deployment.yaml",
38233822
"sed -i '/- name: PROXY_HTTP_ADDR/i\\\\ - name: PROXY_ENABLE_BASIC_AUTH\\\n value: \"true\"' ./charts/ocis/templates/proxy/deployment.yaml",
3824-
"sed -i '/- name: FRONTEND_PASSWORD_POLICY_BANNED_PASSWORDS_LIST/{N;d;}' %s/ocis-charts/charts/ocis/templates/frontend/deployment.yaml" % dirs["base"],
3825-
"sed -i '/name: SHARING_PASSWORD_POLICY_BANNED_PASSWORDS_LIST/,+1d' %s/ocis-charts/charts/ocis/templates/sharing/deployment.yaml" % dirs["base"],
38263823
"export KUBECONFIG=%s/kubeconfig-$${DRONE_BUILD_NUMBER}.yaml" % dirs["base"],
38273824
"make helm-install-atomic",
38283825
],
@@ -3834,6 +3831,39 @@ def deployOcis():
38343831
],
38353832
}]
38363833

3834+
def clamavServiceK8s():
3835+
return [{
3836+
"name": "clamav",
3837+
"image": OC_CI_ALPINE,
3838+
"commands": [
3839+
"cp -r %s/tests/config/drone/k8s/clamav %s/ocis-charts/charts/ocis/templates/" % (dirs["base"], dirs["base"]),
3840+
"sed -i 's/{{ *\\\\.Values\\\\.features\\\\.virusscan\\\\.infectedFileHandling *| *quote *}}/\"delete\"/' %s/ocis-charts/charts/ocis/templates/antivirus/deployment.yaml" % dirs["base"],
3841+
"sed -i 's/{{ *\\\\.Values\\\\.features\\\\.virusscan\\\\.infectedFileHandling *| *quote *}}/\"delete\"/' %s/ocis-charts/charts/ocis/templates/antivirus/deployment.yaml" % dirs["base"],
3842+
"sed -i '/name: ANTIVIRUS_SCANNER_TYPE/{n;s/value: *\"icap\"/value: \"clamav\"/}' %s/ocis-charts/charts/ocis/templates/antivirus/deployment.yaml" % dirs["base"],
3843+
"sed -i '/- name: ANTIVIRUS_SCANNER_TYPE/i\\\\ - name: ANTIVIRUS_CLAMAV_SOCKET\\\n value: \"tcp://clamav:3310\"' %s/ocis-charts/charts/ocis/templates/antivirus/deployment.yaml" % dirs["base"],
3844+
],
3845+
}]
3846+
3847+
def emailServiceK8s():
3848+
return [{
3849+
"name": "copy-%s-service" % EMAIL_SMTP_HOST,
3850+
"image": OC_CI_ALPINE,
3851+
"commands": [
3852+
"cp -r %s/tests/config/drone/k8s/mailpit %s/ocis-charts/charts/ocis/templates/" % (dirs["base"], dirs["base"]),
3853+
],
3854+
}]
3855+
3856+
def exposeEmailServiceK8s():
3857+
return [{
3858+
"name": EMAIL_SMTP_HOST,
3859+
"image": "ghcr.io/k3d-io/k3d:5-dind",
3860+
"commands": [
3861+
"kubectl port-forward svc/mailpit %s:%s -n ocis" % (EMAIL_PORT, EMAIL_PORT),
3862+
"kubectl port-forward svc/mailpit 9174:9174 -n ocis",
3863+
],
3864+
"detach": True,
3865+
}]
3866+
38373867
def ociswrapper():
38383868
return [{
38393869
"name": "ociswrapper",
@@ -3844,6 +3874,8 @@ def ociswrapper():
38443874
"until test -f $${KUBECONFIG}; do sleep 1s; done",
38453875
"kubectl get pods -A",
38463876
"kubectl get ingress -A",
3877+
"kubectl describe pods $(kubectl get pods -n ocis -l app=antivirus -o jsonpath=\"{.items[0].metadata.name}\") -n ocis",
3878+
"kubectl describe pods $(kubectl get pods -n ocis -l app=postprocessing -o jsonpath=\"{.items[0].metadata.name}\") -n ocis",
38473879
"%s/bin/ociswrapper serve --url https://ocis-server --admin-username admin --admin-password admin --skip-ocis-run" % dirs["ocisWrapper"],
38483880
],
38493881
"detach": True,

tests/acceptance/bootstrap/OcisConfigContext.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ public function theAdministratorHasStartedServiceSeparatelyWithTheFollowingConfi
318318
*/
319319
public function rollback(): void {
320320
if (\getenv('K8S') === "true") {
321+
$this->rollbackK8sServices();
321322
return;
322323
}
323324
$this->rollbackServices();
@@ -349,4 +350,18 @@ public function rollbackServices(): void {
349350
"Failed to rollback services.",
350351
);
351352
}
353+
354+
/**
355+
* @return void
356+
* @throws GuzzleException
357+
*/
358+
public function rollbackK8sServices(): void {
359+
$url = OcisConfigHelper::getWrapperUrl() . "/k8s/rollback";
360+
$response = OcisConfigHelper::sendRequest($url, "DELETE");
361+
Assert::assertEquals(
362+
200,
363+
$response->getStatusCode(),
364+
"Failed to rollback services.",
365+
);
366+
}
352367
}

tests/acceptance/features/apiAuthApp/token.feature

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Feature: create auth-app token
113113

114114
@env-config
115115
Scenario: admin creates auth-app token for other user
116-
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "auth-app" service
116+
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "authapp" service
117117
When user "Admin" creates auth-app token for user "Alice" with expiration time "72h" using the auth-app API
118118
Then the HTTP status code should be "200"
119119
And the JSON data of the response should match
@@ -139,7 +139,7 @@ Feature: create auth-app token
139139

140140
@env-config
141141
Scenario: user deletes the created auth-app token
142-
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "auth-app" service
142+
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "authapp" service
143143
And user "Alice" has created auth-app token with expiration time "72h" using the auth-app API
144144
And user "Admin" has created auth-app token for user "Alice" with expiration time "72h" using the auth-app API
145145
When user "Alice" deletes all the created auth-app tokens using the auth-app API
@@ -176,7 +176,7 @@ Feature: create auth-app token
176176

177177
@env-config
178178
Scenario: admin tries to create auth-app token for other users without expiry
179-
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "auth-app" service
179+
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "authapp" service
180180
When user "Admin" tries to create auth-app token for user "Alice" with expiration time "" using the auth-app API
181181
Then the HTTP status code should be "400"
182182
And the content in the response should include the following content:
@@ -187,19 +187,19 @@ Feature: create auth-app token
187187
@env-config
188188
Scenario: non-admin user tries to create an auth-app token for another user
189189
Given user "Brian" has been created with default attributes
190-
And the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "auth-app" service
190+
And the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "authapp" service
191191
When user "Alice" tries to create auth-app token for user "Brian" with expiration time "72h" using the auth-app API
192192
Then the HTTP status code should be "403"
193193

194194
@env-config @issue-10815
195195
Scenario: admin tries to create auth-app token for non-existing user
196-
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "auth-app" service
196+
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "authapp" service
197197
When user "Admin" creates auth-app token for user "Brian" with expiration time "72h" using the auth-app API
198198
Then the HTTP status code should be "403"
199199

200200
@env-config @issue-10815
201201
Scenario: admin user tries to delete auth-app token of another user with impersonation enabled
202-
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "auth-app" service
202+
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "authapp" service
203203
And user "Admin" has created auth-app token for user "Alice" with expiration time "72h" using the auth-app API
204204
When user "Admin" tries to delete the last created auth-app token using the auth-app API
205205
Then the HTTP status code should be "403"

tests/acceptance/features/apiAuthApp/tokenUsage.feature

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Feature: create auth-app token
112112

113113
@env-config
114114
Scenario: admin tries to access resource of another user using impersonation token
115-
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "auth-app" service
115+
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "authapp" service
116116
And user "Admin" has created auth-app token for user "Alice" with expiration time "72h" using the auth-app API
117117
And user "Alice" has uploaded file with content "ownCloud test text file" to "textfile.txt"
118118
When user "Admin" requests these endpoints with "PROPFIND" using the auth-app token of user "Alice"
@@ -124,7 +124,7 @@ Feature: create auth-app token
124124

125125
@env-config
126126
Scenario: non-admin user tries to access resource of another user using impersonation token
127-
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "auth-app" service
127+
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "authapp" service
128128
And user "Admin" has created auth-app token for user "Alice" with expiration time "72h" using the auth-app API
129129
And user "Alice" has uploaded file with content "ownCloud test text file" to "textfile.txt"
130130
And user "Brian" has been created with default attributes
@@ -144,15 +144,15 @@ Feature: create auth-app token
144144

145145
@env-config
146146
Scenario: user tries to use expired impersonation token created via impersonation token
147-
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "auth-app" service
147+
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "authapp" service
148148
And user "Admin" has created auth-app token for user "Alice" with expiration time "1s" using the auth-app API
149149
And user "Alice" has waited "2" second for auth-app token to expire
150150
When user "Alice" lists all available spaces via the Graph API
151151
Then the HTTP status code should be "401"
152152

153153
@env-config
154154
Scenario: user lists their drives using impersonation token
155-
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "auth-app" service
155+
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "authapp" service
156156
And user "Admin" has created auth-app token for user "Alice" with expiration time "72h" using the auth-app API
157157
When user "Alice" lists all available spaces via the Graph API
158158
Then the HTTP status code should be "200"

tests/acceptance/features/apiAuthApp/tokenUsingUserId.feature

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Feature: create auth-app token using user-id
88

99
@env-config @issue-11063
1010
Scenario: admin creates auth-app token for another user using user-id
11-
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "auth-app" service
11+
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "authapp" service
1212
When user "Admin" creates app token with user-id for user "Alice" with expiration time "72h" using the auth-app API
1313
Then the HTTP status code should be "200"
1414
And the JSON data of the response should match
@@ -56,13 +56,13 @@ Feature: create auth-app token using user-id
5656

5757

5858
Scenario: non-admin user tries to create own auth-app token using user-id with impersonation enabled
59-
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "auth-app" service
59+
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "authapp" service
6060
When user "Alice" tries to create app token with user-id for user "Alice" with expiration time "72h" using the auth-app API
6161
Then the HTTP status code should be "403"
6262

6363
@env-config @issue-11063
6464
Scenario: non-admin user tries to creates auth-app token for another user using user-id
65-
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "auth-app" service
65+
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "authapp" service
6666
And user "Brian" has been created with default attributes
6767
When user "Brian" tries to create app token with user-id for user "Alice" with expiration time "72h" using the auth-app API
6868
Then the HTTP status code should be "403"
@@ -88,7 +88,7 @@ Feature: create auth-app token using user-id
8888

8989
@env-config
9090
Scenario: admin tries to create auth-app token for another user with user-id and without expiry
91-
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "auth-app" service
91+
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "authapp" service
9292
When user "Admin" tries to create app token with user-id for user "Alice" with expiration time "" using the auth-app API
9393
Then the HTTP status code should be "400"
9494
And the content in the response should include the following content:
@@ -98,7 +98,7 @@ Feature: create auth-app token using user-id
9898

9999

100100
Scenario: non-admin user tries to create auth-app token for another user using user-id and without expiry
101-
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "auth-app" service
101+
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" for "authapp" service
102102
And user "Brian" has been created with default attributes
103103
When user "Brian" tries to create app token with user-id for user "Alice" with expiration time "" using the auth-app API
104104
Then the HTTP status code should be "400"

tests/acceptance/features/apiNotification/notification.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Feature: Notification
134134

135135
@env-config
136136
Scenario: get a notification about a file share in default languages
137-
Given the config "OCIS_DEFAULT_LANGUAGE" has been set to "de" for "notifications" service
137+
Given the config "OCIS_DEFAULT_LANGUAGE" has been set to "de" for "settings" service
138138
And user "Alice" has sent the following resource share invitation:
139139
| resource | textfile1.txt |
140140
| space | Personal |

0 commit comments

Comments
 (0)