forked from keel-hq/keel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Verify that ports on registries work
- Loading branch information
1 parent
65606ca
commit 00c6887
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -332,6 +332,55 @@ func TestLookupHelmNoSecretsFound(t *testing.T) { | |
} | ||
} | ||
|
||
var secretDataPayloadWithPort = `{"https://example.com:3456":{"username":"user-x","password":"pass-x","email":"[email protected]","auth":"somethinghere"}}` | ||
|
||
func TestLookupWithPortedRegistry(t *testing.T) { | ||
imgRef, _ := image.Parse("https://example.com:3456/karolisr/webhook-demo:0.0.11") | ||
|
||
impl := &testutil.FakeK8sImplementer{ | ||
AvailablePods: &v1.PodList{ | ||
Items: []v1.Pod{ | ||
v1.Pod{ | ||
Spec: v1.PodSpec{ImagePullSecrets: []v1.LocalObjectReference{ | ||
v1.LocalObjectReference{ | ||
Name: "example.com", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
AvailableSecret: &v1.Secret{ | ||
Data: map[string][]byte{ | ||
dockerConfigKey: []byte(secretDataPayloadWithPort), | ||
}, | ||
Name: "example.com", | ||
Type: v1.SecretTypeDockercfg, | ||
}, | ||
} | ||
|
||
getter := NewGetter(impl, nil) | ||
|
||
trackedImage := &types.TrackedImage{ | ||
Image: imgRef, | ||
Namespace: "default", | ||
Secrets: []string{"example.com"}, | ||
} | ||
|
||
creds, err := getter.Get(trackedImage) | ||
if err != nil { | ||
t.Errorf("failed to get creds: %s", err) | ||
} | ||
|
||
if creds.Username != "user-x" { | ||
t.Errorf("unexpected username: %s", creds.Username) | ||
} | ||
|
||
if creds.Password != "pass-x" { | ||
t.Errorf("unexpected pass: %s", creds.Password) | ||
} | ||
} | ||
|
||
func Test_decodeBase64Secret(t *testing.T) { | ||
type args struct { | ||
authSecret string | ||
|
@@ -404,6 +453,12 @@ func Test_hostname(t *testing.T) { | |
want: "quay.io", | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "withport", | ||
args: args{registry: "https://example.com:3456"}, | ||
want: "example.com", | ||
wantErr: false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
|