Merge pull request #897 from ManoManoTech/panic-oci-auth

Handle nil OCI authenticator with malformed registry
This commit is contained in:
Max Jonas Werner 2022-09-14 13:45:12 +02:00 committed by GitHub
commit 9ab1522271
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -382,5 +382,9 @@ func oidcAuthFromAdapter(ctx context.Context, url, provider string) (helmreg.Log
return nil, err
}
if auth == nil {
return nil, fmt.Errorf("could not validate OCI provider %s with URL %s", provider, url)
}
return registry.OIDCAdaptHelper(auth)
}

View File

@ -229,6 +229,15 @@ func TestHelmRepositoryOCIReconciler_authStrategy(t *testing.T) {
*conditions.FalseCondition(meta.ReadyCondition, sourcev1.AuthenticationFailedReason, "failed to get credential from"),
},
},
{
name: "with contextual login provider and invalid repository URL",
wantErr: true,
provider: "aws",
providerImg: "oci://123456789000.dkr.ecr.us-east-2.amazonaws.com",
assertConditions: []metav1.Condition{
*conditions.FalseCondition(meta.ReadyCondition, sourcev1.AuthenticationFailedReason, "failed to get credential from"),
},
},
{
name: "with contextual login provider and secretRef",
want: ctrl.Result{RequeueAfter: interval},