Skip to content

Commit

Permalink
SLVS-1732 Rename method
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriela-trutan-sonarsource committed Dec 24, 2024
1 parent e65430e commit f4f8bce
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ public void ToCredential_TokenAuthCredentials_ReturnsExpected()
}

[TestMethod]
public void ToICredentials_UsernameIsEmpty_ReturnsBasicAuthCredentialsWithPasswordAsToken()
public void ToConnectionCredentials_UsernameIsEmpty_ReturnsBasicAuthCredentialsWithPasswordAsToken()
{
var credential = new Credential(string.Empty, "token");

var result = credential.ToICredentials();
var result = credential.ToConnectionCredentials();

var basicAuth = result as UsernameAndPasswordCredentials;
basicAuth.Should().NotBeNull();
Expand All @@ -72,23 +72,23 @@ public void ToICredentials_UsernameIsEmpty_ReturnsBasicAuthCredentialsWithPasswo
/// </summary>

[TestMethod]
public void ToICredentials_PasswordIsEmpty_ReturnsTokenAuthCredentialsWithUsernameAsToken()
public void ToConnectionCredentials_PasswordIsEmpty_ReturnsTokenAuthCredentialsWithUsernameAsToken()
{
var credential = new Credential("token", string.Empty);

var result = credential.ToICredentials();
var result = credential.ToConnectionCredentials();

var tokenAuth = result as TokenAuthCredentials;
tokenAuth.Should().NotBeNull();
tokenAuth.Token.ToUnsecureString().Should().Be(credential.Username);
}

[TestMethod]
public void ToICredentials_PasswordAndUsernameFilled_ReturnsBasicAuthCredentials()
public void ToConnectionCredentials_PasswordAndUsernameFilled_ReturnsBasicAuthCredentials()
{
var credential = new Credential("username", "pwd");

var result = credential.ToICredentials();
var result = credential.ToConnectionCredentials();

var basicAuth = result as UsernameAndPasswordCredentials;
basicAuth.Should().NotBeNull();
Expand All @@ -97,9 +97,9 @@ public void ToICredentials_PasswordAndUsernameFilled_ReturnsBasicAuthCredentials
}

[TestMethod]
public void ToICredentials_Null_ReturnsNull()
public void ToConnectionCredentials_Null_ReturnsNull()
{
var result = ((Credential)null).ToICredentials();
var result = ((Credential)null).ToConnectionCredentials();

result.Should().BeNull();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/

using Microsoft.Alm.Authentication;
using SonarLint.VisualStudio.Core.Binding;
using SonarQube.Client.Helpers;
using SonarQube.Client.Models;

Expand All @@ -36,7 +35,7 @@ internal static Credential ToCredential(this IConnectionCredentials credentials)
_ => throw new NotSupportedException($"Unexpected credentials type: {credentials?.GetType()}")
};

internal static IConnectionCredentials ToICredentials(this Credential credential)
internal static IConnectionCredentials ToConnectionCredentials(this Credential credential)
{
if (credential is null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

using Microsoft.Alm.Authentication;
using SonarLint.VisualStudio.ConnectedMode.Binding;
using SonarQube.Client.Helpers;
using SonarQube.Client.Models;

namespace SonarLint.VisualStudio.ConnectedMode.Persistence
Expand Down Expand Up @@ -51,7 +49,7 @@ public IConnectionCredentials Load(Uri boundServerUri)
}
var credentials = store.ReadCredentials(boundServerUri);

return credentials.ToICredentials();
return credentials.ToConnectionCredentials();
}

public void Save(IConnectionCredentials credentials, Uri boundServerUri)
Expand Down

0 comments on commit f4f8bce

Please sign in to comment.