Skip to content

Commit 2a25e95

Browse files
committed
CI: Add cli integration test for secret creation/retrieval
1 parent 2d36315 commit 2a25e95

File tree

2 files changed

+112
-1
lines changed

2 files changed

+112
-1
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
2+
# SPDX-FileCopyrightText: Nextcloud contributors
3+
# SPDX-License-Identifier: AGPL-3.0-or-later
4+
name: Integration Test
5+
6+
on:
7+
pull_request:
8+
push:
9+
branches:
10+
- main
11+
- stable*
12+
tags:
13+
- "v*"
14+
- "test*"
15+
16+
env:
17+
APP_NAME: secrets
18+
19+
jobs:
20+
integration-test-cli:
21+
runs-on: ubuntu-latest
22+
23+
strategy:
24+
matrix:
25+
php-versions: ['8.3']
26+
server-versions: ['v30.0.4', 'v31.0.0beta2']
27+
28+
services:
29+
mysql:
30+
image: mariadb:10.5
31+
ports:
32+
- 4444:3306/tcp
33+
env:
34+
MYSQL_ROOT_PASSWORD: rootpassword
35+
options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 5
36+
37+
steps:
38+
- name: Set app env
39+
run: |
40+
# Split and keep last
41+
echo "APP_NAME=secrets" >> $GITHUB_ENV
42+
43+
- name: Enable ONLY_FULL_GROUP_BY MySQL option
44+
run: |
45+
echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
46+
echo "SELECT @@sql_mode;" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
47+
48+
- name: Checkout server
49+
uses: actions/checkout@v3
50+
with:
51+
submodules: true
52+
repository: nextcloud/server
53+
ref: ${{ matrix.server-versions }}
54+
55+
- name: Checkout app
56+
uses: actions/checkout@v3
57+
with:
58+
path: apps/${{ env.APP_NAME }}
59+
60+
- name: Set up php ${{ matrix.php-versions }}
61+
uses: shivammathur/setup-php@v2
62+
with:
63+
php-version: ${{ matrix.php-versions }}
64+
tools: phpunit
65+
extensions: mbstring, iconv, fileinfo, intl, mysql, pdo_mysql
66+
coverage: none
67+
68+
- name: Set up PHPUnit
69+
working-directory: apps/${{ env.APP_NAME }}
70+
run: composer i
71+
72+
- name: Read package.json node and npm engines version
73+
uses: skjnldsv/read-package-engines-version-actions@v1.2
74+
id: versions
75+
with:
76+
fallbackNode: '^12'
77+
fallbackNpm: '^6'
78+
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
79+
uses: actions/setup-node@v3
80+
with:
81+
node-version: ${{ steps.versions.outputs.nodeVersion }}
82+
- name: Set up bun
83+
uses: oven-sh/setup-bun@v1
84+
85+
- name: Build cli
86+
working-directory: apps/${{ env.APP_NAME }}/cli
87+
run: |
88+
cp ../src/crypto.js ./crypto.import.js
89+
bun install --dev
90+
bun build --compile ./cli.ts --outfile nc-secrets
91+
92+
- name: Set up Nextcloud
93+
env:
94+
DB_PORT: 4444
95+
run: |
96+
mkdir data
97+
./occ maintenance:install --verbose --database=mysql --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password
98+
./occ --version
99+
./occ app:enable ${{ env.APP_NAME }}
100+
101+
- name: Run Nextcloud
102+
run: php -S localhost:8080 &
103+
104+
- name: '[TEST] create and retrieve secret'
105+
working-directory: apps/${{ env.APP_NAME }}/cli
106+
run: |
107+
set -e
108+
base64 < /dev/urandom | head -c 10 > ./secret_data
109+
result="$(echo "password" | ./nc-secrets -k create -t 'integration-test' http://localhost:8080 admin ./secret_data)"
110+
echo "${result}"
111+

cli/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ contains a Nextcloud password (or app token) for user 'sharer' at a Nextcloud in
5050
you could use the following command:
5151

5252
```sh
53-
./nc-secrets create -t 'My Secret' https://nextcloud.foss sharer "$NC_PASS" ./my-secret <<<"$NC_PASS"
53+
./nc-secrets create -t 'My Secret' https://nextcloud.foss sharer ./my-secret <<<"$NC_PASS"
5454
```
5555

5656
### Retrieve

0 commit comments

Comments
 (0)