Search in sources :

Example 11 with Encryption

use of org.sonar.api.config.internal.Encryption in project sonarqube by SonarSource.

the class UpdateBitbucketActionTest method update.

@Test
public void update() {
    UserDto user = db.users().insertUser();
    userSession.logIn(user).setSystemAdministrator();
    AlmSettingDto almSettingDto = db.almSettings().insertBitbucketAlmSetting();
    ws.newRequest().setParam("key", almSettingDto.getKey()).setParam("url", "https://bitbucket.enterprise-unicorn.com").setParam("personalAccessToken", "10987654321").execute();
    assertThat(db.getDbClient().almSettingDao().selectAll(db.getSession())).extracting(AlmSettingDto::getKey, AlmSettingDto::getUrl, s -> s.getDecryptedPersonalAccessToken(encryption)).containsOnly(tuple(almSettingDto.getKey(), "https://bitbucket.enterprise-unicorn.com", "10987654321"));
}
Also used : AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto) UserSessionRule(org.sonar.server.tester.UserSessionRule) DbTester(org.sonar.db.DbTester) ComponentFinder(org.sonar.server.component.ComponentFinder) UserDto(org.sonar.db.user.UserDto) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) MultipleAlmFeatureProvider(org.sonar.server.almsettings.MultipleAlmFeatureProvider) Test(org.junit.Test) WsActionTester(org.sonar.server.ws.WsActionTester) NotFoundException(org.sonar.server.exceptions.NotFoundException) String.format(java.lang.String.format) Rule(org.junit.Rule) WebService(org.sonar.api.server.ws.WebService) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) Encryption(org.sonar.api.config.internal.Encryption) ForbiddenException(org.sonar.server.exceptions.ForbiddenException) Tuple.tuple(org.assertj.core.groups.Tuple.tuple) Mockito.mock(org.mockito.Mockito.mock) UserDto(org.sonar.db.user.UserDto) AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto) Test(org.junit.Test)

Example 12 with Encryption

use of org.sonar.api.config.internal.Encryption in project sonarqube by SonarSource.

the class UpdateGithubActionTest method update_with_new_key.

@Test
public void update_with_new_key() {
    UserDto user = db.users().insertUser();
    userSession.logIn(user).setSystemAdministrator();
    AlmSettingDto almSettingDto = db.almSettings().insertGitHubAlmSetting();
    ws.newRequest().setParam("key", almSettingDto.getKey()).setParam("newKey", "GitHub Server - Infra Team").setParam("url", "https://github.enterprise-unicorn.com").setParam("appId", "54321").setParam("privateKey", "10987654321").setParam("clientId", "client_1234").setParam("clientSecret", "client_so_secret").execute();
    assertThat(db.getDbClient().almSettingDao().selectAll(db.getSession())).extracting(AlmSettingDto::getKey, AlmSettingDto::getUrl, AlmSettingDto::getAppId, s -> s.getDecryptedPrivateKey(encryption), AlmSettingDto::getClientId, s -> s.getDecryptedClientSecret(encryption)).containsOnly(tuple("GitHub Server - Infra Team", "https://github.enterprise-unicorn.com", "54321", "10987654321", "client_1234", "client_so_secret"));
}
Also used : AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto) UserSessionRule(org.sonar.server.tester.UserSessionRule) DbTester(org.sonar.db.DbTester) ComponentFinder(org.sonar.server.component.ComponentFinder) UserDto(org.sonar.db.user.UserDto) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) MultipleAlmFeatureProvider(org.sonar.server.almsettings.MultipleAlmFeatureProvider) TestRequest(org.sonar.server.ws.TestRequest) Test(org.junit.Test) WsActionTester(org.sonar.server.ws.WsActionTester) NotFoundException(org.sonar.server.exceptions.NotFoundException) String.format(java.lang.String.format) Rule(org.junit.Rule) WebService(org.sonar.api.server.ws.WebService) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) Encryption(org.sonar.api.config.internal.Encryption) ForbiddenException(org.sonar.server.exceptions.ForbiddenException) Tuple.tuple(org.assertj.core.groups.Tuple.tuple) Mockito.mock(org.mockito.Mockito.mock) UserDto(org.sonar.db.user.UserDto) AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto) Test(org.junit.Test)

