Skip to content

Commit ad7269a

Browse files
indrorairbyKeyfactor
authored
feat: CyberArk Conjur PAM 1.0.0 (#1) (#2)
Co-authored-by: Matthew H. Irby <[email protected]> Co-authored-by: Keyfactor <[email protected]>
1 parent 12a0ccf commit ad7269a

37 files changed

+1582
-108
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Keyfactor Bootstrap Workflow
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
types: [opened, closed, synchronize, edited, reopened]
7+
push:
8+
create:
9+
branches:
10+
- 'release-*.*'
11+
12+
jobs:
13+
call-starter-workflow:
14+
uses: keyfactor/actions/.github/workflows/starter.yml@v4
15+
with:
16+
command_token_url: ${{ vars.DOCTOOL_COMMAND_TOKEN_URL }}
17+
command_hostname: ${{ vars.DOCTOOL_COMMAND_HOSTNAME }}
18+
command_base_api_path: ${{ vars.DOCTOOL_COMMAND_BASE_API_PATH}}
19+
secrets:
20+
token: ${{ secrets.V2BUILDTOKEN}}
21+
gpg_key: ${{ secrets.KF_GPG_PRIVATE_KEY }}
22+
gpg_pass: ${{ secrets.KF_GPG_PASSPHRASE }}
23+
scan_token: ${{ secrets.SAST_TOKEN }}
24+
entra_username: ${{ secrets.DOCTOOL_ENTRA_USERNAME }}
25+
entra_password: ${{ secrets.DOCTOOL_ENTRA_PASSWD }}
26+
command_client_id: ${{ secrets.DOCTOOL_COMMAND_CLIENT_ID }}
27+
command_client_secret: ${{ secrets.DOCTOOL_COMMAND_CLIENT_SECRET }}

.github/workflows/pull-request.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
run-name: Build and Test Solution - ${{ github.sha }}
2+
name: Build and Test Solution
3+
4+
on:
5+
pull_request:
6+
types: [opened, synchronize, reopened]
7+
8+
jobs:
9+
build-and-test-solution:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
dotnet-version: [ '8.0.x' ]
14+
steps:
15+
- name: Checkout Code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup .NET 8
19+
uses: actions/setup-dotnet@v4
20+
with:
21+
dotnet-version: '8.0.x'
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
26+
- name: Add Keyfactor NuGet Source
27+
run: dotnet nuget add source https://nuget.pkg.github.com/Keyfactor/index.json -n github -u ${{ github.actor }} -p ${{ secrets.V2BUILDTOKEN }} --store-password-in-clear-text
28+
29+
- name: Restore Dependencies
30+
run: dotnet restore
31+
32+
- name: Build solution
33+
run: dotnet build --no-restore --configuration Release
34+
35+
- name: Run Unit Tests
36+
run: dotnet test --configuration Release --no-build --logger "console;verbosity=detailed" --filter "Category!=Integration"
37+
38+
# load the .env.ci file from the integrations test folder
39+
- name: Load .env file
40+
uses: xom9ikk/dotenv@v2
41+
with:
42+
path: ./cyberark-conjur-pam.IntegrationTests
43+
mode: ci
44+
45+
# Pull Docker containers
46+
- name: Start Conjur Docker Container
47+
run: |
48+
docker compose -f quickstart/docker-compose.yml pull
49+
env:
50+
BUILDKIT_INLINE_CACHE: 1
51+
52+
- name: Start Conjur Docker Container
53+
run: |
54+
docker compose -f quickstart/docker-compose.yml up -d
55+
56+
# Verify that the API user can authenticate successfully
57+
- name: Wait for Conjur API to become ready
58+
uses: nick-fields/retry@v2
59+
with:
60+
timeout_minutes: 1
61+
max_attempts: 12
62+
retry_wait_seconds: 5
63+
command: ./quickstart/scripts/check-user-password.sh
64+
65+
- name: Run Integration Tests
66+
run: dotnet test --configuration Release --no-build --logger "console;verbosity=detailed" --filter "Category=Integration"
67+
68+
- name: Stop Conjur Docker Container
69+
if: always()
70+
run: |
71+
docker compose -f quickstart/docker-compose.yml down -v

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,3 +348,7 @@ MigrationBackup/
348348

349349
# Ionide (cross platform F# VS Code tools) working folder
350350
.ionide/
351+
352+
**/.env.*
353+
!**/.env.test.example
354+
!**/.env.ci

CONTRIBUTING.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
## Requirements
2+
- .NET 8 SDK and above
3+
- Docker (with Docker Compose) - Optional if not using the Quickstart environment
4+
5+
## Unit + Integration Tests
6+
7+
This project features unit and integration tests that can be run from any IDE or command line.
8+
9+
### Setting Up Integration Tests
10+
11+
Inside the `cyberark-conjur-pam.IntegrationTests` directory there is a [.env.test.example](./cyberark-conjur-pam.IntegrationTests/.env.test.example) file with the example environment variables. Copy the file to `.env.test` within the same directory. Fill out the environment variables. Make sure to configure `.env.test` to **always copy** to the output directory (this should already be set within the integration test's .csproj).
12+
13+
You are welcome to fill out the `.env.test` file to set these values to point to an existing CyberArk Conjur environment. Otherwise, these integration tests can also run against the Quickstart environment.
14+
15+
#### Running the Quickstart Environment
16+
17+
> This section can be skipped if you do not plan to run the integration tests against a local Docker environment.
18+
19+
The environment variables for the Quickstart environment are already defined in the `.env.ci` file under the `cyberark-conjur-pam.IntegrationTests` directory. Copy the `.env.ci` file to `.env.test`.
20+
21+
The Quickstart environment hosts a Docker Compose project that builds out a local CyberArk Conjur instance pre-populated with an admin account, a test user account, an example secret variable, and an example policy for the test user account to access the variable. The definition for the Quickstart environment is defined in [the quickstart directory](./quickstart/), which also includes the example policy defined under [the conf/policy](./quickstart/conf/policy) directory.
22+
23+
To run the Quickstart environment, run the following command from the project root:
24+
25+
```bash
26+
# Use docker-compose if you're on an older Docker version
27+
docker compose -f ./quickstart/docker-compose.yml up --build
28+
```
29+
30+
The output of the `conjur-init` container should provide information on how to access the local Conjur instance, including the credentials to use to access the instance.
31+
32+
```bash
33+
docker logs conjur-init
34+
35+
===========================================
36+
ConjurUrl: http://localhost:8080 (or your mapped port if different)
37+
AccountId: testConjurAccount
38+
39+
Admin Login: admin
40+
Admin API Key: [randomly generated admin api key]
41+
42+
Test User Login: TestUser@local
43+
Test User Password: Mypassw0rD2!
44+
Test User API Key: [randomly generated user api key]
45+
46+
Test Variable: local/MyTestVar
47+
Test Variable Value: MyTestSecretValue123
48+
===========================================
49+
```
50+
51+
The secret value for variable `local/MyTestVar` can be accessed by either the admin or the test user, with either their respective API keys or passwords.
52+
53+
The Quickstart environment can be cleaned up with the following command:
54+
55+
```bash
56+
docker compose -f ./quickstart/docker-compose.yml down -v
57+
```
58+
59+
### Running the Tests
60+
61+
Here are some command line scripts to run the test suites.
62+
63+
Restore project dependencies (optional):
64+
```bash
65+
dotnet restore
66+
```
67+
68+
Run integration and unit tests:
69+
```bash
70+
dotnet test
71+
```
72+
73+
Run just the unit tests:
74+
```bash
75+
dotnet test --filter "Category!=Integration"
76+
```
77+
78+
Run just the integration tests:
79+
```bash
80+
dotnet test --filter "Category=Integration"
81+
```

0 commit comments

Comments
 (0)