Skip to content

Commit cc66878

Browse files
committed
run integration tests separately
1 parent 93b80d1 commit cc66878

3 files changed

Lines changed: 276 additions & 39 deletions

File tree

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: DAV Integration Tests
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
paths:
7+
- ".github/workflows/dav-integration.yml"
8+
- "dav/**"
9+
- "go.mod"
10+
- "go.sum"
11+
push:
12+
branches:
13+
- main
14+
15+
concurrency:
16+
group: dav-integration
17+
cancel-in-progress: false
18+
19+
jobs:
20+
dav-integration:
21+
name: DAV Integration Tests
22+
runs-on: ubuntu-latest
23+
24+
services:
25+
webdav:
26+
image: httpd:2.4
27+
ports:
28+
- 8443:443
29+
30+
steps:
31+
- name: Checkout code
32+
uses: actions/checkout@v6
33+
34+
- name: Set up Go
35+
uses: actions/setup-go@v6
36+
with:
37+
go-version-file: go.mod
38+
39+
- name: Install Ginkgo
40+
run: go install github.com/onsi/ginkgo/v2/ginkgo@latest
41+
42+
- name: Setup WebDAV Server Configuration
43+
run: |
44+
# Create certificates
45+
mkdir -p /tmp/webdav-certs
46+
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
47+
-keyout /tmp/webdav-certs/server.key \
48+
-out /tmp/webdav-certs/server.crt \
49+
-subj "/C=US/ST=Test/L=Test/O=Test/CN=localhost" \
50+
-addext "subjectAltName=DNS:localhost,IP:127.0.0.1"
51+
52+
# Create WebDAV directory
53+
mkdir -p /tmp/webdav-data
54+
chmod 777 /tmp/webdav-data
55+
56+
# Create htpasswd file
57+
docker run --rm httpd:2.4 htpasswd -nb testuser testpass > /tmp/webdav.passwd
58+
59+
# Create Apache config with DAV
60+
cat > /tmp/httpd.conf << 'EOF'
61+
ServerRoot "/usr/local/apache2"
62+
Listen 443
63+
64+
LoadModule mpm_event_module modules/mod_mpm_event.so
65+
LoadModule authn_file_module modules/mod_authn_file.so
66+
LoadModule authn_core_module modules/mod_authn_core.so
67+
LoadModule authz_host_module modules/mod_authz_host.so
68+
LoadModule authz_user_module modules/mod_authz_user.so
69+
LoadModule authz_core_module modules/mod_authz_core.so
70+
LoadModule auth_basic_module modules/mod_auth_basic.so
71+
LoadModule dav_module modules/mod_dav.so
72+
LoadModule dav_fs_module modules/mod_dav_fs.so
73+
LoadModule setenvif_module modules/mod_setenvif.so
74+
LoadModule ssl_module modules/mod_ssl.so
75+
LoadModule unixd_module modules/mod_unixd.so
76+
LoadModule dir_module modules/mod_dir.so
77+
78+
User daemon
79+
Group daemon
80+
81+
DAVLockDB /usr/local/apache2/var/DavLock
82+
83+
<IfModule ssl_module>
84+
SSLRandomSeed startup builtin
85+
SSLRandomSeed connect builtin
86+
</IfModule>
87+
88+
<VirtualHost *:443>
89+
SSLEngine on
90+
SSLCertificateFile /usr/local/apache2/certs/server.crt
91+
SSLCertificateKeyFile /usr/local/apache2/certs/server.key
92+
93+
DocumentRoot "/usr/local/apache2/webdav"
94+
95+
<Directory "/usr/local/apache2/webdav">
96+
Dav On
97+
Options +Indexes
98+
AuthType Basic
99+
AuthName "WebDAV"
100+
AuthUserFile /usr/local/apache2/webdav.passwd
101+
Require valid-user
102+
103+
<LimitExcept GET OPTIONS>
104+
Require valid-user
105+
</LimitExcept>
106+
</Directory>
107+
</VirtualHost>
108+
EOF
109+
110+
# Get the service container ID
111+
CONTAINER_ID=$(docker ps --filter "ancestor=httpd:2.4" --format "{{.ID}}")
112+
echo "WebDAV container ID: $CONTAINER_ID"
113+
114+
# Create required directories in container first
115+
docker exec $CONTAINER_ID mkdir -p /usr/local/apache2/certs
116+
docker exec $CONTAINER_ID mkdir -p /usr/local/apache2/webdav
117+
docker exec $CONTAINER_ID mkdir -p /usr/local/apache2/var
118+
docker exec $CONTAINER_ID chmod 777 /usr/local/apache2/webdav
119+
docker exec $CONTAINER_ID chmod 777 /usr/local/apache2/var
120+
121+
# Copy files to container
122+
docker cp /tmp/httpd.conf $CONTAINER_ID:/usr/local/apache2/conf/httpd.conf
123+
docker cp /tmp/webdav.passwd $CONTAINER_ID:/usr/local/apache2/webdav.passwd
124+
docker cp /tmp/webdav-certs/server.crt $CONTAINER_ID:/usr/local/apache2/certs/server.crt
125+
docker cp /tmp/webdav-certs/server.key $CONTAINER_ID:/usr/local/apache2/certs/server.key
126+
127+
# Reload Apache
128+
docker exec $CONTAINER_ID apachectl graceful
129+
130+
# Wait for Apache to be ready
131+
sleep 5
132+
133+
# Test connection
134+
curl -k -u testuser:testpass -v https://localhost:8443/ || echo "WebDAV server not ready yet"
135+
136+
- name: Run Integration Tests
137+
env:
138+
DAV_ENDPOINT: "https://localhost:8443"
139+
DAV_USER: "testuser"
140+
DAV_PASSWORD: "testpass"
141+
DAV_SECRET: "test-secret-key"
142+
run: |
143+
export DAV_CA_CERT="$(cat /tmp/webdav-certs/server.crt)"
144+
cd dav
145+
ginkgo -v ./integration
146+

