Skip to content

Commit 11a44a8

Browse files
authored
Merge branch 'main' into renovate/github.com-jedib0t-go-pretty-v6-6.x
2 parents 7be12a2 + 0bda4bb commit 11a44a8

Some content is hidden

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

62 files changed

+7999
-834
lines changed

.github/workflows/cli-build_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
build:
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v5
20+
- uses: actions/checkout@v6
2121

2222
- name: Set up Go
2323
uses: actions/setup-go@v6

.github/workflows/go-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
name: lint
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v5
20+
- uses: actions/checkout@v6
2121
- uses: actions/setup-go@v6
2222
with:
2323
go-version-file: 'go.mod'

.github/workflows/integration-test.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@ jobs:
1313
integration-tests:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v5
16+
- uses: actions/checkout@v6
1717

1818
- name: Set up Go
1919
uses: actions/setup-go@v6
2020
with:
2121
go-version-file: 'go.mod'
2222

23+
- name: Build CLI
24+
run: make build-cli
25+
2326
- name: Run Integration Tests
2427
env:
2528
OMS_PORTAL_API_KEY: ${{ secrets.OMS_PORTAL_API_KEY }}

.github/workflows/service-build_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
build:
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v5
20+
- uses: actions/checkout@v6
2121

2222
- name: Set up Go
2323
uses: actions/setup-go@v6

.github/workflows/tag-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
needs: integration-tests
1919
steps:
20-
- uses: actions/checkout@v5
20+
- uses: actions/checkout@v6
2121
with:
2222
fetch-tags: true
2323
fetch-depth: 0

.github/workflows/update-docs-and-licenses.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- name: Checkout Code
20-
uses: actions/checkout@v5
20+
uses: actions/checkout@v6
2121
with:
2222
# on push to main, use main; on PR, check out the PR head
2323
ref: ${{ github.event.pull_request.head.ref || github.ref }}

NOTICE

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,23 @@ Version: v3.5.1
99
License: MIT
1010
License URL: https://github.com/blang/semver/blob/v3.5.1/LICENSE
1111

12+
----------
13+
Module: github.com/clipperhouse/stringish
14+
Version: v0.1.1
15+
License: MIT
16+
License URL: https://github.com/clipperhouse/stringish/blob/v0.1.1/LICENSE
17+
1218
----------
1319
Module: github.com/clipperhouse/uax29/v2
14-
Version: v2.2.0
20+
Version: v2.3.0
1521
License: MIT
16-
License URL: https://github.com/clipperhouse/uax29/blob/v2.2.0/LICENSE
22+
License URL: https://github.com/clipperhouse/uax29/blob/v2.3.0/LICENSE
1723

1824
----------
1925
Module: github.com/codesphere-cloud/cs-go/pkg/io
20-
Version: v0.14.0
26+
Version: v0.14.1
2127
License: Apache-2.0
22-
License URL: https://github.com/codesphere-cloud/cs-go/blob/v0.14.0/LICENSE
28+
License URL: https://github.com/codesphere-cloud/cs-go/blob/v0.14.1/LICENSE
2329

2430
----------
2531
Module: github.com/codesphere-cloud/oms/internal/tmpl
@@ -71,9 +77,9 @@ License URL: https://github.com/inconshreveable/go-update/blob/8152e7eb6ccf/inte
7177

7278
----------
7379
Module: github.com/jedib0t/go-pretty/v6
74-
Version: v6.7.2
80+
Version: v6.7.3
7581
License: MIT
76-
License URL: https://github.com/jedib0t/go-pretty/blob/v6.7.2/LICENSE
82+
License URL: https://github.com/jedib0t/go-pretty/blob/v6.7.3/LICENSE
7783

7884
----------
7985
Module: github.com/mattn/go-runewidth
@@ -113,9 +119,9 @@ License URL: https://github.com/spf13/pflag/blob/v1.0.10/LICENSE
113119

