public void NullPasswordCredentials() { string baseUri = "http://sonarqube.test.de/"; string projectKey = "project-key"; string metrics = "ncloc,bugs,vulnerabilities"; string username = "******"; string password = null; SqComponentTreeUriBuilder uri = new SqComponentTreeUriBuilder(baseUri, projectKey, metrics); uri.UserCredentials(username, password); string expectedUri = baseUri + "api/measures/component_tree?baseComponentKey=" + projectKey + "&metricKeys=" + metrics; Assert.AreEqual(expectedUri, uri.GetSqUri().ToString()); }
/// <summary> /// Requests all project components and their metrics from the sonarqube api /// </summary> /// <param name="projectKey">SonarQube Project Key</param> /// <param name="page">The page of the request, should be 1. /// The other calls are recursive in the method.</param> private void LoadOnlineProject(string projectKey, int page) { SqComponentTreeUriBuilder uriBuilder = new SqComponentTreeUriBuilder(model.GetBaseUrl(), projectKey, model.GetAvailableMetricsAsString()); if (model.GetUsername() != "" && model.GetPassword() != "") { uriBuilder.UserCredentials(model.GetUsername(), model.GetPassword()); } StartCoroutine(WebInterface.WebRequest <ComponentTree>( uriBuilder.Page(page).GetSqUri(), (res, err) => { switch (err) { case 200: model.BuildProjectTree(res.baseComponent, res.components); int TotalNumOfPages = res.paging.total / res.paging.pageSize + 1; if (page < TotalNumOfPages) { LoadOnlineProject(projectKey, page + 1); } else { if (cityLoadingState != CityLoadingState.LodingError) { cityLoadingState = CityLoadingState.Ready; } ComponentTreeStream.SaveProjectComponent(model.GetTree()); } break; default: Debug.Log("Addyi ResponseCode: " + err); cityLoadingState = CityLoadingState.LodingError; break; } })); }