@@ -311,7 +311,7 @@ func TestCredentialsRequestReconcile(t *testing.T) {
311311 },
312312 {
313313 // This indicates an error state.
314- name : "new credential no root creds available" ,
314+ name : "new credential no root creds available (initially) " ,
315315 existing : []runtime.Object {
316316 testOperatorConfig ("" ),
317317 createTestNamespace (testNamespace ),
@@ -337,6 +337,55 @@ func TestCredentialsRequestReconcile(t *testing.T) {
337337 assert .False (t , cr .Status .Provisioned )
338338 },
339339 expectErr : true ,
340+ expectedConditions : []ExpectedCondition {
341+ {
342+ conditionType : minterv1 .CredentialsProvisionFailure ,
343+ reason : "CredentialsProvisionFailure" ,
344+ status : corev1 .ConditionTrue ,
345+ },
346+ },
347+ expectedCOConditions : []ExpectedCOCondition {
348+ {
349+ conditionType : configv1 .OperatorProgressing ,
350+ status : corev1 .ConditionTrue ,
351+ },
352+ },
353+ },
354+ {
355+ // This indicates an error state.
356+ name : "new credential no root creds available (after waiting period)" ,
357+ existing : []runtime.Object {
358+ testOperatorConfig ("" ),
359+ createTestNamespace (testNamespace ),
360+ createTestNamespace (testSecretNamespace ),
361+ testFailedCredentialsRequest (t , 10 * time .Minute ),
362+ testAWSCredsSecret ("openshift-cloud-credential-operator" , "cloud-credential-operator-iam-ro-creds" , testReadAWSAccessKeyID , testReadAWSSecretAccessKey ),
363+ testClusterVersion (),
364+ testInfrastructure (testInfraName ),
365+ },
366+ existingAdmin : []runtime.Object {},
367+ mockRootAWSClient : func (mockCtrl * gomock.Controller ) * mockaws.MockClient {
368+ mockAWSClient := mockaws .NewMockClient (mockCtrl )
369+ return mockAWSClient
370+ },
371+ mockReadAWSClient : func (mockCtrl * gomock.Controller ) * mockaws.MockClient {
372+ mockAWSClient := mockaws .NewMockClient (mockCtrl )
373+ return mockAWSClient
374+ },
375+ validate : func (c client.Client , t * testing.T ) {
376+ targetSecret := getSecret (c )
377+ assert .Nil (t , targetSecret )
378+ cr := getCR (c )
379+ assert .False (t , cr .Status .Provisioned )
380+ },
381+ expectErr : true ,
382+ expectedConditions : []ExpectedCondition {
383+ {
384+ conditionType : minterv1 .CredentialsProvisionFailure ,
385+ reason : "CredentialsProvisionFailure" ,
386+ status : corev1 .ConditionTrue ,
387+ },
388+ },
340389 expectedCOConditions : []ExpectedCOCondition {
341390 {
342391 conditionType : configv1 .OperatorProgressing ,
@@ -1683,6 +1732,17 @@ func testProvisionedCredentialsRequest(t *testing.T) *minterv1.CredentialsReques
16831732 return cr
16841733}
16851734
1735+ func testFailedCredentialsRequest (t * testing.T , howLong time.Duration ) * minterv1.CredentialsRequest {
1736+ cr := testCredentialsRequest (t )
1737+ cr .Status .Conditions = append (cr .Status .Conditions , minterv1.CredentialsRequestCondition {
1738+ Type : minterv1 .CredentialsProvisionFailure ,
1739+ Reason : "CredentialsProvisionFailure" ,
1740+ Status : corev1 .ConditionTrue ,
1741+ LastTransitionTime : metav1 .NewTime (time .Now ().Add (- howLong )),
1742+ })
1743+ return cr
1744+ }
1745+
16861746func createTestNamespace (namespace string ) * corev1.Namespace {
16871747 return & corev1.Namespace {
16881748 ObjectMeta : metav1.ObjectMeta {
0 commit comments