Skip to content

Commit 5c16b02

Browse files
Merge remote-tracking branch 'origin/dev' into v2
2 parents 59ffcf8 + 7a5d2ac commit 5c16b02

File tree

74 files changed

+670
-3201
lines changed

Some content is hidden

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

74 files changed

+670
-3201
lines changed

.github/workflows/accessTests.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ on:
1212
concurrency:
1313
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.ref }}
1414
cancel-in-progress: true
15+
permissions:
16+
id-token: write
17+
contents: read
1518
jobs:
1619
Access-Tests:
1720
if: contains(github.event.pull_request.labels.*.name, 'safe to test') || github.event_name == 'push'
@@ -35,5 +38,12 @@ jobs:
3538
with:
3639
RTLIC: ${{ secrets.RTLIC }}
3740

41+
- name: Get ID Token and Exchange Token
42+
shell: bash
43+
run: |
44+
ID_TOKEN=$(curl -sLS -H "User-Agent: actions/oidc-client" -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
45+
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=jfrog-github" | jq .value | tr -d '"')
46+
echo "JFROG_CLI_OIDC_EXCHANGE_TOKEN_ID=${ID_TOKEN}" >> $GITHUB_ENV
47+
3848
- name: Run Access tests
3949
run: go test -v github.com/jfrog/jfrog-cli --timeout 0 --test.access --jfrog.url=http://127.0.0.1:8082 --jfrog.adminToken=${{ env.JFROG_TESTS_LOCAL_ACCESS_TOKEN }}

.github/workflows/lifecycleTests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
name: Lifecycle Tests
2+
env:
3+
JFROG_CLI_LOG_LEVEL: DEBUG
24
on:
35
push:
46
branches:

.github/workflows/oidcTests.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# These Tests validate successful OIDC server configuration in the CLI.
2+
# After the server has been configured the CLI will ping the server to make sure we have access
3+
name: "Config OIDC test"
4+
on:
5+
push:
6+
branches:
7+
- '**'
8+
tags-ignore:
9+
- '**'
10+
# Triggers the workflow on labeled PRs only.
11+
pull_request_target:
12+
types: [ labeled ]
13+
# Ensures that only the latest commit is running for each PR at a time.
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
env:
19+
JFROG_CLI_LOG_LEVEL: DEBUG
20+
21+
# Needed for OIDC
22+
permissions:
23+
id-token: write
24+
contents: read
25+
jobs:
26+
config-oidc:
27+
if: contains(github.event.pull_request.labels.*.name, 'safe to test') || github.event_name == 'push'
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
os: [ ubuntu-latest, macos-latest, windows-latest ]
32+
runs-on: ${{ matrix.os }}
33+
steps:
34+
- name: Setup Go with cache
35+
uses: jfrog/.github/actions/install-go-with-cache@main
36+
37+
- name: Checkout the repository
38+
uses: actions/checkout@v4
39+
with:
40+
ref: ${{ github.event.pull_request.head.sha }}
41+
42+
- name: Build CLI
43+
run: |
44+
if [ "$RUNNER_OS" == "Windows" ]; then
45+
./build/build.bat
46+
else
47+
./build/build.sh
48+
fi
49+
shell: bash
50+
51+
- name: Get ID Token from GitHub
52+
shell: bash
53+
run: |
54+
ID_TOKEN=$(curl -sLS -H "User-Agent: actions/oidc-client" -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
55+
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=jfrog-github" | jq .value | tr -d '"')
56+
echo "JFROG_CLI_OIDC_EXCHANGE_TOKEN_ID=${ID_TOKEN}" >> $GITHUB_ENV
57+
58+
- name: Run config command
59+
shell: bash
60+
run: |
61+
if [ "$RUNNER_OS" == "Windows" ]; then
62+
./jfrog.exe c add --url=https://ecosysjfrog.jfrog.io --oidc-provider-name=setup-jfrog-cli-test --interactive=false
63+
else
64+
./jf c add --url=https://ecosysjfrog.jfrog.io --oidc-provider-name=setup-jfrog-cli-test --interactive=false
65+
fi
66+
67+
- name: Ping the server to validate successful OIDC configuration
68+
shell: bash
69+
run: |
70+
if [ "$RUNNER_OS" == "Windows" ]; then
71+
./jfrog.exe rt ping
72+
else
73+
./jf rt ping
74+
fi

.github/workflows/scriptTests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
suite:
2323
- os: "ubuntu-latest"
2424

25-
- os: "ubuntu-20.04"
25+
- os: "ubuntu-22.04"
2626

2727
- os: "macos-latest"
2828

.github/workflows/transferTests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
if: contains(github.event.pull_request.labels.*.name, 'safe to test') || github.event_name == 'push'
4444
name: artifactory-6
4545
# Fixed runner image to set the java tools needed for artifactory 6
46-
runs-on: ubuntu-20.04
46+
runs-on: ubuntu-22.04
4747
steps:
4848
- name: Checkout code
4949
uses: actions/checkout@v4

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ node("docker-ubuntu20-xlarge") {
3131
repo = 'jfrog-cli'
3232
sh 'rm -rf temp'
3333
sh 'mkdir temp'
34-
def goRoot = tool 'go-1.23.4'
34+
def goRoot = tool 'go-1.23.7'
3535
env.GOROOT="$goRoot"
3636
env.PATH+=":${goRoot}/bin:/tmp/node-${nodeVersion}-linux-x64/bin"
3737
env.GO111MODULE="on"

access_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"encoding/json"
55
"fmt"
66
"net/http"
7+
"os"
8+
"regexp"
79
"testing"
810

911
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
@@ -269,6 +271,35 @@ func TestAccessTokenCreate(t *testing.T) {
269271
}
270272
}
271273

274+
func TestOidcExchangeToken(t *testing.T) {
275+
// If token ID was not provided by the CI, skip this test
276+
if os.Getenv(coreutils.OidcExchangeTokenId) == "" {
277+
t.Skip("No token ID available in environment,skipping test")
278+
return
279+
}
280+
accessCli = coreTests.NewJfrogCli(execMain, "jfrog", "")
281+
var testCases = []struct {
282+
name string
283+
args []string
284+
expectedOutput string
285+
}{
286+
{
287+
name: "Successful exchange",
288+
args: []string{"eot", "setup-jfrog-cli-test", "--url=https://ecosysjfrog.jfrog.io"},
289+
expectedOutput: `\{ AccessToken: [^\s]+ Username: [^\s]+ \}`,
290+
},
291+
}
292+
293+
for _, testCase := range testCases {
294+
t.Run(testCase.name, func(t *testing.T) {
295+
output := accessCli.RunCliCmdWithOutput(t, testCase.args...)
296+
matched, err := regexp.MatchString(testCase.expectedOutput, output)
297+
assert.NoError(t, err)
298+
assert.True(t, matched, "Output did not match expected pattern")
299+
})
300+
}
301+
}
302+
272303
func assertNotEmptyIfExpected(t *testing.T, expected bool, output string) {
273304
if expected {
274305
assert.NotEmpty(t, output)

0 commit comments

Comments
 (0)