File tree Expand file tree Collapse file tree 6 files changed +58
-1
lines changed Expand file tree Collapse file tree 6 files changed +58
-1
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,11 @@ VAULT_HOST_URL="https://localhost"
27
27
# Used to match a remote server configuration.
28
28
REMOTE_VAULT_CONFIG_MATCH = " https://localhost:8443/api/config"
29
29
30
+ # (Optional) Specify the root directory filename for the Bitwarden vault JSON import
31
+ # you'd like to use (e.g. "vault.json")
32
+ # Mock data generation tool: https://www.passwordvaultgenerator.com/
33
+ VAULT_IMPORT_FILE = " "
34
+
30
35
# The extension that will have tests running against it
31
36
EXTENSION_BUILD_PATH = " clients/apps/browser/build"
32
37
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ Thumbs.db
6
6
.env
7
7
dev-server.local.pem
8
8
tmp-vault-seeder
9
+ vault.json
9
10
ssl.crt
10
11
ssl.key
11
12
Original file line number Diff line number Diff line change 42
42
"seed:vault:account" : " NODE_EXTRA_CA_CERTS=ssl.crt ts-node ./scripts/create-account.ts" ,
43
43
"seed:vault:ciphers" : " ts-node ./scripts/vault-seeder.ts" ,
44
44
"seed:vault:ciphers:refresh" : " ./scripts/cli-serve-helper.sh && REFRESH=true ts-node ./scripts/vault-seeder.ts && kill $(ps -e | grep 'bw serve' | grep -v 'vault-seeder' | awk '{print $1}')" ,
45
+ "seed:vault:import" : " ./scripts/vault-import.sh" ,
45
46
"setup:all" : " ./scripts/first-time-setup.sh" ,
46
47
"setup:extension" : " rimraf clients && git clone https://github.com/bitwarden/clients.git clients && cd clients && npm ci" ,
47
48
"setup:install" : " ts-node ./scripts/generate-installation.ts" ,
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ BW_COMMAND status
33
33
# shellcheck disable=SC2086 # we want to pass the server host url as a single argument
34
34
BW_COMMAND logout --quiet # In case there's an active outdated session (e.g. docker container was rebuilt)
35
35
BW_COMMAND config server $VAULT_HOST || true # no error if already configured
36
- BW_COMMAND login " $VAULT_EMAIL " " $VAULT_PASSWORD " --nointeraction || true # no error if already logged in
36
+ BW_COMMAND login " $VAULT_EMAIL " " $VAULT_PASSWORD " --nointeraction --quiet || true # no error if already logged in
37
37
BW_COMMAND sync || true # no error if already synced
38
38
39
39
# Start Vault Management API
Original file line number Diff line number Diff line change @@ -15,5 +15,6 @@ npm run seed:vault:account
15
15
npm run start:cli
16
16
npm run seed:vault:ciphers
17
17
npm run stop:cli
18
+ npm run seed:vault:import
18
19
19
20
npm run setup:test-site
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ ROOT_DIR=$( git rev-parse --show-toplevel)
4
+
5
+ # shellcheck source=.env
6
+ set -o allexport
7
+ . $ROOT_DIR /.env
8
+ set +o allexport
9
+
10
+ export NODE_EXTRA_CA_CERTS=$ROOT_DIR /$BW_SSL_CERT
11
+
12
+ BW_COMMAND () {
13
+ bw " $@ "
14
+ }
15
+
16
+ if [[ -z " ${VAULT_IMPORT_FILE} " ]]; then
17
+ printf " No vault import file was specified. Skipping vault import...\n\n"
18
+
19
+ exit 0
20
+ fi
21
+
22
+ chmod +r $VAULT_IMPORT_FILE
23
+
24
+ export VAULT_HOST=$VAULT_HOST_URL :$VAULT_HOST_PORT
25
+
26
+ if [[ -z " ${VAULT_HOST_URL:- } " ]]; then
27
+ echo " VAULT_HOST_URL is not set, using local dev values"
28
+ export VAULT_HOST=' --api http://localhost:4000 --identity http://localhost:33656 --web-vault https://localhost:8080 --events http://localhost:46273'
29
+ fi
30
+
31
+ BW_COMMAND status
32
+
33
+ # Login to the vault
34
+ # shellcheck disable=SC2086 # we want to pass the server host url as a single argument
35
+ BW_COMMAND logout --quiet # In case there's an active outdated session (e.g. docker container was rebuilt)
36
+ BW_COMMAND config server $VAULT_HOST || true # no error if already configured
37
+
38
+ BW_COMMAND login " $VAULT_EMAIL " " $VAULT_PASSWORD " --nointeraction --quiet || true # no error if already logged in
39
+ BW_COMMAND sync || true # no error if already synced
40
+
41
+ # Unlock and set session token
42
+ export BW_SESSION=$(
43
+ BW_COMMAND unlock --passwordenv VAULT_PASSWORD --raw --nointeraction
44
+ )
45
+
46
+ printf " Importing...\n"
47
+ BW_COMMAND import bitwardenjson " ${VAULT_IMPORT_FILE} "
48
+
49
+ BW_COMMAND logout --quiet
You can’t perform that action at this time.
0 commit comments