From: Sébastien Lesaint Date: Tue, 17 Oct 2017 09:00:21 +0000 (+0200) Subject: SONAR-9954 return sonar.editions.jsonUrl in api/navigation/global X-Git-Tag: 6.7-RC1~103 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a41cbd9d77ee847456795c524c3c41d12f4492e8;p=sonarqube.git SONAR-9954 return sonar.editions.jsonUrl in api/navigation/global --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/GlobalAction.java b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/GlobalAction.java index 42652292532..6ff1646ac02 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/GlobalAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/GlobalAction.java @@ -40,6 +40,7 @@ import org.sonar.server.ui.VersionFormatter; import org.sonar.server.user.UserSession; import static org.sonar.api.CoreProperties.RATING_GRID; +import static org.sonar.core.config.CorePropertyDefinitions.EDITIONS_CONFIG_URL; import static org.sonar.core.config.WebConstants.SONARCLOUD_ENABLED; import static org.sonar.core.config.WebConstants.SONAR_LF_ENABLE_GRAVATAR; import static org.sonar.core.config.WebConstants.SONAR_LF_GRAVATAR_SERVER_URL; @@ -55,6 +56,7 @@ public class GlobalAction implements NavigationWsAction { SONAR_LF_ENABLE_GRAVATAR, SONAR_LF_GRAVATAR_SERVER_URL, SONAR_UPDATECENTER_ACTIVATE, + EDITIONS_CONFIG_URL, SONARCLOUD_ENABLED, RATING_GRID); diff --git a/server/sonar-server/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java index bdc667d415f..1576a6429f9 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java @@ -67,7 +67,11 @@ public class GlobalActionTest { public void empty_call() throws Exception { init(); - executeAndVerify("empty.json"); + assertJson(call()).isSimilarTo("{" + + " \"globalPages\": []," + + " \"settings\": {}," + + " \"qualifiers\": []" + + "}"); } @Test @@ -85,7 +89,9 @@ public class GlobalActionTest { .build() }); - executeAndVerify("qualifiers.json"); + assertJson(call()).isSimilarTo("{" + + " \"qualifiers\": [\"POL\", \"PAL\"]" + + "}"); } @Test @@ -97,11 +103,23 @@ public class GlobalActionTest { settings.setProperty("sonar.lf.enableGravatar", true); settings.setProperty("sonar.sonarcloud.enabled", true); settings.setProperty("sonar.updatecenter.activate", false); + settings.setProperty("sonar.editions.jsonUrl", "https://foo.bar/editions.json"); settings.setProperty("sonar.technicalDebt.ratingGrid", "0.05,0.1,0.2,0.5"); // This setting should be ignored as it's not needed settings.setProperty("sonar.defaultGroup", "sonar-users"); - executeAndVerify("settings.json"); + assertJson(call()).isSimilarTo("{" + + " \"settings\": {" + + " \"sonar.lf.logoUrl\": \"http://example.com/my-custom-logo.png\"," + + " \"sonar.lf.logoWidthPx\": \"135\"," + + " \"sonar.lf.gravatarServerUrl\": \"https://secure.gravatar.com/avatar/{EMAIL_MD5}.jpg?s={SIZE}&d=identicon\"," + + " \"sonar.lf.enableGravatar\": \"true\"," + + " \"sonar.sonarcloud.enabled\": \"true\"," + + " \"sonar.editions.jsonUrl\": \"https://foo.bar/editions.json\"," + + " \"sonar.updatecenter.activate\": \"false\"," + + " \"sonar.technicalDebt.ratingGrid\": \"0.05,0.1,0.2,0.5\"" + + " }" + + "}"); } @Test @@ -110,14 +128,32 @@ public class GlobalActionTest { settings.setProperty("sonar.lf.logoUrl", "http://example.com/my-custom-logo.png"); settings.setProperty("sonar.lf.logoWidthPx", 135); - executeAndVerify("deprecated_logo_settings.json"); + assertJson(call()).isSimilarTo("{" + + " \"settings\": {" + + " \"sonar.lf.logoUrl\": \"http://example.com/my-custom-logo.png\"," + + " \"sonar.lf.logoWidthPx\": \"135\"" + + " }," + + " \"logoUrl\": \"http://example.com/my-custom-logo.png\"," + + " \"logoWidth\": \"135\"" + + "}"); } @Test public void the_returned_global_pages_do_not_include_administration_pages() throws Exception { init(createPages(), new ResourceTypeTree[] {}); - executeAndVerify("global_pages.json"); + assertJson(call()).isSimilarTo("{" + + " \"globalPages\": [" + + " {" + + " \"key\": \"another_plugin/page\"," + + " \"name\": \"My Another Page\"" + + " }," + + " {" + + " \"key\": \"my_plugin/page\"," + + " \"name\": \"My Plugin Page\"" + + " }" + + " ]" + + "}"); } @Test @@ -125,7 +161,9 @@ public class GlobalActionTest { init(); when(server.getVersion()).thenReturn("6.2"); - executeAndVerify("version.json"); + assertJson(call()).isSimilarTo("{" + + " \"version\": \"6.2\"" + + "}"); } @Test @@ -153,7 +191,9 @@ public class GlobalActionTest { init(); when(dbClient.getDatabase().getDialect()).thenReturn(new MySql()); - executeAndVerify("production_database.json"); + assertJson(call()).isSimilarTo("{" + + " \"productionDatabase\": true" + + "}"); } @Test @@ -161,7 +201,10 @@ public class GlobalActionTest { init(); organizationFlags.setEnabled(true); - executeAndVerify("organization_support.json"); + assertJson(call()).isSimilarTo("{" + + " \"organizationsEnabled\": true," + + " \"defaultOrganization\": \"key_foo\"" + + "}"); } @Test @@ -228,10 +271,6 @@ public class GlobalActionTest { dbClient, organizationFlags, defaultOrganizationProvider, branchFeature, userSession)); } - private void executeAndVerify(String json) { - assertJson(call()).isSimilarTo(getClass().getResource(GlobalActionTest.class.getSimpleName() + "/" + json)); - } - private String call() { return ws.newRequest().execute().getInput(); } diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/deprecated_logo_settings.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/deprecated_logo_settings.json deleted file mode 100644 index 13930da3fd2..00000000000 --- a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/deprecated_logo_settings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "settings": { - "sonar.lf.logoUrl": "http://example.com/my-custom-logo.png", - "sonar.lf.logoWidthPx": "135" - }, - "logoUrl": "http://example.com/my-custom-logo.png", - "logoWidth": "135" -} diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/empty.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/empty.json deleted file mode 100644 index cc5448c6cf3..00000000000 --- a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/empty.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "globalPages": [], - "settings": {}, - "qualifiers": [] -} diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/global_pages.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/global_pages.json deleted file mode 100644 index 014d6a56615..00000000000 --- a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/global_pages.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "globalPages": [ - { - "key": "another_plugin/page", - "name": "My Another Page" - }, - { - "key": "my_plugin/page", - "name": "My Plugin Page" - } - ] -} diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/organization_support.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/organization_support.json deleted file mode 100644 index b2778b221da..00000000000 --- a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/organization_support.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "organizationsEnabled": true, - "defaultOrganization": "key_foo" -} diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/production_database.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/production_database.json deleted file mode 100644 index ae8359cc59d..00000000000 --- a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/production_database.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "productionDatabase": true -} diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/qualifiers.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/qualifiers.json deleted file mode 100644 index ef2107cd9b3..00000000000 --- a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/qualifiers.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "qualifiers": ["POL", "PAL"] -} diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/settings.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/settings.json deleted file mode 100644 index 885c52ba52a..00000000000 --- a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/settings.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "settings": { - "sonar.lf.logoUrl": "http://example.com/my-custom-logo.png", - "sonar.lf.logoWidthPx": "135", - "sonar.lf.gravatarServerUrl": "https://secure.gravatar.com/avatar/{EMAIL_MD5}.jpg?s={SIZE}&d=identicon", - "sonar.lf.enableGravatar": "true", - "sonar.sonarcloud.enabled": "true", - "sonar.updatecenter.activate": "false", - "sonar.technicalDebt.ratingGrid": "0.05,0.1,0.2,0.5" - } -} diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/version.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/version.json deleted file mode 100644 index 21cd1393d5c..00000000000 --- a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/version.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version": "6.2" -}