@@ -130,14 +130,12 @@ class SonarCloudTests extends AbstractConnectedTests {
130
130
private static final URI SONARCLOUD_STAGING_URL = URI .create ("https://sc-staging.io" );
131
131
private static final URI SONARCLOUD_WEBSOCKETS_STAGING_URL = URI .create ("wss://events-api.sc-staging.io/" );
132
132
private static final String SONARCLOUD_ORGANIZATION = "sonarlint-it" ;
133
- private static final String SONARCLOUD_USER = "sonarlint-it" ;
134
- private static final String SONARCLOUD_PASSWORD = System .getenv ("SONARCLOUD_IT_PASSWORD" );
133
+ private static final String SONARCLOUD_TOKEN = System .getenv ("SONARCLOUD_IT_TOKEN" );
135
134
136
135
private static final String TIMESTAMP = Long .toString (Instant .now ().toEpochMilli ());
137
136
private static final String TOKEN_NAME = "SLCORE-IT-" + TIMESTAMP ;
138
137
private static final String PROJECT_KEY_JAVA = "sample-java" ;
139
-
140
-
138
+
141
139
public static final String CONNECTION_ID = "sonarcloud" ;
142
140
143
141
private static WsClient adminWsClient ;
@@ -195,7 +193,7 @@ static void prepare() throws Exception {
195
193
static void cleanup () throws Exception {
196
194
adminWsClient .userTokens ()
197
195
.revoke (new RevokeRequest ().setName (TOKEN_NAME ));
198
-
196
+
199
197
var request = new PostRequest ("api/projects/bulk_delete" );
200
198
request .setParam ("q" , "-" + randomPositiveInt );
201
199
request .setParam ("organization" , SONARCLOUD_ORGANIZATION );
@@ -277,7 +275,7 @@ void should_use_enterprise_csharp_analyzer_with_sonarcloud() {
277
275
void getAllProjects () {
278
276
provisionProject ("foo-bar" , "Foo" );
279
277
var getAllProjectsParams = new GetAllProjectsParams (new TransientSonarCloudConnectionDto (SONARCLOUD_ORGANIZATION ,
280
- Either .forRight (new UsernamePasswordDto ( SONARCLOUD_USER , SONARCLOUD_PASSWORD ))));
278
+ Either .forLeft (new TokenDto ( SONARCLOUD_TOKEN ))));
281
279
282
280
waitAtMost (1 , TimeUnit .MINUTES ).untilAsserted (() -> assertThat (backend .getConnectionService ().getAllProjects (getAllProjectsParams ).get ().getSonarProjects ())
283
281
.extracting (SonarProjectDto ::getKey )
@@ -406,14 +404,14 @@ void analysisUseConfiguration() {
406
404
@ Test
407
405
void downloadUserOrganizations () throws ExecutionException , InterruptedException {
408
406
var response = backend .getConnectionService ()
409
- .listUserOrganizations (new ListUserOrganizationsParams (Either .forRight (new UsernamePasswordDto ( SONARCLOUD_USER , SONARCLOUD_PASSWORD )))).get ();
407
+ .listUserOrganizations (new ListUserOrganizationsParams (Either .forLeft (new TokenDto ( SONARCLOUD_TOKEN )))).get ();
410
408
assertThat (response .getUserOrganizations ()).hasSize (1 );
411
409
}
412
410
413
411
@ Test
414
412
void getOrganization () throws ExecutionException , InterruptedException {
415
413
var response = backend .getConnectionService ()
416
- .getOrganization (new GetOrganizationParams (Either .forRight (new UsernamePasswordDto ( SONARCLOUD_USER , SONARCLOUD_PASSWORD )), SONARCLOUD_ORGANIZATION )).get ();
414
+ .getOrganization (new GetOrganizationParams (Either .forLeft (new TokenDto ( SONARCLOUD_TOKEN )), SONARCLOUD_ORGANIZATION )).get ();
417
415
var org = response .getOrganization ();
418
416
assertThat (org ).isNotNull ();
419
417
assertThat (org .getKey ()).isEqualTo (SONARCLOUD_ORGANIZATION );
@@ -484,13 +482,13 @@ void analysisXml() {
484
482
void testConnection () throws ExecutionException , InterruptedException {
485
483
var successResponse = backend .getConnectionService ()
486
484
.validateConnection (
487
- new ValidateConnectionParams (new TransientSonarCloudConnectionDto (SONARCLOUD_ORGANIZATION , Either .forRight (new UsernamePasswordDto ( SONARCLOUD_USER , SONARCLOUD_PASSWORD )))))
485
+ new ValidateConnectionParams (new TransientSonarCloudConnectionDto (SONARCLOUD_ORGANIZATION , Either .forLeft (new TokenDto ( SONARCLOUD_TOKEN )))))
488
486
.get ();
489
487
assertThat (successResponse .isSuccess ()).isTrue ();
490
488
assertThat (successResponse .getMessage ()).isEqualTo ("Authentication successful" );
491
489
492
490
var failIfWrongOrg = backend .getConnectionService ().validateConnection (
493
- new ValidateConnectionParams (new TransientSonarCloudConnectionDto ("not-exists" , Either .forRight (new UsernamePasswordDto ( SONARCLOUD_USER , SONARCLOUD_PASSWORD ))))).get ();
491
+ new ValidateConnectionParams (new TransientSonarCloudConnectionDto ("not-exists" , Either .forLeft (new TokenDto ( SONARCLOUD_TOKEN ))))).get ();
494
492
assertThat (failIfWrongOrg .isSuccess ()).isFalse ();
495
493
assertThat (failIfWrongOrg .getMessage ()).isEqualTo ("No organizations found for key: not-exists" );
496
494
@@ -621,7 +619,7 @@ private void setSettingsMultiValue(@Nullable String moduleKey, String key, Strin
621
619
public static WsClient newAdminWsClient () {
622
620
return WsClientFactories .getDefault ().newClient (HttpConnector .newBuilder ()
623
621
.url (SONARCLOUD_STAGING_URL .toString ())
624
- .credentials ( SONARCLOUD_USER , SONARCLOUD_PASSWORD )
622
+ .token ( SONARCLOUD_TOKEN )
625
623
.build ());
626
624
}
627
625
@@ -675,7 +673,7 @@ private static SonarLintRpcClientDelegate newDummySonarLintClient() {
675
673
@ Override
676
674
public Either <TokenDto , UsernamePasswordDto > getCredentials (String connectionId ) throws ConnectionNotFoundException {
677
675
if (connectionId .equals (CONNECTION_ID )) {
678
- return Either .forRight (new UsernamePasswordDto ( SONARCLOUD_USER , SONARCLOUD_PASSWORD ));
676
+ return Either .forLeft (new TokenDto ( SONARCLOUD_TOKEN ));
679
677
}
680
678
return super .getCredentials (connectionId );
681
679
}
0 commit comments