import org.sonar.server.branch.BranchFeatureProxy;
import org.sonar.server.organization.DefaultOrganizationProvider;
import org.sonar.server.organization.OrganizationFlags;
+import org.sonar.server.platform.WebServer;
import org.sonar.server.ui.PageRepository;
import org.sonar.server.ui.VersionFormatter;
import org.sonar.server.user.UserSession;
private final Configuration config;
private final ResourceTypes resourceTypes;
private final Server server;
+ private final WebServer webServer;
private final DbClient dbClient;
private final OrganizationFlags organizationFlags;
private final DefaultOrganizationProvider defaultOrganizationProvider;
private final UserSession userSession;
public GlobalAction(PageRepository pageRepository, Configuration config, ResourceTypes resourceTypes, Server server,
- DbClient dbClient, OrganizationFlags organizationFlags, DefaultOrganizationProvider defaultOrganizationProvider, BranchFeatureProxy branchFeature, UserSession userSession) {
+ WebServer webServer, DbClient dbClient, OrganizationFlags organizationFlags,
+ DefaultOrganizationProvider defaultOrganizationProvider, BranchFeatureProxy branchFeature, UserSession userSession) {
this.pageRepository = pageRepository;
this.config = config;
this.resourceTypes = resourceTypes;
this.server = server;
+ this.webServer = webServer;
this.dbClient = dbClient;
this.organizationFlags = organizationFlags;
this.defaultOrganizationProvider = defaultOrganizationProvider;
writeDatabaseProduction(json);
writeOrganizationSupport(json);
writeBranchSupport(json);
+ json.prop("standalone", webServer.isStandalone());
json.endObject();
}
}
import org.sonar.server.organization.DefaultOrganizationProvider;
import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.organization.TestOrganizationFlags;
+import org.sonar.server.platform.WebServer;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ui.PageRepository;
import org.sonar.server.ws.WsActionTester;
private MapSettings settings = new MapSettings();
private Server server = mock(Server.class);
+ private WebServer webServer = mock(WebServer.class);
private DbClient dbClient = mock(DbClient.class, RETURNS_DEEP_STUBS);
private TestOrganizationFlags organizationFlags = TestOrganizationFlags.standalone();
assertJson(call()).isSimilarTo("{\"canAdmin\":true}");
}
+ @Test
+ public void standalone_flag() {
+ init();
+ userSession.logIn().setRoot();
+ when(webServer.isStandalone()).thenReturn(true);
+
+
+ assertJson(call()).isSimilarTo("{\"standalone\":true}");
+ }
+
+ @Test
+ public void not_standalone_flag() {
+ init();
+ userSession.logIn().setRoot();
+ when(webServer.isStandalone()).thenReturn(false);
+
+
+ assertJson(call()).isSimilarTo("{\"standalone\":false}");
+ }
+
@Test
public void test_example_response() throws Exception {
init(createPages(), new ResourceTypeTree[] {
settings.setProperty("sonar.technicalDebt.ratingGrid", "0.05,0.1,0.2,0.5");
when(server.getVersion()).thenReturn("6.2");
when(dbClient.getDatabase().getDialect()).thenReturn(new MySql());
+ when(webServer.isStandalone()).thenReturn(true);
String result = call();
- assertJson(ws.getDef().responseExampleAsString()).isSimilarTo(result);
+ assertJson(result).isSimilarTo(ws.getDef().responseExampleAsString());
}
private void init() {
}});
pageRepository.start();
ws = new WsActionTester(new GlobalAction(pageRepository, settings.asConfig(), new ResourceTypes(resourceTypeTrees), server,
- dbClient, organizationFlags, defaultOrganizationProvider, branchFeature, userSession));
+ webServer, dbClient, organizationFlags, defaultOrganizationProvider, branchFeature, userSession));
}
private String call() {