114120
----------
115121
Module: github.com/stretchr/objx
116-
Version: v0.5.2
122+
Version: v0.5.3
117123
License: MIT
118-
License URL: https://github.com/stretchr/objx/blob/v0.5.2/LICENSE
124+
License URL: https://github.com/stretchr/objx/blob/v0.5.3/LICENSE
119125

120126
----------
121127
Module: github.com/stretchr/testify
@@ -137,21 +143,21 @@ License URL: https://github.com/ulikunitz/xz/blob/v0.5.15/LICENSE
137143

138144
----------
139145
Module: golang.org/x/crypto
140-
Version: v0.42.0
146+
Version: v0.45.0
141147
License: BSD-3-Clause
142-
License URL: https://cs.opensource.google/go/x/crypto/+/v0.42.0:LICENSE
148+
License URL: https://cs.opensource.google/go/x/crypto/+/v0.45.0:LICENSE
143149

144150
----------
145151
Module: golang.org/x/oauth2
146-
Version: v0.30.0
152+
Version: v0.33.0
147153
License: BSD-3-Clause
148-
License URL: https://cs.opensource.google/go/x/oauth2/+/v0.30.0:LICENSE
154+
License URL: https://cs.opensource.google/go/x/oauth2/+/v0.33.0:LICENSE
149155

150156
----------
151157
Module: golang.org/x/text
152-
Version: v0.29.0
158+
Version: v0.31.0
153159
License: BSD-3-Clause
154-
License URL: https://cs.opensource.google/go/x/text/+/v0.29.0:LICENSE
160+
License URL: https://cs.opensource.google/go/x/text/+/v0.31.0:LICENSE
155161

156162
----------
157163
Module: gopkg.in/yaml.v3

