зеркало из https://github.com/Azure/ARO-RP.git
ARO-9263: Add another condition to check if expiry date is nil
This commit is contained in:
Родитель
1bacb5897e
Коммит
a463d584f0
|
@ -35,15 +35,19 @@ func EnsureACRTokenIsValid(ctx context.Context) error {
|
|||
rp := manager.GetRegistryProfileFromSlice(registryProfiles)
|
||||
if rp != nil {
|
||||
var now = time.Now().UTC()
|
||||
expiry := registryProfiles[0].Expiry.Time
|
||||
expiry := registryProfiles[0].Expiry
|
||||
|
||||
if expiry.Before(now) {
|
||||
switch {
|
||||
case expiry == nil:
|
||||
return mimo.TerminalError(errors.New("No expiry date detected."))
|
||||
case expiry.Time.Before(now):
|
||||
return mimo.TerminalError(errors.New("ACR token has expired"))
|
||||
default:
|
||||
th.SetResultMessage("ACR token is valid")
|
||||
}
|
||||
} else {
|
||||
return mimo.TerminalError(errors.New("No registry profile detected."))
|
||||
}
|
||||
|
||||
th.SetResultMessage("ACR token is valid")
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
tokenName = "token-12345"
|
||||
registryResourceID = "/subscriptions/93aeba23-2f76-4307-be82-02921df010cf/resourceGroups/global/providers/Microsoft.ContainerRegistry/registries/arointsvc"
|
||||
registryName = "arointsvc"
|
||||
registryResourceID = "/subscriptions/93aeba23-2f76-4307-be82-02921df010cf/resourceGroups/global/providers/Microsoft.ContainerRegistry/registries/" + registryName
|
||||
clusterUUID = "512a50c8-2a43-4c2a-8fd9-a5539475df2a"
|
||||
)
|
||||
|
||||
|
@ -50,6 +50,24 @@ func TestEnsureACRToken(t *testing.T) {
|
|||
},
|
||||
wantErr: "TerminalError: No registry profile detected.",
|
||||
},
|
||||
{
|
||||
name: "No expiry date",
|
||||
azureEnv: azureclient.PublicCloud,
|
||||
oc: func() *api.OpenShiftCluster {
|
||||
return &api.OpenShiftCluster{
|
||||
Properties: api.OpenShiftClusterProperties{
|
||||
RegistryProfiles: []*api.RegistryProfile{
|
||||
{
|
||||
Name: registryName + ".azurecr.io",
|
||||
Username: "testuser",
|
||||
Expiry: nil,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
wantErr: "TerminalError: No expiry date detected.",
|
||||
},
|
||||
{
|
||||
name: "expired",
|
||||
azureEnv: azureclient.PublicCloud,
|
||||
|
|
Загрузка…
Ссылка в новой задаче