.github/workflows/unit-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
run: |
4343
export CGO_ENABLED=0
4444
go version
45-
go test -v ./dav/...
45+
go run github.com/onsi/ginkgo/v2/ginkgo --skip-package=integration ./dav/...
4646
4747
- name: gcs unit tests
4848
run: |

dav/integration/general_dav_test.go

Lines changed: 129 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ var _ = Describe("General testing for DAV", func() {
3232
}
3333
})
3434

35-
configurations := []TableEntry{
36-
Entry("with basic config", &config.Config{
35+
It("Blobstore lifecycle works with basic config", func() {
36+
cfg := &config.Config{
3737
Endpoint: endpoint,
3838
User: user,
3939
Password: password,
@@ -42,8 +42,12 @@ var _ = Describe("General testing for DAV", func() {
4242
CA: ca,
4343
},
4444
},
45-
}),
46-
Entry("with custom retry attempts", &config.Config{
45+
}
46+
integration.AssertLifecycleWorks(cliPath, cfg)
47+
})
48+
49+
It("Blobstore lifecycle works with custom retry attempts", func() {
50+
cfg := &config.Config{
4751
Endpoint: endpoint,
4852
User: user,
4953
Password: password,
@@ -53,36 +57,127 @@ var _ = Describe("General testing for DAV", func() {
5357
CA: ca,
5458
},
5559
},
56-
}),
57-
}
60+
}
61+
integration.AssertLifecycleWorks(cliPath, cfg)
62+
})
5863

59-
DescribeTable("Blobstore lifecycle works",
60-
func(cfg *config.Config) { integration.AssertLifecycleWorks(cliPath, cfg) },
61-
configurations,
62-
)
64+
It("Invoking `get` on a non-existent-key fails with basic config", func() {
65+
cfg := &config.Config{
66+
Endpoint: endpoint,
67+
User: user,
68+
Password: password,
69+
TLS: config.TLS{
70+
Cert: config.Cert{
71+
CA: ca,
72+
},
73+
},
74+
}
75+
integration.AssertGetNonexistentFails(cliPath, cfg)
76+
})
6377

64-
DescribeTable("Invoking `get` on a non-existent-key fails",
65-
func(cfg *config.Config) { integration.AssertGetNonexistentFails(cliPath, cfg) },
66-
configurations,
67-
)
78+
It("Invoking `get` on a non-existent-key fails with custom retry attempts", func() {
79+
cfg := &config.Config{
80+
Endpoint: endpoint,
81+
User: user,
82+
Password: password,
83+
RetryAttempts: 5,
84+
TLS: config.TLS{
85+
Cert: config.Cert{
86+
CA: ca,
87+
},
88+
},
89+
}
90+
integration.AssertGetNonexistentFails(cliPath, cfg)
91+
})
6892

