Search in sources :

Example 1 with PassthroughProperty

use of com.synopsys.integration.configuration.property.base.PassthroughProperty in project synopsys-detect by blackducksoftware.

the class PropertyConfiguration method getMaskedRawValueMap.

@NotNull
public Map<String, String> getMaskedRawValueMap(@NotNull Set<Property> properties, Predicate<String> shouldMask) {
    Map<String, String> rawMap = new HashMap<>();
    for (Property property : properties) {
        String rawKey = property.getKey();
        if (property instanceof PassthroughProperty) {
            getRaw((PassthroughProperty) property).entrySet().forEach(passThrough -> {
                String fullPassThroughKey = String.format("%s.%s", rawKey, passThrough.getKey());
                rawMap.put(fullPassThroughKey, maskValue(fullPassThroughKey, passThrough.getValue(), shouldMask));
            });
        } else {
            getRaw(property).ifPresent(rawValue -> rawMap.put(rawKey, maskValue(rawKey, rawValue, shouldMask)));
        }
    }
    return rawMap;
}
Also used : HashMap(java.util.HashMap) NullableProperty(com.synopsys.integration.configuration.property.base.NullableProperty) PassthroughProperty(com.synopsys.integration.configuration.property.base.PassthroughProperty) TypedProperty(com.synopsys.integration.configuration.property.base.TypedProperty) ValuedProperty(com.synopsys.integration.configuration.property.base.ValuedProperty) Property(com.synopsys.integration.configuration.property.Property) PassthroughProperty(com.synopsys.integration.configuration.property.base.PassthroughProperty) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with PassthroughProperty

use of com.synopsys.integration.configuration.property.base.PassthroughProperty in project synopsys-detect by blackducksoftware.

the class PropertyConfigurationTest method getRawPassthroughPrimary.

@Test
public void getRawPassthroughPrimary() {
    PassthroughProperty passthrough = new PassthroughProperty("pass");
    PropertySource secondarySource = propertySourceOf("secondary", Pair.of("pass.shared", "secondaryValue"));
    PropertySource primarySource = propertySourceOf("primary", Pair.of("pass.shared", "primaryValue"));
    PropertyConfiguration configuration = configOf(primarySource, secondarySource);
    Map<String, String> properties = Bds.mapOf(Pair.of("shared", "primaryValue"));
    Assertions.assertEquals(properties, configuration.getRaw(passthrough));
}
Also used : PassthroughProperty(com.synopsys.integration.configuration.property.base.PassthroughProperty) PropertySource(com.synopsys.integration.configuration.source.PropertySource) Test(org.junit.jupiter.api.Test)

Example 3 with PassthroughProperty

use of com.synopsys.integration.configuration.property.base.PassthroughProperty in project synopsys-detect by blackducksoftware.

the class PropertyConfigurationTest method getRawPassthroughMultipleValues.

@Test
public void getRawPassthroughMultipleValues() {
    PassthroughProperty passthrough = new PassthroughProperty("pass");
    PropertySource secondarySource = propertySourceOf("secondary", Pair.of("pass.two", "two value"), Pair.of("ignore", "ignore value"));
    PropertySource primarySource = propertySourceOf("primary", Pair.of("pass.one", "one value"));
    PropertyConfiguration configuration = configOf(primarySource, secondarySource);
    Map<String, String> properties = Bds.mapOf(Pair.of("one", "one value"), Pair.of("two", "two value"));
    Assertions.assertEquals(properties, configuration.getRaw(passthrough));
}
Also used : PassthroughProperty(com.synopsys.integration.configuration.property.base.PassthroughProperty) PropertySource(com.synopsys.integration.configuration.source.PropertySource) Test(org.junit.jupiter.api.Test)

Example 4 with PassthroughProperty

use of com.synopsys.integration.configuration.property.base.PassthroughProperty in project synopsys-detect by blackducksoftware.

the class PropertyConfigurationTest method getRawValueMapWithPassthroughs.

@Test
public void getRawValueMapWithPassthroughs() {
    Set<Property> properties = new HashSet<>();
    PassthroughProperty passthrough = new PassthroughProperty("blackduck.passthrough");
    properties.add(passthrough);
    Map<String, String> propertyMap = Bds.mapOf(Pair.of("blackduck.passthrough.password", "password"));
    PropertyConfiguration configuration = configOf(propertyMap);
    Map<String, String> rawPropertyValues = configuration.getMaskedRawValueMap(properties, rawKey -> rawKey.contains("password"));
    Assertions.assertEquals("********", rawPropertyValues.get("blackduck.passthrough.password"));
}
Also used : NullableAlikeProperty(com.synopsys.integration.configuration.property.base.NullableAlikeProperty) Property(com.synopsys.integration.configuration.property.Property) ValuedAlikeProperty(com.synopsys.integration.configuration.property.base.ValuedAlikeProperty) PassthroughProperty(com.synopsys.integration.configuration.property.base.PassthroughProperty) NullableStringProperty(com.synopsys.integration.configuration.property.types.string.NullableStringProperty) PassthroughProperty(com.synopsys.integration.configuration.property.base.PassthroughProperty) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Aggregations

PassthroughProperty (com.synopsys.integration.configuration.property.base.PassthroughProperty)4 Test (org.junit.jupiter.api.Test)3 Property (com.synopsys.integration.configuration.property.Property)2 PropertySource (com.synopsys.integration.configuration.source.PropertySource)2 NullableAlikeProperty (com.synopsys.integration.configuration.property.base.NullableAlikeProperty)1 NullableProperty (com.synopsys.integration.configuration.property.base.NullableProperty)1 TypedProperty (com.synopsys.integration.configuration.property.base.TypedProperty)1 ValuedAlikeProperty (com.synopsys.integration.configuration.property.base.ValuedAlikeProperty)1 ValuedProperty (com.synopsys.integration.configuration.property.base.ValuedProperty)1 NullableStringProperty (com.synopsys.integration.configuration.property.types.string.NullableStringProperty)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 NotNull (org.jetbrains.annotations.NotNull)1