66using IntelliTect . Management . Automation . UnitTesting ;
77using Microsoft . VisualStudio . TestTools . UnitTesting ;
88using ExposedObject ;
9+ using IntelliTect . Security ;
910
1011namespace IntelliTect . PSDropbin . Tests
1112{
@@ -399,5 +400,31 @@ public void RemoveItem_ExistingItem_Success()
399400 RemoveItem ( path ) ;
400401 AttemptAssertion ( ( ) => TestPath ( path ) , false ) ;
401402 }
403+
404+ [ TestMethod ]
405+ public void RemoveCredentials_WithSavedCredentials_Success ( )
406+ {
407+ string credentialName = "RemoveCredentialsTest" ;
408+ string accessTokenCredentialName = DropboxDriveInfo . GetDropboxAccessTokenName ( credentialName ) ;
409+ CredentialManager . WriteCredential ( accessTokenCredentialName , "TestAccessToken" ) ;
410+ string refreshTokenCredentialName = DropboxDriveInfo . GetDropboxRefreshTokenName ( credentialName ) ;
411+ CredentialManager . WriteCredential ( refreshTokenCredentialName , "TestRefreshToken" ) ;
412+
413+ var result = PowerShellInvoke ( "Remove-DropboxCredential {0}" , credentialName ) ;
414+
415+ var actual = ( string ) result . First ( ) . BaseObject ;
416+ Assert . AreEqual ( "Credentials removed. You may wish to also revoke access in your Dropbox user profile." , actual ) ;
417+ }
418+
419+ [ TestMethod ]
420+ public void RemoveCredentials_WithoutSavedCredentials_ReturnsNoCredentialsFound ( )
421+ {
422+ string credentialName = "RemoveCredentialsTest" ;
423+
424+ var result = PowerShellInvoke ( "Remove-DropboxCredential {0}" , credentialName ) ;
425+
426+ var actual = ( string ) result . First ( ) . BaseObject ;
427+ Assert . AreEqual ( "No credential found." , actual ) ;
428+ }
402429 }
403430}
0 commit comments