Example 13 with Encryption

use of org.sonar.api.config.internal.Encryption in project sonarqube by SonarSource.

the class UpdateGithubActionTest method update_url_with_trailing_slash.

@Test
public void update_url_with_trailing_slash() {
    UserDto user = db.users().insertUser();
    userSession.logIn(user).setSystemAdministrator();
    AlmSettingDto almSettingDto = db.almSettings().insertGitHubAlmSetting();
    ws.newRequest().setParam("key", almSettingDto.getKey()).setParam("url", "https://github.enterprise-unicorn.com/").setParam("appId", "54321").setParam("privateKey", "10987654321").setParam("clientId", "client_1234").setParam("clientSecret", "client_so_secret").execute();
    assertThat(db.getDbClient().almSettingDao().selectAll(db.getSession())).extracting(AlmSettingDto::getKey, AlmSettingDto::getUrl, AlmSettingDto::getAppId, s -> s.getDecryptedPrivateKey(encryption), AlmSettingDto::getClientId, s -> s.getDecryptedClientSecret(encryption)).containsOnly(tuple(almSettingDto.getKey(), "https://github.enterprise-unicorn.com", "54321", "10987654321", "client_1234", "client_so_secret"));
}
Also used : AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto) UserSessionRule(org.sonar.server.tester.UserSessionRule) DbTester(org.sonar.db.DbTester) ComponentFinder(org.sonar.server.component.ComponentFinder) UserDto(org.sonar.db.user.UserDto) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) MultipleAlmFeatureProvider(org.sonar.server.almsettings.MultipleAlmFeatureProvider) TestRequest(org.sonar.server.ws.TestRequest) Test(org.junit.Test) WsActionTester(org.sonar.server.ws.WsActionTester) NotFoundException(org.sonar.server.exceptions.NotFoundException) String.format(java.lang.String.format) Rule(org.junit.Rule) WebService(org.sonar.api.server.ws.WebService) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) Encryption(org.sonar.api.config.internal.Encryption) ForbiddenException(org.sonar.server.exceptions.ForbiddenException) Tuple.tuple(org.assertj.core.groups.Tuple.tuple) Mockito.mock(org.mockito.Mockito.mock) UserDto(org.sonar.db.user.UserDto) AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto) Test(org.junit.Test)

Example 14 with Encryption

use of org.sonar.api.config.internal.Encryption in project sonarqube by SonarSource.

the class UpdateGithubActionTest method update.

@Test
public void update() {
    UserDto user = db.users().insertUser();
    userSession.logIn(user).setSystemAdministrator();
    AlmSettingDto almSettingDto = db.almSettings().insertGitHubAlmSetting();
    ws.newRequest().setParam("key", almSettingDto.getKey()).setParam("url", "https://github.enterprise-unicorn.com").setParam("appId", "54321").setParam("privateKey", "10987654321").setParam("clientId", "client_1234").setParam("clientSecret", "client_so_secret").execute();
    assertThat(db.getDbClient().almSettingDao().selectAll(db.getSession())).extracting(AlmSettingDto::getKey, AlmSettingDto::getUrl, AlmSettingDto::getAppId, s -> s.getDecryptedPrivateKey(encryption), AlmSettingDto::getClientId, s -> s.getDecryptedClientSecret(encryption)).containsOnly(tuple(almSettingDto.getKey(), "https://github.enterprise-unicorn.com", "54321", "10987654321", "client_1234", "client_so_secret"));
}
Also used : AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto) UserSessionRule(org.sonar.server.tester.UserSessionRule) DbTester(org.sonar.db.DbTester) ComponentFinder(org.sonar.server.component.ComponentFinder) UserDto(org.sonar.db.user.UserDto) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) MultipleAlmFeatureProvider(org.sonar.server.almsettings.MultipleAlmFeatureProvider) TestRequest(org.sonar.server.ws.TestRequest) Test(org.junit.Test) WsActionTester(org.sonar.server.ws.WsActionTester) NotFoundException(org.sonar.server.exceptions.NotFoundException) String.format(java.lang.String.format) Rule(org.junit.Rule) WebService(org.sonar.api.server.ws.WebService) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) Encryption(org.sonar.api.config.internal.Encryption) ForbiddenException(org.sonar.server.exceptions.ForbiddenException) Tuple.tuple(org.assertj.core.groups.Tuple.tuple) Mockito.mock(org.mockito.Mockito.mock) UserDto(org.sonar.db.user.UserDto) AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto) Test(org.junit.Test)

