-
Notifications
You must be signed in to change notification settings - Fork 7k
fix: Helm OCI repositories with custom CAs #8508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,10 +2,14 @@ package v1alpha1 | |
|
|
||
| import ( | ||
| fmt "fmt" | ||
| "io/ioutil" | ||
| "os" | ||
| "path" | ||
| "reflect" | ||
| "testing" | ||
| "time" | ||
|
|
||
| argocdcommon "github.com/argoproj/argo-cd/v2/common" | ||
| "k8s.io/utils/pointer" | ||
|
|
||
| "github.com/argoproj/gitops-engine/pkg/sync/common" | ||
|
|
@@ -2592,3 +2596,45 @@ func Test_validateGroupName(t *testing.T) { | |
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestGetCAPath(t *testing.T) { | ||
|
|
||
| temppath, err := ioutil.TempDir("", "argocd-cert-test") | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
|
Comment on lines
+2603
to
+2605
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. panic might be a little heavy-handed. Can we use
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should make a differentiation between the actual code path tested (use
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting, I'd always thought of Aside: there's a |
||
| cert, err := ioutil.ReadFile("../../../../test/fixture/certs/argocd-test-server.crt") | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
| err = ioutil.WriteFile(path.Join(temppath, "foo.example.com"), cert, 0666) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
| defer os.RemoveAll(temppath) | ||
| os.Setenv(argocdcommon.EnvVarTLSDataPath, temppath) | ||
| validcert := []string{ | ||
| "https://foo.example.com", | ||
| "oci://foo.example.com", | ||
| "foo.example.com", | ||
| } | ||
| invalidpath := []string{ | ||
| "https://bar.example.com", | ||
| "oci://bar.example.com", | ||
| "bar.example.com", | ||
| "ssh://foo.example.com", | ||
| "/some/invalid/thing", | ||
| "../another/invalid/thing", | ||
| "./also/invalid", | ||
| "$invalid/as/well", | ||
| } | ||
|
|
||
| for _, str := range validcert { | ||
| path := getCAPath(str) | ||
| assert.NotEmpty(t, path) | ||
| } | ||
| for _, str := range invalidpath { | ||
| path := getCAPath(str) | ||
| assert.Empty(t, path) | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.