use of org.sonarlint.intellij.SonarApplication in project sonarlint-intellij by SonarSource.
the class ConnectionTestTaskTest method prepare.
@Before
public void prepare() {
super.register(app, SonarApplication.class, new SonarApplication());
super.register(app, GlobalLogOutput.class, globalLogOutput);
}
use of org.sonarlint.intellij.SonarApplication in project sonarlint-intellij by SonarSource.
the class SonarLintUtils method getServerConfiguration.
public static ServerConfiguration getServerConfiguration(SonarQubeServer server, int connectTimeout, int readTimeout) {
CertificateManager certificateManager = get(CertificateManager.class);
SonarApplication sonarlint = get(SonarApplication.class);
ServerConfiguration.Builder serverConfigBuilder = ServerConfiguration.builder().userAgent("SonarLint IntelliJ " + sonarlint.getVersion()).connectTimeoutMilliseconds(connectTimeout).readTimeoutMilliseconds(readTimeout).sslSocketFactory(certificateManager.getSslContext().getSocketFactory()).trustManager(certificateManager.getCustomTrustManager()).url(server.getHostUrl());
if (!isBlank(server.getOrganizationKey())) {
serverConfigBuilder.organizationKey(server.getOrganizationKey());
}
if (!isBlank(server.getToken())) {
serverConfigBuilder.token(server.getToken());
} else {
serverConfigBuilder.credentials(server.getLogin(), server.getPassword());
}
if (server.enableProxy()) {
configureProxy(server.getHostUrl(), serverConfigBuilder);
}
return serverConfigBuilder.build();
}
use of org.sonarlint.intellij.SonarApplication in project sonarlint-intellij by SonarSource.
the class SonarLintUtilsTest method testServerConfigurationToken.
@Test
public void testServerConfigurationToken() {
SonarApplication app = mock(SonarApplication.class);
when(app.getVersion()).thenReturn("1.0");
super.register(ApplicationManager.getApplication(), SonarApplication.class, app);
SonarQubeServer server = SonarQubeServer.newBuilder().setHostUrl("http://myhost").setEnableProxy(false).setToken("token").build();
ServerConfiguration config = SonarLintUtils.getServerConfiguration(server);
assertThat(config.getLogin()).isEqualTo(server.getToken());
assertThat(config.getPassword()).isNull();
assertThat(config.getConnectTimeoutMs()).isEqualTo(SonarLintUtils.CONNECTION_TIMEOUT_MS);
assertThat(config.getReadTimeoutMs()).isEqualTo(SonarLintUtils.READ_TIMEOUT_MS);
assertThat(config.getUserAgent()).contains("SonarLint");
assertThat(config.getUrl()).isEqualTo(server.getHostUrl());
assertThat(config.getOrganizationKey()).isNull();
}
use of org.sonarlint.intellij.SonarApplication in project sonarlint-intellij by SonarSource.
the class SonarLintUtilsTest method testServerConfigurationPassword.
@Test
public void testServerConfigurationPassword() {
SonarApplication app = mock(SonarApplication.class);
when(app.getVersion()).thenReturn("1.0");
super.register(ApplicationManager.getApplication(), SonarApplication.class, app);
SonarQubeServer server = SonarQubeServer.newBuilder().setHostUrl("http://myhost").setLogin("token").setPassword("pass").build();
ServerConfiguration config = SonarLintUtils.getServerConfiguration(server);
assertThat(config.getLogin()).isEqualTo(server.getLogin());
assertThat(config.getPassword()).isEqualTo(server.getPassword());
}
Aggregations