Skip to content

Commit bdab6f7

Browse files
Gupta, SuryaGupta, Surya
authored andcommitted
[CSTACKEX-176] Bug Fixes test cases
1 parent 27c0c6a commit bdab6f7

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/StorageStrategyTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,20 @@ public void testConnect_nullSvmResponse() {
405405
assertTrue(ex.getMessage().contains("No SVM found"));
406406
}
407407

408+
@Test
409+
public void testConnect_invalidCredentials() {
410+
// Setup - ONTAP rejects the supplied username/password with HTTP 401 Unauthorized.
411+
when(svmFeignClient.getSvmResponse(anyMap(), anyString()))
412+
.thenThrow(mock(FeignException.Unauthorized.class));
413+
414+
// Execute & Verify - connect() must surface a clear "invalid credentials" error.
415+
CloudRuntimeException ex = assertThrows(CloudRuntimeException.class, () -> storageStrategy.connect());
416+
assertTrue(ex.getMessage().contains("Authentication failed: Invalid credentials"),
417+
"Expected an authentication failure message but got: " + ex.getMessage());
418+
assertTrue(ex.getMessage().contains("Please verify the username and password"),
419+
"Expected the message to prompt verifying username/password but got: " + ex.getMessage());
420+
}
421+
408422
// ========== createStorageVolume() Tests ==========
409423

410424
@Test

0 commit comments

Comments
 (0)