69-
DescribeTable("Invoking `delete` on a non-existent-key does not fail",
70-
func(cfg *config.Config) { integration.AssertDeleteNonexistentWorks(cliPath, cfg) },
71-
configurations,
72-
)
93+
It("Invoking `delete` on a non-existent-key does not fail with basic config", func() {
94+
cfg := &config.Config{
95+
Endpoint: endpoint,
96+
User: user,
97+
Password: password,
98+
TLS: config.TLS{
99+
Cert: config.Cert{
100+
CA: ca,
101+
},
102+
},
103+
}
104+
integration.AssertDeleteNonexistentWorks(cliPath, cfg)
105+
})
73106

74-
DescribeTable("Blobstore list and delete-recursive lifecycle works",
75-
func(cfg *config.Config) { integration.AssertOnListDeleteLifecycle(cliPath, cfg) },
76-
configurations,
77-
)
107+
It("Invoking `delete` on a non-existent-key does not fail with custom retry attempts", func() {
108+
cfg := &config.Config{
109+
Endpoint: endpoint,
110+
User: user,
111+
Password: password,
112+
RetryAttempts: 5,
113+
TLS: config.TLS{
114+
Cert: config.Cert{
115+
CA: ca,
116+
},
117+
},
118+
}
119+
integration.AssertDeleteNonexistentWorks(cliPath, cfg)
120+
})
78121

79-
DescribeTable("Invoking `ensure-storage-exists` works",
80-
func(cfg *config.Config) {
81-
Skip("ensure-storage-exists not applicable for WebDAV - root always exists")
82-
integration.AssertEnsureStorageExists(cliPath, cfg)
83-
},
84-
configurations,
85-
)
122+
It("Blobstore list and delete-recursive lifecycle works with basic config", func() {
123+
cfg := &config.Config{
124+
Endpoint: endpoint,
125+
User: user,
126+
Password: password,
127+
TLS: config.TLS{
128+
Cert: config.Cert{
129+
CA: ca,
130+
},
131+
},
132+
}
133+
integration.AssertOnListDeleteLifecycle(cliPath, cfg)
134+
})
135+
136+
It("Blobstore list and delete-recursive lifecycle works with custom retry attempts", func() {
137+
cfg := &config.Config{
138+
Endpoint: endpoint,
139+
User: user,
140+
Password: password,
141+
RetryAttempts: 5,
142+
TLS: config.TLS{
143+
Cert: config.Cert{
144+
CA: ca,
145+
},
146+
},
147+
}
148+
integration.AssertOnListDeleteLifecycle(cliPath, cfg)
149+
})
150+
151+
It("Invoking `ensure-storage-exists` works with basic config", func() {
152+
Skip("ensure-storage-exists not applicable for WebDAV - root always exists")
153+
cfg := &config.Config{
154+
Endpoint: endpoint,
155+
User: user,
156+
Password: password,
157+
TLS: config.TLS{
158+
Cert: config.Cert{
159+
CA: ca,
160+
},
161+
},
162+
}
163+
integration.AssertEnsureStorageExists(cliPath, cfg)
164+
})
165+
166+
It("Invoking `ensure-storage-exists` works with custom retry attempts", func() {
167+
Skip("ensure-storage-exists not applicable for WebDAV - root always exists")
168+
cfg := &config.Config{
169+
Endpoint: endpoint,
170+
User: user,
171+
Password: password,
172+
RetryAttempts: 5,
173+
TLS: config.TLS{
174+
Cert: config.Cert{
175+
CA: ca,
176+
},
177+
},
178+
}
179+
integration.AssertEnsureStorageExists(cliPath, cfg)
180+
})
86181

87182
Context("with signed URL support", func() {
88183
BeforeEach(func() {
@@ -91,8 +186,8 @@ var _ = Describe("General testing for DAV", func() {
91186
}
92187
})
93188

94-
configurationsWithSecret := []TableEntry{
95-
Entry("with secret for signed URLs", &config.Config{
189+
It("Invoking `sign` returns a signed URL with secret for signed URLs", func() {
190+
cfg := &config.Config{
96191
Endpoint: endpoint,
97192
User: user,
98193
Password: password,
@@ -102,13 +197,9 @@ var _ = Describe("General testing for DAV", func() {
102197
CA: ca,
103198
},
104199
},
105-
}),
106-
}
107-
108-
DescribeTable("Invoking `sign` returns a signed URL",
109-
func(cfg *config.Config) { integration.AssertOnSignedURLs(cliPath, cfg) },
110-
configurationsWithSecret,
111-
)
200+
}
201+
integration.AssertOnSignedURLs(cliPath, cfg)
202+
})
112203
})
113204
})
114205
})

0 commit comments

Comments
 (0)