Search in sources :

Example 1 with AESEncrypter

use of com.thoughtworks.go.security.AESEncrypter in project gocd by gocd.

the class MagicalGoConfigXmlLoaderTest method shouldMigrateDESEncryptedPluginPropertyValue_XslMigrationFrom108To109.

@Test
void shouldMigrateDESEncryptedPluginPropertyValue_XslMigrationFrom108To109(ResetCipher resetCipher) throws Exception {
    resetCipher.setupDESCipherFile();
    String clearText = "user-password!";
    // "user-password!" encrypted using the above key
    String desEncryptedPassword = "mvcX9yrQsM4iPgm1tDxN1A==";
    String content = configWithPluggableScm("" + "  <scm id='f7c309f5-ea4d-41c5-9c43-95d79fa9ec7b' name='gocd-private'>" + "      <pluginConfiguration id='github.pr' version='1' />" + "      <configuration>" + "        <property>" + "          <key>plainTextKey</key>" + "          <value>https://url/some_path</value>" + "        </property>" + "        <property>" + "          <key>secureKey</key>" + "          <encryptedValue>" + desEncryptedPassword + "</encryptedValue>" + "        </property>" + "      </configuration>" + "    </scm>", 108);
    CruiseConfig config = ConfigMigrator.loadWithMigration(content).config;
    assertThat(config.getSCMs().get(0).getConfiguration().getProperty("secureKey").getValue()).isEqualTo(clearText);
    String encryptedValue = config.getSCMs().get(0).getConfiguration().getProperty("secureKey").getEncryptedValue();
    assertThat(encryptedValue).startsWith("AES:");
    assertThat(new AESEncrypter(new AESCipherProvider(systemEnvironment)).decrypt(encryptedValue)).isEqualTo("user-password!");
    assertThat(config.getSCMs().get(0).getConfiguration().getProperty("plainTextKey").getValue()).isEqualTo("https://url/some_path");
}
Also used : AESEncrypter(com.thoughtworks.go.security.AESEncrypter) AESCipherProvider(com.thoughtworks.go.security.AESCipherProvider) Test(org.junit.jupiter.api.Test)

Example 2 with AESEncrypter

use of com.thoughtworks.go.security.AESEncrypter in project gocd by gocd.

the class MagicalGoConfigXmlLoaderTest method shouldMigrateDESEncryptedEnvironmentVariables_XslMigrationFrom108To109.

@Test
void shouldMigrateDESEncryptedEnvironmentVariables_XslMigrationFrom108To109(ResetCipher resetCipher) throws Exception {
    resetCipher.setupDESCipherFile();
    String clearText = "user-password!";
    // "user-password!" encrypted using the above key
    String desEncryptedPassword = "mvcX9yrQsM4iPgm1tDxN1A==";
    String content = configWithPipeline("" + "<pipeline name='some_pipeline'>" + "  <environmentvariables>" + "    <variable name='var_name' secure='true'>" + "      <encryptedValue>" + desEncryptedPassword + "</encryptedValue>" + "    </variable>" + "   </environmentvariables>" + "    <materials>" + "      <svn url='svnurl'/>" + "    </materials>" + "  <stage name='some_stage'>" + "    <jobs>" + "      <job name='some_job'><tasks><exec command='echo'><runif status='passed' /></exec></tasks>" + "      </job>" + "    </jobs>" + "  </stage>" + "</pipeline>", 108);
    CruiseConfig config = ConfigMigrator.loadWithMigration(content).config;
    assertThat(config.allPipelines().get(0).getVariables().get(0).getValue()).isEqualTo(clearText);
    String encryptedValue = config.allPipelines().get(0).getVariables().get(0).getEncryptedValue();
    assertThat(encryptedValue).startsWith("AES:");
    assertThat(new AESEncrypter(new AESCipherProvider(systemEnvironment)).decrypt(encryptedValue)).isEqualTo("user-password!");
}
Also used : AESEncrypter(com.thoughtworks.go.security.AESEncrypter) AESCipherProvider(com.thoughtworks.go.security.AESCipherProvider) Test(org.junit.jupiter.api.Test)

Aggregations

AESCipherProvider (com.thoughtworks.go.security.AESCipherProvider)2 AESEncrypter (com.thoughtworks.go.security.AESEncrypter)2 Test (org.junit.jupiter.api.Test)2