|
| 1 | +name: E2E Tests |
| 2 | + |
| 3 | +on: |
| 4 | + # For local testing with: act push -W .github/workflows/e2e-tests.yml |
| 5 | + push: |
| 6 | + branches-ignore: |
| 7 | + - "**" # Never runs on GitHub, only locally with act |
| 8 | + |
| 9 | + # For test.yml to call this workflow |
| 10 | + workflow_call: |
| 11 | + secrets: |
| 12 | + OP_CONNECT_CREDENTIALS: |
| 13 | + required: true |
| 14 | + OP_CONNECT_TOKEN: |
| 15 | + required: true |
| 16 | + OP_SERVICE_ACCOUNT_TOKEN: |
| 17 | + required: true |
| 18 | + VAULT: |
| 19 | + description: "1Password vault name or UUID" |
| 20 | + required: true |
| 21 | + |
| 22 | +jobs: |
| 23 | + test-service-account: |
| 24 | + name: Service Account (${{ matrix.os }}, ${{ matrix.version }}, export-env=${{ matrix.export-env }}) |
| 25 | + runs-on: ${{ matrix.os }} |
| 26 | + strategy: |
| 27 | + fail-fast: true |
| 28 | + matrix: |
| 29 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 30 | + version: [latest, 2.30.0] |
| 31 | + export-env: [true, false] |
| 32 | + steps: |
| 33 | + - name: Checkout |
| 34 | + uses: actions/checkout@v5 |
| 35 | + with: |
| 36 | + fetch-depth: 0 |
| 37 | + |
| 38 | + - name: Generate .env.tpl |
| 39 | + shell: bash |
| 40 | + run: | |
| 41 | + echo "FILE_SECRET=op://${{ secrets.VAULT }}/test-secret/password" > tests/.env.tpl |
| 42 | + echo "FILE_SECRET_IN_SECTION=op://${{ secrets.VAULT }}/test-secret/test-section/password" >> tests/.env.tpl |
| 43 | + echo "FILE_MULTILINE_SECRET=op://${{ secrets.VAULT }}/multiline-secret/notesPlain" >> tests/.env.tpl |
| 44 | +
|
| 45 | + - name: Configure Service account |
| 46 | + uses: ./configure |
| 47 | + with: |
| 48 | + service-account-token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} |
| 49 | + |
| 50 | + - name: Load secrets |
| 51 | + id: load_secrets |
| 52 | + uses: ./ |
| 53 | + with: |
| 54 | + version: ${{ matrix.version }} |
| 55 | + export-env: ${{ matrix.export-env }} |
| 56 | + env: |
| 57 | + SECRET: op://${{ secrets.VAULT }}/test-secret/password |
| 58 | + SECRET_IN_SECTION: op://${{ secrets.VAULT }}/test-secret/test-section/password |
| 59 | + MULTILINE_SECRET: op://${{ secrets.VAULT }}/multiline-secret/notesPlain |
| 60 | + OP_ENV_FILE: ./tests/.env.tpl |
| 61 | + |
| 62 | + - name: Assert test secret values [step output] |
| 63 | + if: ${{ !matrix.export-env }} |
| 64 | + shell: bash |
| 65 | + env: |
| 66 | + SECRET: ${{ steps.load_secrets.outputs.SECRET }} |
| 67 | + SECRET_IN_SECTION: ${{ steps.load_secrets.outputs.SECRET_IN_SECTION }} |
| 68 | + MULTILINE_SECRET: ${{ steps.load_secrets.outputs.MULTILINE_SECRET }} |
| 69 | + FILE_SECRET: ${{ steps.load_secrets.outputs.FILE_SECRET }} |
| 70 | + FILE_SECRET_IN_SECTION: ${{ steps.load_secrets.outputs.FILE_SECRET_IN_SECTION }} |
| 71 | + FILE_MULTILINE_SECRET: ${{ steps.load_secrets.outputs.FILE_MULTILINE_SECRET }} |
| 72 | + run: ./tests/assert-env-set.sh |
| 73 | + |
| 74 | + - name: Assert test secret values [exported env] |
| 75 | + if: ${{ matrix.export-env }} |
| 76 | + shell: bash |
| 77 | + run: ./tests/assert-env-set.sh |
| 78 | + |
| 79 | + - name: Remove secrets [exported env] |
| 80 | + if: ${{ matrix.export-env }} |
| 81 | + uses: ./ |
| 82 | + with: |
| 83 | + unset-previous: true |
| 84 | + |
| 85 | + - name: Assert removed secrets [exported env] |
| 86 | + if: ${{ matrix.export-env }} |
| 87 | + shell: bash |
| 88 | + run: ./tests/assert-env-unset.sh |
| 89 | + |
| 90 | + test-connect: |
| 91 | + name: Connect (ubuntu-latest, ${{ matrix.version }}, export-env=${{ matrix.export-env }}) |
| 92 | + runs-on: ubuntu-latest |
| 93 | + strategy: |
| 94 | + fail-fast: true |
| 95 | + matrix: |
| 96 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 97 | + version: [latest, 2.30.0] |
| 98 | + export-env: [true, false] |
| 99 | + steps: |
| 100 | + - name: Checkout |
| 101 | + uses: actions/checkout@v5 |
| 102 | + with: |
| 103 | + fetch-depth: 0 |
| 104 | + |
| 105 | + - name: Generate .env.tpl |
| 106 | + run: | |
| 107 | + mkdir -p tests |
| 108 | + echo "FILE_SECRET=op://${{ secrets.VAULT }}/test-secret/password" > tests/.env.tpl |
| 109 | + echo "FILE_SECRET_IN_SECTION=op://${{ secrets.VAULT }}/test-secret/test-section/password" >> tests/.env.tpl |
| 110 | + echo "FILE_MULTILINE_SECRET=op://${{ secrets.VAULT }}/multiline-secret/notesPlain" >> tests/.env.tpl |
| 111 | +
|
| 112 | + - name: Launch 1Password Connect instance |
| 113 | + env: |
| 114 | + OP_CONNECT_CREDENTIALS: ${{ secrets.OP_CONNECT_CREDENTIALS }} |
| 115 | + run: | |
| 116 | + echo "$OP_CONNECT_CREDENTIALS" > 1password-credentials.json |
| 117 | + docker compose -f tests/fixtures/docker-compose.yml up -d && sleep 10 |
| 118 | +
|
| 119 | + - name: Configure 1Password Connect |
| 120 | + uses: ./configure |
| 121 | + with: |
| 122 | + connect-host: http://localhost:8080 |
| 123 | + connect-token: ${{ secrets.OP_CONNECT_TOKEN }} |
| 124 | + |
| 125 | + - name: Load secrets |
| 126 | + id: load_secrets |
| 127 | + uses: ./ |
| 128 | + with: |
| 129 | + version: ${{ matrix.version }} |
| 130 | + export-env: ${{ matrix.export-env }} |
| 131 | + env: |
| 132 | + SECRET: op://${{ secrets.VAULT }}/test-secret/password |
| 133 | + SECRET_IN_SECTION: op://${{ secrets.VAULT }}/test-secret/test-section/password |
| 134 | + MULTILINE_SECRET: op://${{ secrets.VAULT }}/multiline-secret/notesPlain |
| 135 | + OP_ENV_FILE: ./tests/.env.tpl |
| 136 | + |
| 137 | + - name: Assert test secret values [step output] |
| 138 | + if: ${{ !matrix.export-env }} |
| 139 | + env: |
| 140 | + SECRET: ${{ steps.load_secrets.outputs.SECRET }} |
| 141 | + SECRET_IN_SECTION: ${{ steps.load_secrets.outputs.SECRET_IN_SECTION }} |
| 142 | + MULTILINE_SECRET: ${{ steps.load_secrets.outputs.MULTILINE_SECRET }} |
| 143 | + FILE_SECRET: ${{ steps.load_secrets.outputs.FILE_SECRET }} |
| 144 | + FILE_SECRET_IN_SECTION: ${{ steps.load_secrets.outputs.FILE_SECRET_IN_SECTION }} |
| 145 | + FILE_MULTILINE_SECRET: ${{ steps.load_secrets.outputs.FILE_MULTILINE_SECRET }} |
| 146 | + run: ./tests/assert-env-set.sh |
| 147 | + |
| 148 | + - name: Assert test secret values [exported env] |
| 149 | + if: ${{ matrix.export-env }} |
| 150 | + run: ./tests/assert-env-set.sh |
| 151 | + |
| 152 | + - name: Remove secrets [exported env] |
| 153 | + if: ${{ matrix.export-env }} |
| 154 | + uses: ./ |
| 155 | + with: |
| 156 | + unset-previous: true |
| 157 | + |
| 158 | + - name: Assert removed secrets [exported env] |
| 159 | + if: ${{ matrix.export-env }} |
| 160 | + run: ./tests/assert-env-unset.sh |
0 commit comments