use of org.sonarsource.sonarlint.core.client.api.connected.ServerConfiguration in project sonarlint-core by SonarSource.
the class ConnectedModeTest method generateToken.
@Test
public void generateToken() {
WsHelper ws = new WsHelperImpl();
ServerConfiguration serverConfig = getServerConfig(true);
if (!ORCHESTRATOR.getServer().version().isGreaterThanOrEquals("5.4")) {
exception.expect(UnsupportedServerException.class);
}
String token = ws.generateAuthenticationToken(serverConfig, "name", false);
assertThat(token).isNotNull();
token = ws.generateAuthenticationToken(serverConfig, "name", true);
assertThat(token).isNotNull();
}
use of org.sonarsource.sonarlint.core.client.api.connected.ServerConfiguration in project sonarlint-core by SonarSource.
the class NotificationConfigurationTest method testGetters.
@Test
public void testGetters() {
SonarQubeNotificationListener listener = mock(SonarQubeNotificationListener.class);
LastNotificationTime lastNotificationTime = mock(LastNotificationTime.class);
String projectKey = "key";
ServerConfiguration serverConfiguration = mock(ServerConfiguration.class);
NotificationConfiguration configuration = new NotificationConfiguration(listener, lastNotificationTime, projectKey, serverConfiguration);
assertThat(configuration.lastNotificationTime()).isEqualTo(lastNotificationTime);
assertThat(configuration.listener()).isEqualTo(listener);
assertThat(configuration.projectKey()).isEqualTo(projectKey);
assertThat(configuration.serverConfiguration()).isEqualTo(serverConfiguration);
}
use of org.sonarsource.sonarlint.core.client.api.connected.ServerConfiguration in project sonarlint-intellij by SonarSource.
the class SonarQubeEventNotifications method createConfiguration.
private NotificationConfiguration createConfiguration(SonarLintProjectSettings settings, SonarQubeServer server) {
String projectKey = settings.getProjectKey();
ServerConfiguration serverConfiguration = SonarLintUtils.getServerConfiguration(server);
return new NotificationConfiguration(eventListener, notificationTime, projectKey, serverConfiguration);
}
use of org.sonarsource.sonarlint.core.client.api.connected.ServerConfiguration in project sonarlint-intellij by SonarSource.
the class UpdateChecker method checkForUpdate.
void checkForUpdate() {
ConnectedSonarLintEngine engine;
try {
engine = projectBindingManager.getConnectedEngine();
} catch (Exception e) {
// happens if project is not bound, binding is invalid, storages are not updated, ...
log.log("Couldn't get a connected engine to check for update: " + e.getMessage(), LogOutput.Level.DEBUG);
return;
}
try {
List<String> changelog = new ArrayList<>();
ServerConfiguration serverConfiguration = SonarLintUtils.getServerConfiguration(projectBindingManager.getSonarQubeServer());
log.log("Check for updates from server '" + projectBindingManager.getSonarQubeServer().getName() + "'...", LogOutput.Level.INFO);
boolean hasGlobalUpdates = checkForGlobalUpdates(changelog, engine, serverConfiguration);
log.log("Check for updates from server '" + projectBindingManager.getSonarQubeServer().getName() + "' for project '" + projectSettings.getProjectKey() + "'...", LogOutput.Level.INFO);
checkForProjectUpdates(changelog, engine, serverConfiguration);
if (!changelog.isEmpty()) {
changelog.forEach(line -> log.log(" - " + line, LogOutput.Level.INFO));
notifications.notifyServerHasUpdates(projectSettings.getServerId(), engine, projectBindingManager.getSonarQubeServer(), !hasGlobalUpdates);
}
} catch (Exception e) {
log.log("There was an error while checking for updates: " + e.getMessage(), LogOutput.Level.WARN);
}
}
use of org.sonarsource.sonarlint.core.client.api.connected.ServerConfiguration 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();
}
Aggregations