diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2017-09-22 18:52:19 +0200 |
---|---|---|
committer | Teryk Bellahsene <teryk@users.noreply.github.com> | 2017-09-26 11:15:35 +0200 |
commit | 184dbe792ce14f192f75b13507c30a4b697d5852 (patch) | |
tree | 79ad219937ecb586c156b34f8302eadfbcd324e4 /tests/src/test | |
parent | 2310482d4297e8e8e051691a21e8c6add5fd25ff (diff) | |
download | sonarqube-184dbe792ce14f192f75b13507c30a4b697d5852.tar.gz sonarqube-184dbe792ce14f192f75b13507c30a4b697d5852.zip |
SONAR-9865 Sanitize WS api/qualityprofiles/*
- functional key of a quality profile is: name, language and organization
- quality profile name is named 'name'
- quality profile key is named 'key'
- quality profile key parameter is deprecated when appropriate
Diffstat (limited to 'tests/src/test')
8 files changed, 22 insertions, 20 deletions
diff --git a/tests/src/test/java/org/sonarqube/tests/QProfileTester.java b/tests/src/test/java/org/sonarqube/tests/QProfileTester.java index c2d163151c6..29656d65c95 100644 --- a/tests/src/test/java/org/sonarqube/tests/QProfileTester.java +++ b/tests/src/test/java/org/sonarqube/tests/QProfileTester.java @@ -58,7 +58,7 @@ public class QProfileTester { CreateRequest.Builder request = CreateRequest.builder() .setOrganizationKey(organization.getKey()) .setLanguage("xoo") - .setProfileName("Profile" + id); + .setName("Profile" + id); stream(populators).forEach(p -> p.accept(request)); return service().create(request.build()).getProfile(); } @@ -69,7 +69,7 @@ public class QProfileTester { public QProfileTester activateRule(String profileKey, String ruleKey) { ActivateRuleWsRequest request = ActivateRuleWsRequest.builder() - .setProfileKey(profileKey) + .setKey(profileKey) .setRuleKey(ruleKey) .build(); service().activateRule(request); @@ -84,7 +84,7 @@ public class QProfileTester { public QProfileTester assignQProfileToProject(QualityProfile profile, Project project) { service().addProject(AddProjectRequest.builder() .setProjectKey(project.getKey()) - .setProfileKey(profile.getKey()) + .setKey(profile.getKey()) .build()); return this; } diff --git a/tests/src/test/java/org/sonarqube/tests/authorisation/QualityProfileAdminPermissionTest.java b/tests/src/test/java/org/sonarqube/tests/authorisation/QualityProfileAdminPermissionTest.java index 6983a6757a3..11fe9c49637 100644 --- a/tests/src/test/java/org/sonarqube/tests/authorisation/QualityProfileAdminPermissionTest.java +++ b/tests/src/test/java/org/sonarqube/tests/authorisation/QualityProfileAdminPermissionTest.java @@ -60,7 +60,7 @@ public class QualityProfileAdminPermissionTest { private void createProfile(String language, String name) { tester.wsClient().qualityProfiles().create(CreateRequest.builder() .setLanguage(language) - .setProfileName(name) + .setName(name) .build()); } diff --git a/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java b/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java index 436e466454d..683b808fbbe 100644 --- a/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java +++ b/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java @@ -209,7 +209,7 @@ public class OrganizationIssueAssignTest { .setProjectKey(projectKey) .setOrganization(organization) .setLanguage("xoo") - .setProfileName("one-issue-per-file-profile") + .setQualityProfile("one-issue-per-file-profile") .build()); } diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/BuiltInQualityProfilesNotificationTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/BuiltInQualityProfilesNotificationTest.java index 8593dc17a08..2ab31f1f1de 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/BuiltInQualityProfilesNotificationTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/BuiltInQualityProfilesNotificationTest.java @@ -110,7 +110,7 @@ public class BuiltInQualityProfilesNotificationTest { WsUsers.CreateWsResponse.User noProfileAdmin = userRule.generate(); // Create a child profile on the built-in profile => The notification should not take into account updates of this profile - wsClient.qualityProfiles().create(CreateRequest.builder().setLanguage("foo").setProfileName("child").build()); + wsClient.qualityProfiles().create(CreateRequest.builder().setLanguage("foo").setName("child").build()); wsClient.qualityProfiles().changeParent(ChangeParentRequest.builder().setProfileName("child").setParentName("Basic").setLanguage("foo").build()); // uninstall plugin V1 diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/CustomQualityProfilesTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/CustomQualityProfilesTest.java index 0be4b07d90f..76d707b38c6 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/CustomQualityProfilesTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/CustomQualityProfilesTest.java @@ -65,8 +65,8 @@ public class CustomQualityProfilesTest { // create two profiles with same names in two organizations Organization org1 = tester.organizations().generate(); Organization org2 = tester.organizations().generate(); - QualityProfile profileInOrg1 = tester.qProfiles().createXooProfile(org1, p -> p.setProfileName("foo")); - QualityProfile profileInOrg2 = tester.qProfiles().createXooProfile(org2, p -> p.setProfileName("foo")); + QualityProfile profileInOrg1 = tester.qProfiles().createXooProfile(org1, p -> p.setName("foo")); + QualityProfile profileInOrg2 = tester.qProfiles().createXooProfile(org2, p -> p.setName("foo")); tester.qProfiles() .assertThatNumberOfActiveRulesEqualsTo(profileInOrg1, 0) @@ -133,7 +133,7 @@ public class CustomQualityProfilesTest { CreateRequest.builder() .setLanguage(parentProfile.getLanguage()) .setOrganizationKey(org.getKey()) - .setProfileName("inherited_profile") + .setName("inherited_profile") .build()) .getProfile(); @@ -145,7 +145,7 @@ public class CustomQualityProfilesTest { CreateRequest.builder() .setLanguage(parentProfile.getLanguage()) .setOrganizationKey(org.getKey()) - .setProfileName("inherited_profile2") + .setName("inherited_profile2") .build()) .getProfile(); @@ -223,7 +223,7 @@ public class CustomQualityProfilesTest { CreateRequest.builder() .setLanguage(parentProfile.getLanguage()) .setOrganizationKey(org.getKey()) - .setProfileName("inherited_profile") + .setName("inherited_profile") .build()) .getProfile(); @@ -295,7 +295,7 @@ public class CustomQualityProfilesTest { .setParam("organization", org.getKey())); adminSession.qProfiles().service().addProject(AddProjectRequest.builder() - .setProfileKey(newXooProfile.getKey()) + .setKey(newXooProfile.getKey()) .setProjectKey(projectKey) .build()); diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java index ad75bcdf9d9..1414b129683 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java @@ -188,7 +188,7 @@ public class OrganizationQualityProfilesUiTest { private void addProfileToProject(String language, String profileName, String projectKey) { tester.wsClient().qualityProfiles().addProject(AddProjectRequest.builder() .setLanguage(language) - .setProfileName(profileName) + .setQualityProfile(profileName) .setProjectKey(projectKey) .setOrganization(organization.getKey()) .build()); diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesUiTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesUiTest.java index a1583020954..f67a20b0acd 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesUiTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesUiTest.java @@ -153,7 +153,7 @@ public class QualityProfilesUiTest { private void createProfile(String language, String name) { tester.wsClient().qualityProfiles().create(CreateRequest.builder() .setLanguage(language) - .setProfileName(name) + .setName(name) .build()); } @@ -172,7 +172,7 @@ public class QualityProfilesUiTest { private void addProfileToProject(String language, String profileName, String projectKey) { tester.wsClient().qualityProfiles().addProject(AddProjectRequest.builder() .setLanguage(language) - .setProfileName(profileName) + .setQualityProfile(profileName) .setProjectKey(projectKey) .build()); } diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesWsTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesWsTest.java index 9abacf1bf29..6047ae1230d 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesWsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesWsTest.java @@ -57,7 +57,7 @@ public class QualityProfilesWsTest { tester.qProfiles().activateRule(xooProfile, RULE_ONE_BUG_PER_LINE); tester.qProfiles().activateRule(xooProfile, RULE_ONE_ISSUE_PER_LINE); - ShowResponse result = tester.qProfiles().service().show(new ShowRequest().setProfile(xooProfile.getKey())); + ShowResponse result = tester.qProfiles().service().show(new ShowRequest().setKey(xooProfile.getKey())); assertThat(result.getProfile()) .extracting(QualityProfile::getName, QualityProfile::getLanguage, QualityProfile::getIsBuiltIn, QualityProfile::getIsDefault, @@ -74,7 +74,7 @@ public class QualityProfilesWsTest { SearchWsResponse.QualityProfile sonarWay = getProfile(org, p -> "Sonar way".equals(p.getName()) && "xoo".equals(p.getLanguage()) && p.getIsBuiltIn()); CompareToSonarWay result = tester.qProfiles().service().show(new ShowRequest() - .setProfile(xooProfile.getKey()) + .setKey(xooProfile.getKey()) .setCompareToSonarWay(true)).getCompareToSonarWay(); assertThat(result) @@ -92,14 +92,14 @@ public class QualityProfilesWsTest { // Bulk activate missing rules from the Sonar way profile tester.wsClient().wsConnector().call(new PostRequest("api/qualityprofiles/activate_rules") - .setParam("targetProfile", xooProfile.getKey()) + .setParam("targetKey", xooProfile.getKey()) .setParam("qprofile", xooProfile.getKey()) .setParam("activation", "false") .setParam("compareToProfile", sonarWay.getKey())).failIfNotSuccessful(); // Check that the profile has no missing rule from the Sonar way profile assertThat(tester.qProfiles().service().show(new ShowRequest() - .setProfile(xooProfile.getKey()) + .setKey(xooProfile.getKey()) .setCompareToSonarWay(true)).getCompareToSonarWay()) .extracting(CompareToSonarWay::getProfile, CompareToSonarWay::getProfileName, CompareToSonarWay::getMissingRuleCount) .containsExactly(sonarWay.getKey(), sonarWay.getName(), 0L); @@ -113,7 +113,9 @@ public class QualityProfilesWsTest { assertThat(response.content()).isEqualTo("xoo -> Basic -> 1"); // Check 'name' parameter is taken into account - assertThat(tester.wsClient().wsConnector().call(new GetRequest("profiles/export?language=xoo&name=empty&format=XooFakeExporter")).content()).isEqualTo("xoo -> empty -> 0"); + assertThat(tester.wsClient().wsConnector() + .call(new GetRequest("profiles/export?language=xoo&qualityProfile=empty&format=XooFakeExporter")).content()) + .isEqualTo("xoo -> empty -> 0"); } private SearchWsResponse.QualityProfile getProfile(Organization organization, Predicate<SearchWsResponse.QualityProfile> filter) { |