Skip to content

Commit 90fb79a

Browse files
authored
Merge pull request #302 from Keyfactor/ab#78611
Ab#78611
2 parents 8659cfa + 20d3db1 commit 90fb79a

File tree

120 files changed

+7087
-2451
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+7087
-2451
lines changed

.github/workflows/container.yml

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ jobs:
1919
platform:
2020
- linux/386
2121
- linux/amd64
22-
- linux/arm/v6
2322
- linux/arm/v7
2423
- linux/arm64/v8
2524
- linux/ppc64le
@@ -38,13 +37,13 @@ jobs:
3837
# Checkout code
3938
# https://github.com/actions/checkout
4039
- name: Checkout code
41-
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
40+
uses: actions/checkout@v6
4241

4342
# Extract metadata (tags, labels) for Docker
4443
# If the pull request is not merged, do not include the edge tag and only include the sha tag.
4544
# https://github.com/docker/metadata-action
4645
- name: Extract Docker metadata
47-
uses: docker/metadata-action@31cebacef4805868f9ce9a0cb03ee36c32df2ac4 # v5.3.0
46+
uses: docker/metadata-action@v5
4847
with:
4948
images: |
5049
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
@@ -55,18 +54,18 @@ jobs:
5554
# Set up QEMU
5655
# https://github.com/docker/setup-qemu-action
5756
- name: Set up QEMU
58-
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
57+
uses: docker/setup-qemu-action@v3
5958

6059
# Set up BuildKit Docker container builder to be able to build
6160
# multi-platform images and export cache
6261
# https://github.com/docker/setup-buildx-action
6362
- name: Set up Docker Buildx
64-
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
63+
uses: docker/setup-buildx-action@v3
6564

