Skip to content

Commit d45f1e7

Browse files
committed
Added RemoveCredential tests.
1 parent b6ab148 commit d45f1e7

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

Modules/IntelliTect.PSDropbin/IntelliTect.PSDropBin.Tests/DropboxPSProviderTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using IntelliTect.Management.Automation.UnitTesting;
77
using Microsoft.VisualStudio.TestTools.UnitTesting;
88
using ExposedObject;
9+
using IntelliTect.Security;
910

1011
namespace 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
}

Modules/IntelliTect.PSDropbin/IntelliTect.PSDropBin/RemoveDropboxCredential.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ protected override void ProcessRecord()
2323
WriteObject(accessTokenResult && refreshTokenResult
2424
? "Credentials removed. You may wish to also revoke access in your Dropbox user profile."
2525
: "No credential found.");
26-
Settings.Default.Reset();
2726
}
2827
catch ( Exception e )
2928
{
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)