Skip to content

Commit a5997e7

Browse files
committed
settingup antivirus, email and authapp services
1 parent e4dec40 commit a5997e7

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
@@ -1107,19 +1107,19 @@ def localApiTestPipeline(ctx):
11071107
([] if run_on_k8s else restoreBuildArtifactCache(ctx, "ocis-binary-amd64", "ocis/bin")) +
11081108
(tikaService() if params["tikaNeeded"] and not run_on_k8s else tikaServiceK8s() if params["tikaNeeded"] and run_on_k8s else []) +
11091109
(waitForServices("online-offices", ["collabora:9980", "onlyoffice:443", "fakeoffice:8080"]) if params["collaborationServiceNeeded"] else []) +
1110-
(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]))) +
1111-
(waitForClamavService() if params["antivirusNeeded"] else []) +
1112-
(waitForEmailService() if params["emailNeeded"] else []) +
1110+
(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]))) +
1111+
(waitForClamavService() if params["antivirusNeeded"] and not run_on_k8s else exposeAntivirusServiceK8s() if params["antivirusNeeded"] and run_on_k8s else []) +
1112+
(waitForEmailService() if params["emailNeeded"] and not run_on_k8s else exposeEmailServiceK8s() if params["emailNeeded"] and run_on_k8s else []) +
11131113
(ocisServer(storage, deploy_type = "federation", extra_server_environment = params["extraServerEnvironment"]) if params["federationServer"] else []) +
11141114
((wopiCollaborationService("fakeoffice") + wopiCollaborationService("collabora") + wopiCollaborationService("onlyoffice")) if params["collaborationServiceNeeded"] else []) +
11151115
(ocisHealthCheck("wopi", ["wopi-collabora:9304", "wopi-onlyoffice:9304", "wopi-fakeoffice:9304"]) if params["collaborationServiceNeeded"] else []) +
11161116
localApiTests(name, params["suites"], storage, params["extraEnvironment"], run_with_remote_php, ocis_url = ocis_url, k8s = run_on_k8s) +
11171117
apiTestFailureLog() +
11181118
(generateCoverageFromAPITest(ctx, name) if not run_on_k8s else []),
1119-
"services": (emailService() if params["emailNeeded"] else []) +
1120-
(clamavService() if params["antivirusNeeded"] else []) +
1121-
((fakeOffice() + collaboraService() + onlyofficeService()) if params["collaborationServiceNeeded"] else []) +
1122-
(k3sCluster() if run_on_k8s else []),
1119+
"services": (k3sCluster() if run_on_k8s else []) +
1120+
(emailService() if params["emailNeeded"] and not run_on_k8s else []) +
1121+
(clamavService() if params["antivirusNeeded"] and not run_on_k8s else []) +
1122+
((fakeOffice() + collaboraService() + onlyofficeService()) if params["collaborationServiceNeeded"] else []),
11231123
"depends_on": getPipelineNames(buildOcisBinaryForTesting(ctx)),
11241124
"trigger": {
11251125
"ref": [
@@ -3835,6 +3835,49 @@ def deployOcis():
38353835
],
38363836
}]
38373837

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