Skip to content

Commit bcd836d

Browse files
Merge pull request #11626 from owncloud/run-antivirus-test-on-k8s
[tests-only][full-ci] add support for antivirus, email and authapp services
2 parents f42466c + a5997e7 commit bcd836d

File tree

10 files changed

+159
-24
lines changed

10 files changed

+159
-24
lines changed

.drone.star

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,19 +1108,19 @@ def localApiTestPipeline(ctx):
11081108
([] if run_on_k8s else restoreBuildArtifactCache(ctx, "ocis-binary-amd64", "ocis/bin")) +
11091109
(tikaService() if params["tikaNeeded"] and not run_on_k8s else tikaServiceK8s() if params["tikaNeeded"] and run_on_k8s else []) +
11101110
(waitForServices("online-offices", ["collabora:9980", "onlyoffice:443", "fakeoffice:8080"]) if params["collaborationServiceNeeded"] else []) +
1111-
(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]))) +
1112-
(waitForClamavService() if params["antivirusNeeded"] else []) +
1113-
(waitForEmailService() if params["emailNeeded"] else []) +
1111+
(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]))) +
1112+
(waitForClamavService() if params["antivirusNeeded"] and not run_on_k8s else exposeAntivirusServiceK8s() if params["antivirusNeeded"] and run_on_k8s else []) +
1113+
(waitForEmailService() if params["emailNeeded"] and not run_on_k8s else exposeEmailServiceK8s() if params["emailNeeded"] and run_on_k8s else []) +
11141114
(ocisServer(storage, deploy_type = "federation", extra_server_environment = params["extraServerEnvironment"]) if params["federationServer"] else []) +
11151115
((wopiCollaborationService("fakeoffice") + wopiCollaborationService("collabora") + wopiCollaborationService("onlyoffice")) if params["collaborationServiceNeeded"] else []) +
11161116
(ocisHealthCheck("wopi", ["wopi-collabora:9304", "wopi-onlyoffice:9304", "wopi-fakeoffice:9304"]) if params["collaborationServiceNeeded"] else []) +
11171117
localApiTests(name, params["suites"], storage, params["extraEnvironment"], run_with_remote_php, ocis_url = ocis_url, k8s = run_on_k8s) +
11181118
apiTestFailureLog() +
11191119
(generateCoverageFromAPITest(ctx, name) if not run_on_k8s else []),
1120-
"services": (emailService() if params["emailNeeded"] else []) +
1121-
(clamavService() if params["antivirusNeeded"] else []) +
1122-
((fakeOffice() + collaboraService() + onlyofficeService()) if params["collaborationServiceNeeded"] else []) +
1123-
(k3sCluster() if run_on_k8s else []),
1120+
"services": (k3sCluster() if run_on_k8s else []) +
1121+
(emailService() if params["emailNeeded"] and not run_on_k8s else []) +
1122+
(clamavService() if params["antivirusNeeded"] and not run_on_k8s else []) +
1123+
((fakeOffice() + collaboraService() + onlyofficeService()) if params["collaborationServiceNeeded"] else []),
11241124
"depends_on": getPipelineNames(buildOcisBinaryForTesting(ctx)),
11251125
"trigger": {
11261126
"ref": [
@@ -3836,6 +3836,49 @@ def deployOcis():
38363836
],
38373837
}]
38383838

