#!/usr/bin/env bash

set -u

PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"

# shellcheck source=modules/passwords/bitwarden/module.sh
source "$PROJECT_ROOT/modules/passwords/bitwarden/module.sh"

test -f "$(module_bitwarden_config_path)"
test -f "$PROJECT_ROOT/modules/passwords/bitwarden/module.sh"

if [[ -f "$POSTINSTALL_BITWARDEN_FIREFOX_POLICIES_FILE" ]]; then
  grep -q '"base"' "$POSTINSTALL_BITWARDEN_FIREFOX_POLICIES_FILE"
fi

if [[ -f "$POSTINSTALL_BITWARDEN_CHROMIUM_POLICIES_FILE" ]]; then
  grep -q '"ExtensionInstallForcelist"' "$POSTINSTALL_BITWARDEN_CHROMIUM_POLICIES_FILE"
fi

printf 'Bitwarden module test OK\n'
