File tree Expand file tree Collapse file tree
plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments