Verify that ports on registries work
parent
65606ca693
commit
00c68877f2
|
@ -332,6 +332,55 @@ func TestLookupHelmNoSecretsFound(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
var secretDataPayloadWithPort = `{"https://example.com:3456":{"username":"user-x","password":"pass-x","email":"karolis.rusenas@gmail.com","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) {
|
||||
|
|
Loading…
Reference in New Issue