Skip to content

Commit b5d185c

Browse files
committed
[CHANGE] tests added
1 parent f56d11d commit b5d185c

File tree

5 files changed

+132
-0
lines changed

5 files changed

+132
-0
lines changed

.github/workflows/test.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: "CI - Test Features"
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
workflow_dispatch:
8+
9+
jobs:
10+
test-autogenerated:
11+
runs-on: ubuntu-latest
12+
continue-on-error: true
13+
strategy:
14+
matrix:
15+
features:
16+
- bitwarden-cli
17+
baseImage:
18+
- debian:latest
19+
- ubuntu:latest
20+
- mcr.microsoft.com/devcontainers/base:ubuntu
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: "Install latest devcontainer CLI"
25+
run: npm install -g @devcontainers/cli
26+
27+
- name: "Generating tests for '${{ matrix.features }}' against '${{ matrix.baseImage }}'"
28+
run: devcontainer features test --skip-scenarios -f ${{ matrix.features }} -i ${{ matrix.baseImage }} .
29+
30+
test-scenarios:
31+
runs-on: ubuntu-latest
32+
continue-on-error: true
33+
strategy:
34+
matrix:
35+
features:
36+
- bitwarden-cli
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: "Install latest devcontainer CLI"
41+
run: npm install -g @devcontainers/cli
42+
43+
- name: "Generating tests for '${{ matrix.features }}' scenarios"
44+
run: devcontainer features test -f ${{ matrix.features }} --skip-autogenerated --skip-duplicated .
45+
46+
test-global:
47+
runs-on: ubuntu-latest
48+
continue-on-error: true
49+
steps:
50+
- uses: actions/checkout@v4
51+
52+
- name: "Install latest devcontainer CLI"
53+
run: npm install -g @devcontainers/cli
54+
55+
- name: "Testing global scenarios"
56+
run: devcontainer features test --global-scenarios-only .

test/bitwarden-cli/scenarios.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"server_example": {
3+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
4+
"features": {
5+
"bitwarden-cli": {
6+
"server": "https://example.com"
7+
}
8+
}
9+
},
10+
"server_example_full": {
11+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
12+
"features": {
13+
"bitwarden-cli": {
14+
"server": "https://example.com",
15+
"api": "https://example.com/api",
16+
"web_vault": "https://example.com/web_vault",
17+
"identity": "https://example.com/identity",
18+
"icons": "https://example.com/icons",
19+
"notifications": "https://example.com/notifications",
20+
"events": "https://example.com/events",
21+
"key_connector": "https://example.com/key_connector"
22+
}
23+
}
24+
}
25+
}

test/bitwarden-cli/server_example.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
set -e
3+
4+
serverVals='{
5+
"api": null,
6+
"identity": null,
7+
"webVault": null,
8+
"icons": null,
9+
"notifications": null,
10+
"events": null,
11+
"keyConnector": null
12+
}'
13+
14+
source dev-container-features-test-lib
15+
16+
check "bw config server => https://example.com" bash -c "bw config server | grep '^https://example.com\$'"
17+
18+
for serverVar in `echo $serverVals | jq --raw-output "keys | .[]"`
19+
do
20+
serverVal="$(echo $serverVals | jq --raw-output ".$serverVar")"
21+
check "server config $serverVar => $serverVal" bash -c "cat ~/.config/Bitwarden\ CLI/data.json | jq --raw-output '.global_environment_environment.urls.$serverVar' | grep '^$serverVal\$'"
22+
done
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
set -e
3+
4+
serverVals='{
5+
"api": "https://example.com/api",
6+
"webVault": "https://example.com/web_vault",
7+
"identity": "https://example.com/identity",
8+
"icons": "https://example.com/icons",
9+
"notifications": "https://example.com/notifications",
10+
"events": "https://example.com/events",
11+
"keyConnector": "https://example.com/key_connector"
12+
}'
13+
14+
source dev-container-features-test-lib
15+
16+
check "bw config server => https://example.com" bash -c "bw config server | grep '^https://example.com\$'"
17+
18+
for serverVar in `echo $serverVals | jq --raw-output "keys | .[]"`
19+
do
20+
serverVal="$(echo $serverVals | jq --raw-output ".$serverVar")"
21+
check "server config $serverVar => $serverVal" bash -c "cat ~/.config/Bitwarden\ CLI/data.json | jq --raw-output '.global_environment_environment.urls.$serverVar' | grep '^$serverVal\$'"
22+
done

test/bitwarden-cli/test.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
set -e
3+
4+
source dev-container-features-test-lib
5+
6+
check "bw --version" bash -c "bw --version | grep -E '^20(2[5-9]|[3-9][0-9])\\.([1-9]|1[0-2])\\.([1-9]|[1-2][0-9]|3[0-1])'"
7+
check "bw config server => https://bitwarden.com" bash -c "bw config server | grep '^https://bitwarden.com$$'"

0 commit comments

Comments
 (0)