Skip to content

Commit d2cc982

Browse files
committed
Fix
1 parent 590690a commit d2cc982

2 files changed

Lines changed: 71 additions & 2 deletions

File tree

.github/workflows/build.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,17 @@ jobs:
3333
- name: Run unit tests
3434
run: bats tests/unit/
3535

36+
- name: Fetch latest BWDC version
37+
id: bwdc_version
38+
env:
39+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
run: |
41+
VERSION=$(gh release view --repo bitwarden/directory-connector \
42+
--json tagName --jq '.tagName | ltrimstr("v")')
43+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
44+
3645
- name: Build image for integration tests
37-
run: docker build -t bwdc-test .
46+
run: docker build --build-arg BWDC_VERSION=${{ steps.bwdc_version.outputs.version }} -t bwdc-test .
3847

3948
- name: Run integration tests
4049
env:
@@ -62,11 +71,15 @@ jobs:
6271

6372
- name: Set version
6473
id: version
74+
env:
75+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6576
run: |
6677
if [ -n "${{ inputs.BWDC_VERSION }}" ]; then
6778
echo "version=${{ inputs.BWDC_VERSION }}" >> $GITHUB_OUTPUT
6879
elif [ "${{ github.event_name }}" = "pull_request" ]; then
69-
echo "version=pr-${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
80+
VERSION=$(gh release view --repo bitwarden/directory-connector \
81+
--json tagName --jq '.tagName | ltrimstr("v")')
82+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
7083
else
7184
echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
7285
fi

tests/integration/container.bats

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,62 @@ setup_file() {
147147
[[ "$output" =~ "config ldap.password supersecret" ]]
148148
}
149149

150+
@test "BW_DIRECTORY_KEY with azure type (numeric) calls bwdc config azure.key" {
151+
local cid
152+
cid=$(docker run -d \
153+
-v "$FIXTURES/mock_bwdc.sh:/usr/local/bin/bwdc" \
154+
-v "$FIXTURES/data.json:$CONFIG_PATH" \
155+
-e BW_DIRECTORY_TYPE=1 \
156+
-e BW_DIRECTORY_KEY=my-azure-secret \
157+
-e SYNC_INTERVAL_MIN=60 \
158+
"$IMAGE")
159+
160+
sleep 8
161+
162+
run docker exec "$cid" cat /tmp/bwdc_calls
163+
docker rm -f "$cid" >/dev/null 2>&1
164+
[ "$status" -eq 0 ]
165+
[[ "$output" =~ "config azure.key my-azure-secret" ]]
166+
}
167+
168+
@test "BW_DIRECTORY_KEY with azure type (string) calls bwdc config azure.key" {
169+
local cid
170+
cid=$(docker run -d \
171+
-v "$FIXTURES/mock_bwdc.sh:/usr/local/bin/bwdc" \
172+
-v "$FIXTURES/data.json:$CONFIG_PATH" \
173+
-e BW_DIRECTORY_TYPE=azure \
174+
-e BW_DIRECTORY_KEY=my-azure-secret \
175+
-e SYNC_INTERVAL_MIN=60 \
176+
"$IMAGE")
177+
178+
sleep 8
179+
180+
run docker exec "$cid" cat /tmp/bwdc_calls
181+
docker rm -f "$cid" >/dev/null 2>&1
182+
[ "$status" -eq 0 ]
183+
[[ "$output" =~ "config azure.key my-azure-secret" ]]
184+
}
185+
186+
@test "azure sync: bwdc config directory is set to type 1" {
187+
local cid
188+
cid=$(docker run -d \
189+
-v "$FIXTURES/mock_bwdc.sh:/usr/local/bin/bwdc" \
190+
-v "$FIXTURES/data.json:$CONFIG_PATH" \
191+
-e BW_DIRECTORY_TYPE=1 \
192+
-e BW_DIRECTORY_KEY=my-azure-secret \
193+
-e SYNC_INTERVAL_MIN=60 \
194+
"$IMAGE")
195+
196+
sleep 8
197+
198+
run docker exec "$cid" cat /tmp/bwdc_calls
199+
docker rm -f "$cid" >/dev/null 2>&1
200+
[ "$status" -eq 0 ]
201+
[[ "$output" =~ "config directory 1" ]]
202+
[[ "$output" =~ "config azure.key my-azure-secret" ]]
203+
[[ "$output" =~ "sync" ]]
204+
}
205+
150206
@test "bwdc sync is called during the sync loop" {
151207
local cid
152208
cid=$(docker run -d \

0 commit comments

Comments
 (0)