3839+
def clamavServiceK8s():
3840+
return [{
3841+
"name": "clamav",
3842+
"image": OC_CI_ALPINE,
3843+
"commands": [
3844+
"cp -r %s/tests/config/drone/k8s/clamav %s/ocis-charts/charts/ocis/templates/" % (dirs["base"], dirs["base"]),
3845+
"sed -i 's/{{ *\\\\.Values\\\\.features\\\\.virusscan\\\\.infectedFileHandling *| *quote *}}/\"delete\"/' %s/ocis-charts/charts/ocis/templates/antivirus/deployment.yaml" % dirs["base"],
3846+
"sed -i 's/{{ *\\\\.Values\\\\.features\\\\.virusscan\\\\.infectedFileHandling *| *quote *}}/\"delete\"/' %s/ocis-charts/charts/ocis/templates/antivirus/deployment.yaml" % dirs["base"],
3847+
"sed -i '/name: ANTIVIRUS_SCANNER_TYPE/{n;s/value: *\"icap\"/value: \"clamav\"/}' %s/ocis-charts/charts/ocis/templates/antivirus/deployment.yaml" % dirs["base"],
3848+
"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"],
3849+
],
3850+
}]
3851+
3852+
def emailServiceK8s():
3853+
return [{
3854+
"name": "copy-%s-service" % EMAIL_SMTP_HOST,
3855+
"image": OC_CI_ALPINE,
3856+
"commands": [
3857+
"cp -r %s/tests/config/drone/k8s/mailpit %s/ocis-charts/charts/ocis/templates/" % (dirs["base"], dirs["base"]),
3858+
],
3859+
}]
3860+
3861+
def exposeEmailServiceK8s():
3862+
return [{
3863+
"name": EMAIL_SMTP_HOST,
3864+
"image": "ghcr.io/k3d-io/k3d:5-dind",
3865+
"commands": [
3866+
"kubectl port-forward svc/mailpit %s:%s -n ocis" % (EMAIL_PORT, EMAIL_PORT),
3867+
"kubectl port-forward svc/mailpit 9174:9174 -n ocis",
3868+
],
3869+
"detach": True,
3870+
}]
3871+
3872+
def exposeAntivirusServiceK8s():
3873+
return [{
3874+
"name": EMAIL_SMTP_HOST,
3875+
"image": "ghcr.io/k3d-io/k3d:5-dind",
3876+
"commands": [
3877+
"kubectl port-forward svc/antivirus 9297:9277 -n ocis",
3878+
],
3879+
"detach": True,
3880+
}]
3881+
38393882
def ociswrapper():
38403883
return [{
38413884
"name": "ociswrapper",
@@ -3846,6 +3889,8 @@ def ociswrapper():
38463889
"until test -f $${KUBECONFIG}; do sleep 1s; done",
38473890
"kubectl get pods -A",
38483891
"kubectl get ingress -A",
3892+
"kubectl describe pods $(kubectl get pods -n ocis -l app=antivirus -o jsonpath=\"{.items[0].metadata.name}\") -n ocis",
3893+
"kubectl describe pods $(kubectl get pods -n ocis -l app=postprocessing -o jsonpath=\"{.items[0].metadata.name}\") -n ocis",
38493894
"%s/bin/ociswrapper serve --url https://ocis-server --admin-username admin --admin-password admin --skip-ocis-run" % dirs["ocisWrapper"],
38503895
],
38513896
"detach": True,

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 |
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: clamav
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: clamav
10+
template:
11+
metadata:
12+
labels:
13+
app: clamav
14+
spec:
15+
containers:
16+
- name: clamav
17+
image: owncloudci/clamavd
18+
ports:
19+
- containerPort: 3310
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: clamav
5+
spec:
6+
selector:
7+
app: clamav
8+
ports:
9+
- protocol: TCP
10+
port: 3310
11+
targetPort: 3310
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: mailpit
5+
labels:
6+
app: mailpit
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: mailpit
12+
template:
13+
metadata:
14+
labels:
15+
app: mailpit
16+
spec:
17+
containers:
18+
- name: mailpit
19+
image: axllent/mailpit:latest
20+
ports:
21+
- containerPort: 1025
22+
name: smtp
23+
- containerPort: 8025
24+
name: web
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: mailpit
5+
spec:
6+
selector:
7+
app: mailpit
8+
ports:
9+
- name: smtp
10+
port: 1025
11+
targetPort: smtp
12+
protocol: TCP
13+
appProtocol: tcp
14+
- name: web
15+
port: 8025
16+
targetPort: web
17+
protocol: TCP

tests/config/drone/k8s/values.yaml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,21 @@ insecure:
1616
ocisHttpApiInsecure: true
1717
ocmInsecure: true
1818
features:
19+
authapp:
20+
enabled: true
21+
emailNotifications:
22+
enabled: true
23+
smtp:
24+
host: mailpit
25+
port: 1025
26+
sender: 'oCIS <[email protected]>'
27+
authentication: none
28+
encryption: none
29+
branding:
30+
enabled: false
1931
virusscan:
20-
enabled: false
32+
enabled: true
33+
infectedFileHandling: delete
2134
policies:
2235
enabled: false
2336
ocm:
@@ -115,3 +128,9 @@ services:
115128
enabled: true
116129
accessModes:
117130
- ReadWriteOnce
131+
antivirus:
132+
events:
133+
consumer:
134+
concurrency: 10
135+
secretRefs:
136+
notificationsSmtpSecretRef: notifications-smtp-secret

0 commit comments

Comments
 (0)