Example 15 with Encryption

use of org.sonar.api.config.internal.Encryption in project sonarqube by SonarSource.

the class CreateGitlabActionTest method create_with_url.

@Test
public void create_with_url() {
    UserDto user = db.users().insertUser();
    userSession.logIn(user).setSystemAdministrator();
    ws.newRequest().setParam("key", "Gitlab - Dev Team").setParam("url", GITLAB_URL).setParam("personalAccessToken", "98765432100").execute();
    assertThat(db.getDbClient().almSettingDao().selectAll(db.getSession())).extracting(AlmSettingDto::getKey, AlmSettingDto::getUrl, s -> s.getDecryptedPersonalAccessToken(encryption)).containsOnly(tuple("Gitlab - Dev Team", GITLAB_URL, "98765432100"));
}
Also used : AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto) UserSessionRule(org.sonar.server.tester.UserSessionRule) DbTester(org.sonar.db.DbTester) ComponentFinder(org.sonar.server.component.ComponentFinder) UserDto(org.sonar.db.user.UserDto) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) MultipleAlmFeatureProvider(org.sonar.server.almsettings.MultipleAlmFeatureProvider) TestRequest(org.sonar.server.ws.TestRequest) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) WsActionTester(org.sonar.server.ws.WsActionTester) BadRequestException(org.sonar.server.exceptions.BadRequestException) Rule(org.junit.Rule) WebService(org.sonar.api.server.ws.WebService) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) Encryption(org.sonar.api.config.internal.Encryption) ForbiddenException(org.sonar.server.exceptions.ForbiddenException) Assertions(org.assertj.core.api.Assertions) Tuple.tuple(org.assertj.core.groups.Tuple.tuple) Before(org.junit.Before) Mockito.mock(org.mockito.Mockito.mock) UserDto(org.sonar.db.user.UserDto) Test(org.junit.Test)

Aggregations

Encryption (org.sonar.api.config.internal.Encryption)36 Test (org.junit.Test)35 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)30 Rule (org.junit.Rule)30 Mockito.mock (org.mockito.Mockito.mock)30 DbTester (org.sonar.db.DbTester)30 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)26 AlmSettingDto (org.sonar.db.alm.setting.AlmSettingDto)26 UserDto (org.sonar.db.user.UserDto)26 UserSessionRule (org.sonar.server.tester.UserSessionRule)26 WsActionTester (org.sonar.server.ws.WsActionTester)26 Tuple.tuple (org.assertj.core.groups.Tuple.tuple)25 WebService (org.sonar.api.server.ws.WebService)25 MultipleAlmFeatureProvider (org.sonar.server.almsettings.MultipleAlmFeatureProvider)25 ComponentFinder (org.sonar.server.component.ComponentFinder)25 ForbiddenException (org.sonar.server.exceptions.ForbiddenException)25 Mockito.when (org.mockito.Mockito.when)20 NotFoundException (org.sonar.server.exceptions.NotFoundException)20 String.format (java.lang.String.format)17 TestRequest (org.sonar.server.ws.TestRequest)17