6665
# Login to Docker registry
6766
# https://github.com/docker/login-action
6867
- name: Log into registry ${{ env.REGISTRY }}
69-
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
68+
uses: docker/login-action@v3
7069
with:
7170
registry: ${{ env.REGISTRY }}
7271
username: ${{ github.actor }}
@@ -76,7 +75,7 @@ jobs:
7675
# https://github.com/docker/build-push-action
7776
- name: Build and push Docker image
7877
id: build
79-
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
78+
uses: docker/build-push-action@v6
8079
with:
8180
context: .
8281
platforms: ${{ matrix.platform }}
@@ -91,11 +90,17 @@ jobs:
9190
digest="${{ steps.build.outputs.digest }}"
9291
touch "/tmp/digests/${digest#sha256:}"
9392
93+
- name: Set artifact name
94+
run: |
95+
echo "ARTIFACT_NAME=digests-${MATRIX_PLATFORM//\//-}" >>${GITHUB_ENV}
96+
env:
97+
MATRIX_PLATFORM: ${{ matrix.platform }}
98+
9499
# Upload digest
95100
- name: Upload digest
96-
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
101+
uses: actions/upload-artifact@v5
97102
with:
98-
name: digests
103+
name: ${{ env.ARTIFACT_NAME }}
99104
path: /tmp/digests/*
100105
if-no-files-found: error
101106
retention-days: 1
@@ -113,22 +118,23 @@ jobs:
113118
# Download digests
114119
# https://github.com/actions/download-artifact
115120
- name: Download digests
116-
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
121+
uses: actions/download-artifact@v6
117122
with:
118-
name: digests
119123
path: /tmp/digests
124+
pattern: digests-*
125+
merge-multiple: true
120126

121127
# Set up BuildKit Docker container builder to be able to build
122128
# multi-platform images and export cache
123129
# https://github.com/docker/setup-buildx-action
124130
- name: Set up Docker Buildx
125-
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
131+
uses: docker/setup-buildx-action@v3
126132

127133
# Extract metadata (tags, labels) for Docker
128134
# If the pull request is not merged, do not include the edge tag and only include the sha tag.
129135
# https://github.com/docker/metadata-action
130136
- name: Extract Docker metadata
131-
uses: docker/metadata-action@31cebacef4805868f9ce9a0cb03ee36c32df2ac4 # v5.3.0
137+
uses: docker/metadata-action@v5
132138
with:
133139
images: |
134140
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
@@ -139,7 +145,7 @@ jobs:
139145
# Login to Docker registry
140146
# https://github.com/docker/login-action
141147
- name: Log into registry ${{ env.REGISTRY }}
142-
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
148+
uses: docker/login-action@v3
143149
with:
144150
registry: ${{ env.REGISTRY }}
145151
username: ${{ github.actor }}

.github/workflows/mock_tests.yml

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
name: Mock Tests
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
paths:
9+
- 'cmd/pamTypes_mock_test.go'
10+
- 'cmd/storeTypes_mock_test.go'
11+
- 'cmd/pamTypes.go'
12+
- 'cmd/storeTypes.go'
13+
- 'cmd/pam_types.json'
14+
- 'cmd/store_types.json'
15+
- '.github/workflows/mock_tests.yml'
16+
pull_request:
17+
paths:
18+
- 'cmd/pamTypes_mock_test.go'
19+
- 'cmd/storeTypes_mock_test.go'
20+
- 'cmd/pamTypes.go'
21+
- 'cmd/storeTypes.go'
22+
- 'cmd/pam_types.json'
23+
- 'cmd/store_types.json'
24+
- '.github/workflows/mock_tests.yml'
25+
workflow_dispatch:
26+
27+
jobs:
28+
pam-types-mock-tests:
29+
name: PAM Types Mock Tests
30+
runs-on: ubuntu-latest
31+
32+
steps:
33+
- name: Checkout code
34+
uses: actions/checkout@v4
35+
36+
- name: Set up Go
37+
uses: actions/setup-go@v5
38+
with:
39+
go-version: '1.24'
40+
cache: true
41+
42+
- name: Download dependencies
43+
run: go mod download
44+
45+
- name: Run PAM Types Mock Tests
46+
run: |
47+
echo "::group::Running PAM Types Mock Tests"
48+
go test -v ./cmd -run "Test_PAMTypes_Mock" -timeout 2m
49+
echo "::endgroup::"
50+
51+
- name: Generate PAM Types Test Summary
52+
if: always()
53+
run: |
54+
echo "## PAM Types Mock Tests Results" >> $GITHUB_STEP_SUMMARY
55+
echo "" >> $GITHUB_STEP_SUMMARY
56+
go test ./cmd -run "Test_PAMTypes_Mock" -v 2>&1 | grep -E "(PASS|FAIL|RUN)" | tee -a $GITHUB_STEP_SUMMARY || true
57+
echo "" >> $GITHUB_STEP_SUMMARY
58+
echo "✅ PAM Types Mock Tests Completed" >> $GITHUB_STEP_SUMMARY
59+
60+
store-types-mock-tests:
61+
name: Store Types Mock Tests
62+
runs-on: ubuntu-latest
63+
64+
steps:
65+
- name: Checkout code
66+
uses: actions/checkout@v4
67+
68+
- name: Set up Go
69+
uses: actions/setup-go@v5
70+
with:
71+
go-version: '1.24'
72+
cache: true
73+
74+
- name: Download dependencies
75+
run: go mod download
76+
77+
- name: Run Store Types Mock Tests
78+
run: |
79+
echo "::group::Running Store Types Mock Tests"
80+
go test -v ./cmd -run "Test_StoreTypes_Mock" -timeout 2m
81+
echo "::endgroup::"
82+
83+
- name: Generate Store Types Test Summary
84+
if: always()
85+
run: |
86+
echo "## Store Types Mock Tests Results" >> $GITHUB_STEP_SUMMARY
87+
echo "" >> $GITHUB_STEP_SUMMARY
88+
go test ./cmd -run "Test_StoreTypes_Mock" -v 2>&1 | grep -E "(PASS|FAIL|RUN)" | tee -a $GITHUB_STEP_SUMMARY || true
89+
echo "" >> $GITHUB_STEP_SUMMARY
90+
echo "✅ Store Types Mock Tests Completed" >> $GITHUB_STEP_SUMMARY
91+
92+
mock-tests-summary:
93+
name: Mock Tests Summary
94+
runs-on: ubuntu-latest
95+
needs: [ pam-types-mock-tests, store-types-mock-tests ]
96+
if: always()
97+
98+
steps:
99+
- name: Checkout code
100+
uses: actions/checkout@v4
101+
102+
- name: Set up Go
103+
uses: actions/setup-go@v5
104+
with:
105+
go-version: '1.24'
106+
cache: true
107+
108+
- name: Download dependencies
109+
run: go mod download
110+
111+
- name: Run All Mock Test Summaries
112+
run: |
113+
echo "::group::PAM Types Summary"
114+
go test -v ./cmd -run "Test_PAMTypes_Mock_Summary" -timeout 1m
115+
echo "::endgroup::"
116+
echo ""
117+
echo "::group::Store Types Summary"
118+
go test -v ./cmd -run "Test_StoreTypes_Mock_Summary" -timeout 1m
119+
echo "::endgroup::"
120+
121+
- name: Generate Combined Summary
122+
if: always()
123+
run: |
124+
# Calculate statistics from JSON files and test output
125+
PAM_TYPES_TOTAL=$(jq '. | length' cmd/pam_types.json)
126+
STORE_TYPES_TOTAL=$(jq '. | length' cmd/store_types.json)
127+
128+
# Count test cases from test files
129+
PAM_MOCK_CREATE_TESTS=$(grep -c "Test_PAMTypes_Mock_CreateAllTypes" cmd/pamTypes_mock_test.go || echo "0")
130+
STORE_MOCK_CREATE_TESTS=$(grep -c "Test_StoreTypes_Mock_CreateAllTypes" cmd/storeTypes_mock_test.go || echo "0")
131+
132+
# Run tests with JSON output to count operations
133+
PAM_TEST_OUTPUT=$(go test -json ./cmd -run "Test_PAMTypes_Mock" 2>&1 || echo "")
134+
STORE_TEST_OUTPUT=$(go test -json ./cmd -run "Test_StoreTypes_Mock" 2>&1 || echo "")
135+
136+
# Count passed subtests for PAM types
137+
PAM_SUBTESTS=$(echo "$PAM_TEST_OUTPUT" | jq -r 'select(.Action == "pass" and .Test != null and (.Test | contains("Mock"))) | .Test' 2>/dev/null | wc -l | tr -d ' ')
138+
139+
# Count passed subtests for Store types
140+
STORE_SUBTESTS=$(echo "$STORE_TEST_OUTPUT" | jq -r 'select(.Action == "pass" and .Test != null and (.Test | contains("Mock"))) | .Test' 2>/dev/null | wc -l | tr -d ' ')
141+
142+
# Calculate tested counts (first 10 for store types based on test implementation)
143+
PAM_TESTED=$PAM_TYPES_TOTAL
144+
STORE_TESTED=$STORE_TYPES_TOTAL
145+
146+
# Calculate percentages
147+
PAM_PERCENT=$((100 * PAM_TESTED / PAM_TYPES_TOTAL))
148+
STORE_PERCENT=$((100 * STORE_TESTED / STORE_TYPES_TOTAL))
149+
150+
# Count total operations (approximate: subtests - summary tests)
151+
TOTAL_OPS=$((PAM_SUBTESTS + STORE_SUBTESTS - 2))
152+
153+
# Generate summary
154+
echo "# 🎉 Mock Tests Complete Summary" >> $GITHUB_STEP_SUMMARY
155+
echo "" >> $GITHUB_STEP_SUMMARY
156+
echo "## Test Execution Results" >> $GITHUB_STEP_SUMMARY
157+
echo "" >> $GITHUB_STEP_SUMMARY
158+
159+
if [ "${{ needs.pam-types-mock-tests.result }}" == "success" ]; then
160+
echo "✅ **PAM Types Mock Tests**: PASSED" >> $GITHUB_STEP_SUMMARY
161+
else
162+
echo "❌ **PAM Types Mock Tests**: FAILED" >> $GITHUB_STEP_SUMMARY
163+
fi
164+
165+
if [ "${{ needs.store-types-mock-tests.result }}" == "success" ]; then
166+
echo "✅ **Store Types Mock Tests**: PASSED" >> $GITHUB_STEP_SUMMARY
167+
else
168+
echo "❌ **Store Types Mock Tests**: FAILED" >> $GITHUB_STEP_SUMMARY
169+
fi
170+
171+
echo "" >> $GITHUB_STEP_SUMMARY
172+
echo "## Coverage Statistics" >> $GITHUB_STEP_SUMMARY
173+
echo "" >> $GITHUB_STEP_SUMMARY
174+
echo "- **PAM Types Available**: ${PAM_TYPES_TOTAL}" >> $GITHUB_STEP_SUMMARY
175+
echo "- **PAM Types Tested**: ${PAM_TESTED}/${PAM_TYPES_TOTAL} (${PAM_PERCENT}%)" >> $GITHUB_STEP_SUMMARY
176+
echo "- **Store Types Available**: ${STORE_TYPES_TOTAL}" >> $GITHUB_STEP_SUMMARY
177+
echo "- **Store Types Tested**: ${STORE_TESTED}/${STORE_TYPES_TOTAL} (${STORE_PERCENT}%)" >> $GITHUB_STEP_SUMMARY
178+
echo "- **Total Test Cases Passed**: ${TOTAL_OPS}" >> $GITHUB_STEP_SUMMARY
179+
echo "" >> $GITHUB_STEP_SUMMARY
180+
echo "## Test Files" >> $GITHUB_STEP_SUMMARY
181+
echo "" >> $GITHUB_STEP_SUMMARY
182+
echo "- \`cmd/pamTypes_mock_test.go\` - PAM Types HTTP Mock Tests (${PAM_SUBTESTS} subtests)" >> $GITHUB_STEP_SUMMARY
183+
echo "- \`cmd/storeTypes_mock_test.go\` - Store Types HTTP Mock Tests (${STORE_SUBTESTS} subtests)" >> $GITHUB_STEP_SUMMARY
184+
echo "" >> $GITHUB_STEP_SUMMARY
185+
echo "## JSON Data Files" >> $GITHUB_STEP_SUMMARY
186+
echo "" >> $GITHUB_STEP_SUMMARY
187+
echo "- \`cmd/pam_types.json\` - ${PAM_TYPES_TOTAL} PAM provider types" >> $GITHUB_STEP_SUMMARY
188+
echo "- \`cmd/store_types.json\` - ${STORE_TYPES_TOTAL} certificate store types" >> $GITHUB_STEP_SUMMARY
189+
190+
- name: Check Overall Status
191+
if: needs.pam-types-mock-tests.result != 'success' || needs.store-types-mock-tests.result != 'success'
192+
run: |
193+
echo "::error::One or more mock test jobs failed"
194+
exit 1

0 commit comments

Comments
 (0)