@@ -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,60 @@ 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+ testCredentialsRequestWithCondition (t , minterv1.CredentialsRequestCondition {
362+ Type : minterv1 .CredentialsProvisionFailure ,
363+ Reason : "CredentialsProvisionFailure" ,
364+ Status : corev1 .ConditionTrue ,
365+ LastTransitionTime : metav1 .NewTime (time .Now ().Add (- 10 * time .Minute )),
366+ }),
367+ testAWSCredsSecret ("openshift-cloud-credential-operator" , "cloud-credential-operator-iam-ro-creds" , testReadAWSAccessKeyID , testReadAWSSecretAccessKey ),
368+ testClusterVersion (),
369+ testInfrastructure (testInfraName ),
370+ },
371+ existingAdmin : []runtime.Object {},
372+ mockRootAWSClient : func (mockCtrl * gomock.Controller ) * mockaws.MockClient {
373+ mockAWSClient := mockaws .NewMockClient (mockCtrl )
374+ return mockAWSClient
375+ },
376+ mockReadAWSClient : func (mockCtrl * gomock.Controller ) * mockaws.MockClient {
377+ mockAWSClient := mockaws .NewMockClient (mockCtrl )
378+ return mockAWSClient
379+ },
380+ validate : func (c client.Client , t * testing.T ) {
381+ targetSecret := getSecret (c )
382+ assert .Nil (t , targetSecret )
383+ cr := getCR (c )
384+ assert .False (t , cr .Status .Provisioned )
385+ },
386+ expectErr : true ,
387+ expectedConditions : []ExpectedCondition {
388+ {
389+ conditionType : minterv1 .CredentialsProvisionFailure ,
390+ reason : "CredentialsProvisionFailure" ,
391+ status : corev1 .ConditionTrue ,
392+ },
393+ },
340394 expectedCOConditions : []ExpectedCOCondition {
341395 {
342396 conditionType : configv1 .OperatorProgressing ,
@@ -1683,6 +1737,12 @@ func testProvisionedCredentialsRequest(t *testing.T) *minterv1.CredentialsReques
16831737 return cr
16841738}
16851739
1740+ func testCredentialsRequestWithCondition (t * testing.T , condition minterv1.CredentialsRequestCondition ) * minterv1.CredentialsRequest {
1741+ cr := testCredentialsRequest (t )
1742+ cr .Status .Conditions = append (cr .Status .Conditions , condition )
1743+ return cr
1744+ }
1745+
16861746func createTestNamespace (namespace string ) * corev1.Namespace {
16871747 return & corev1.Namespace {
16881748 ObjectMeta : metav1.ObjectMeta {
0 commit comments