Search in sources :

Example 1 with Deny

use of com.thoughtworks.go.config.rules.Deny in project gocd by gocd.

the class MagicalGoConfigXmlLoaderTest method shouldLoadSecretConfigs.

@Test
void shouldLoadSecretConfigs() {
    String content = config("<secretConfigs>" + "<secretConfig id=\"my_secret\" pluginId=\"gocd_file_based_plugin\">\n" + "    <description>All secrets for env1</description>" + "    <configuration>" + "       <property>\n" + "           <key>PasswordFilePath</key>\n" + "           <value>/godata/config/password.properties</value>\n" + "       </property>\n" + "    </configuration>" + "    <rules>\n" + "        <deny action=\"refer\" type=\"pipeline_group\">my_group</deny>\n" + "        <allow action=\"refer\" type=\"pipeline_group\">other_group</allow>  \n" + "    </rules>\n" + "</secretConfig>" + "</secretConfigs>", 116);
    CruiseConfig config = ConfigMigrator.load(content);
    SecretConfigs secretConfigs = config.getSecretConfigs();
    assertThat(secretConfigs.size()).isEqualTo(1);
    SecretConfig secretConfig = secretConfigs.first();
    assertThat(secretConfig.getId()).isEqualTo("my_secret");
    assertThat(secretConfig.getPluginId()).isEqualTo("gocd_file_based_plugin");
    assertThat(secretConfig.getDescription()).isEqualTo("All secrets for env1");
    Configuration configuration = secretConfig.getConfiguration();
    assertThat(configuration.size()).isEqualTo(1);
    assertThat(configuration.getProperty("PasswordFilePath").getValue()).isEqualTo("/godata/config/password.properties");
    Rules rules = secretConfig.getRules();
    assertThat(rules.size()).isEqualTo(2);
    assertThat(rules).containsExactly(new Deny("refer", "pipeline_group", "my_group"), new Allow("refer", "pipeline_group", "other_group"));
}
Also used : RepositoryConfiguration(com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) Deny(com.thoughtworks.go.config.rules.Deny) Rules(com.thoughtworks.go.config.rules.Rules) Allow(com.thoughtworks.go.config.rules.Allow) Test(org.junit.jupiter.api.Test)

Aggregations

Allow (com.thoughtworks.go.config.rules.Allow)1 Deny (com.thoughtworks.go.config.rules.Deny)1 Rules (com.thoughtworks.go.config.rules.Rules)1 PackageConfiguration (com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration)1 RepositoryConfiguration (com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration)1 PluginConfiguration (com.thoughtworks.go.plugin.domain.common.PluginConfiguration)1 Test (org.junit.jupiter.api.Test)1