Esempio n. 1
0
        public async Task Call_Real_SonarCloud()
        {
            // TODO: set to a valid SonarCloud token but make sure you don't check it in...
            string validSonarCloudToken = "DO NOT CHECK IN A REAL TOKEN";

            var url      = ConnectionInformation.FixedSonarCloudUri;
            var password = new SecureString();
            var connInfo = new ConnectionInformation(url, validSonarCloudToken, password);

            var service = new SonarQubeService(new HttpClientHandler(), "agent", new TestLogger());

            try
            {
                await service.ConnectAsync(connInfo, CancellationToken.None);

                // Example
                var fileKey = "vuln:Tools/Orchard/Logger.cs";
                var result  = await service.GetSourceCodeAsync(fileKey, CancellationToken.None);

                result.Should().NotBeNullOrEmpty();
            }
            finally
            {
                service.Disconnect();
            }
        }
Esempio n. 2
0
        public async Task Call_Real_SonarQube()
        {
            var url = new Uri("http://localhost:9000");

            string userName = "******";
            var    password = new SecureString();

            password.AppendChar('a');
            password.AppendChar('d');
            password.AppendChar('m');
            password.AppendChar('i');
            password.AppendChar('n');

            var connInfo = new ConnectionInformation(url, userName, password);

            var service = new SonarQubeService(new HttpClientHandler(), "agent", new TestLogger());

            try
            {
                await service.ConnectAsync(connInfo, CancellationToken.None);

                // Example
                string fileKey = "junk:MyClass.cs";
                var    result  = await service.GetSourceCodeAsync(fileKey, CancellationToken.None);

                result.Should().NotBeNullOrEmpty();
            }
            finally
            {
                service.Disconnect();
            }
        }