cli/cmd/api_key_integration_test.go

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ package cmd_test
99
import (
1010
"fmt"
1111
"os"
12+
"os/exec"
13+
"strings"
1214
"time"
1315

1416
. "github.com/onsi/ginkgo/v2"
@@ -62,7 +64,11 @@ var _ = Describe("API Key Integration Tests", func() {
6264
},
6365
}
6466

67+
GinkgoWriter.Printf("Attempting to register API key for owner: %s at API: %s\n", registerCmd.Opts.Owner, os.Getenv("OMS_PORTAL_API"))
6568
newKey, err := registerCmd.Register(portalClient)
69+
if err != nil {
70+
GinkgoWriter.Printf("Registration failed: %v\n", err)
71+
}
6672
Expect(err).To(BeNil(), "API key registration should succeed")
6773
Expect(newKey).NotTo(BeNil(), "Register should return the created API key")
6874

@@ -100,7 +106,12 @@ var _ = Describe("API Key Integration Tests", func() {
100106
},
101107
}
102108

109+
GinkgoWriter.Printf("[DEBUG] Attempting to register API key for owner: %s, org: %s at API: %s\n",
110+
testOwner, testOrg, os.Getenv("OMS_PORTAL_API"))
103111
newKey, err := registerCmd.Register(portalClient)
112+
if err != nil {
113+
GinkgoWriter.Printf("[ERROR] Registration failed: %v\n", err)
114+
}
104115
Expect(err).To(BeNil(), "API key registration should succeed")
105116
Expect(newKey).NotTo(BeNil(), "Register should return the created API key")
106117

@@ -217,4 +228,107 @@ var _ = Describe("API Key Integration Tests", func() {
217228
Expect(err.Error()).To(ContainSubstring("invalid date format"))
218229
})
219230
})
231+
232+
Describe("Old API Key Detection and Warning", func() {
233+
var (
234+
cliPath = "../../oms-cli"
235+
)
236+
237+
Context("when using a 22-character old API key format", func() {
238+
It("should detect the old format and attempt to upgrade", func() {
239+
cmd := exec.Command(cliPath, "version")
240+
cmd.Env = append(os.Environ(),
241+
"OMS_PORTAL_API_KEY=fakeapikeywith22charsa", // 22 characters
242+
"OMS_PORTAL_API=http://localhost:3000/api",
243+
)
244+
245+
output, err := cmd.CombinedOutput()
246+
outputStr := string(output)
247+
if err != nil {
248+
GinkgoWriter.Printf("Command error: %v, Output: %s\n", err, outputStr)
249+
}
250+
251+
Expect(outputStr).To(ContainSubstring("OMS CLI version"))
252+
})
253+
})
254+
255+
Context("when using a new long-format API key", func() {
256+
It("should not show any warning", func() {
257+
cmd := exec.Command(cliPath, "version")
258+
cmd.Env = append(os.Environ(),
259+
"OMS_PORTAL_API_KEY=fake-api-key",
260+
"OMS_PORTAL_API=http://localhost:3000/api",
261+
)
262+
263+
output, err := cmd.CombinedOutput()
264+
outputStr := string(output)
265+
if err != nil {
266+
GinkgoWriter.Printf("Command error: %v, Output: %s\n", err, outputStr)
267+
}
268+
269+
Expect(outputStr).To(ContainSubstring("OMS CLI version"))
270+
Expect(outputStr).NotTo(ContainSubstring("old API key"))
271+
Expect(outputStr).NotTo(ContainSubstring("Failed to upgrade"))
272+
})
273+
})
274+
275+
Context("when using a 22-character key with list api-keys command", func() {
276+
It("should attempt the upgrade and handle the error gracefully", func() {
277+
cmd := exec.Command(cliPath, "list", "api-keys")
278+
cmd.Env = append(os.Environ(),
279+
"OMS_PORTAL_API_KEY=fakeapikeywith22charsa", // 22 characters (old format)
280+
"OMS_PORTAL_API=http://localhost:3000/api",
281+
)
282+
283+
output, err := cmd.CombinedOutput()
284+
outputStr := string(output)
285+
286+
Expect(err).To(HaveOccurred())
287+
288+
hasWarning := strings.Contains(outputStr, "old API key") ||
289+
strings.Contains(outputStr, "Failed to upgrade") ||
290+
strings.Contains(outputStr, "Unauthorized")
291+
292+
Expect(hasWarning).To(BeTrue(),
293+
"Should contain warning about old key or auth failure. Got: "+outputStr)
294+
})
295+
})
296+
297+
Context("when checking key length detection", func() {
298+
It("should correctly identify 22-character old format", func() {
299+
oldKey := "fakeapikeywith22charsa"
300+
Expect(len(oldKey)).To(Equal(22))
301+
})
302+
303+
It("should correctly identify new long format", func() {
304+
newKey := "4hBieJRj2pWeB9qKJ9wQGE3CrcldLnLwP8fz6qutMjkf1n1"
305+
Expect(len(newKey)).NotTo(Equal(22))
306+
Expect(len(newKey)).To(BeNumerically(">", 22))
307+
})
308+
})
309+
})
310+
311+
Describe("PreRun Hook Execution", func() {
312+
var (
313+
cliPath = "../../oms-cli"
314+
)
315+
316+
Context("when running any OMS command", func() {
317+
It("should execute the PreRun hook", func() {
318+
cmd := exec.Command(cliPath, "version")
319+
cmd.Env = append(os.Environ(),
320+
"OMS_PORTAL_API_KEY=valid-key-format-short",
321+
"OMS_PORTAL_API=http://localhost:3000/api",
322+
)
323+
324+
output, err := cmd.CombinedOutput()
325+
outputStr := string(output)
326+
if err != nil {
327+
GinkgoWriter.Printf("Command error: %v, Output: %s\n", err, outputStr)
328+
}
329+
330+
Expect(outputStr).To(ContainSubstring("OMS CLI version"))
331+
})
332+
})
333+
})
220334
})

0 commit comments

Comments
 (0)