Skip to content

Commit

Permalink
Verify that ports on registries work
Browse files Browse the repository at this point in the history
  • Loading branch information
stickycode committed Sep 27, 2018
1 parent 65606ca commit 00c6887
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions secrets/secrets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 00c6887

Please sign in to comment.