Ejemplo n.º 1
0
        public void ReadSolution_SolutionFileExists_CredentialsExist_ReturnsConfig()
        {
            // Arrange
            var validConfig = @"{
  ""ServerUri"": ""https://*****:*****@"c:\mysolutionfile.foo");
            SetFileContents(@"c:\.sonarlint\mysolutionfile.slconfig", validConfig);

            Credential cred = new Credential("user1");

            configurableStore.WriteCredentials(new TargetUri("https://xxx:123"), cred);

            // Act
            var actual = testSubject.ReadSolutionBinding();

            // Assert
            actual.Should().NotBeNull();

            actual.Credentials.Should().NotBeNull();
            var actualCreds = actual.Credentials as BasicAuthCredentials;

            actualCreds.Should().NotBeNull();
            actualCreds.UserName.Should().Be("user1");

            actual.ServerUri.Should().Be("https://xxx:123");
            actual.Organization.Should().NotBeNull();
            actual.Organization.Key.Should().Be("OrgKey");
            actual.Organization.Name.Should().Be("OrgName");
            actual.ProjectKey.Should().Be("key111");
        }
Ejemplo n.º 2
0
        public void Save(ICredentials credentials, Uri boundServerUri)
        {
            if (boundServerUri == null || !(credentials is BasicAuthCredentials basicCredentials))
            {
                return;
            }

            Debug.Assert(basicCredentials.UserName != null, "User name is not expected to be null");
            Debug.Assert(basicCredentials.Password != null, "Password name is not expected to be null");

            var credentialToSave = new Credential(basicCredentials.UserName, basicCredentials.Password.ToUnsecureString());

            store.WriteCredentials(boundServerUri, credentialToSave);
        }