Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions components/camel-aws/camel-aws-parameter-store/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
<artifactId>camel-test-spring-junit6</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>

<!-- test infra -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,10 @@ private void putParameter(SsmClient ssmClient, Exchange exchange)
} else {
throw new IllegalArgumentException("Parameter Name must be specified");
}
String payload = exchange.getIn().getMandatoryBody(String.class);
String payload = exchange.getIn().getHeader(ParameterStoreConstants.PARAMETER_VALUE, String.class);
if (ObjectHelper.isEmpty(payload)) {
payload = exchange.getIn().getMandatoryBody(String.class);
}
builder.value(payload);
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ParameterStoreConstants.PARAMETER_TYPE))) {
String type = exchange.getIn().getHeader(ParameterStoreConstants.PARAMETER_TYPE, String.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.component.aws.parameterstore;

import org.apache.camel.Exchange;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.support.DefaultExchange;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import software.amazon.awssdk.services.ssm.SsmClient;
import software.amazon.awssdk.services.ssm.model.PutParameterRequest;
import software.amazon.awssdk.services.ssm.model.PutParameterResponse;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;

class ParameterStoreProducerTest {

@Test
void putParameterHonorsTheValueHeader() throws Exception {
try (DefaultCamelContext context = new DefaultCamelContext()) {
SsmClient client = Mockito.mock(SsmClient.class);
ArgumentCaptor<PutParameterRequest> captor = ArgumentCaptor.forClass(PutParameterRequest.class);
when(client.putParameter(captor.capture())).thenReturn(PutParameterResponse.builder().build());

ParameterStoreConfiguration configuration = new ParameterStoreConfiguration();
configuration.setSsmClient(client);
ParameterStoreEndpoint endpoint
= new ParameterStoreEndpoint("aws-parameter-store://test", null, configuration);
endpoint.setCamelContext(context);
endpoint.start();

ParameterStoreProducer producer = new ParameterStoreProducer(endpoint);

Exchange exchange = new DefaultExchange(context);
exchange.getIn().setHeader(ParameterStoreConstants.OPERATION, ParameterStoreOperations.putParameter);
exchange.getIn().setHeader(ParameterStoreConstants.PARAMETER_NAME, "myParam");
exchange.getIn().setHeader(ParameterStoreConstants.PARAMETER_VALUE, "valueFromHeader");
exchange.getIn().setBody("valueFromBody");

producer.process(exchange);

// the CamelAwsParameterStoreValue header used to be ignored (the value always came from the body);
// it must now be honored when present
assertThat(captor.getValue().value()).isEqualTo("valueFromHeader");
}
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class EKS2Configuration implements Cloneable, AwsCommonConfiguration {
private boolean useProfileCredentialsProvider;
@UriParam(label = "security")
private boolean useSessionCredentials;
@UriParam(defaultValue = "false")
@UriParam(label = "security")
private String profileCredentialsName;

public EksClient getEksClient() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public void doStop() throws Exception {
iamClient.close();
}
}
super.doStop();
}

public IAM2Configuration getConfiguration() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,24 +142,6 @@ default Aws2EksComponentBuilder pojoRequest(boolean pojoRequest) {
return this;
}


/**
* If using a profile credentials provider, this parameter will set the
* profile name.
*
* The option is a: &lt;code&gt;java.lang.String&lt;/code&gt; type.
*
* Default: false
* Group: producer
*
* @param profileCredentialsName the value to set
* @return the dsl builder
*/
default Aws2EksComponentBuilder profileCredentialsName(java.lang.String profileCredentialsName) {
doSetProperty("profileCredentialsName", profileCredentialsName);
return this;
}

/**
* The region in which EKS client needs to work. When using this
* parameter, the configuration will expect the lowercase name of the
Expand Down Expand Up @@ -370,6 +352,22 @@ default Aws2EksComponentBuilder accessKey(java.lang.String accessKey) {
return this;
}

/**
* If using a profile credentials provider, this parameter will set the
* profile name.
*
* The option is a: &lt;code&gt;java.lang.String&lt;/code&gt; type.
*
* Group: security
*
* @param profileCredentialsName the value to set
* @return the dsl builder
*/
default Aws2EksComponentBuilder profileCredentialsName(java.lang.String profileCredentialsName) {
doSetProperty("profileCredentialsName", profileCredentialsName);
return this;
}

/**
* Amazon AWS Secret Key.
*
Expand Down Expand Up @@ -463,7 +461,6 @@ protected boolean setPropertyOnComponent(
case "operation": getOrCreateConfiguration((EKS2Component) component).setOperation((org.apache.camel.component.aws2.eks.EKS2Operations) value); return true;
case "overrideEndpoint": getOrCreateConfiguration((EKS2Component) component).setOverrideEndpoint((boolean) value); return true;
case "pojoRequest": getOrCreateConfiguration((EKS2Component) component).setPojoRequest((boolean) value); return true;
case "profileCredentialsName": getOrCreateConfiguration((EKS2Component) component).setProfileCredentialsName((java.lang.String) value); return true;
case "region": getOrCreateConfiguration((EKS2Component) component).setRegion((java.lang.String) value); return true;
case "uriEndpointOverride": getOrCreateConfiguration((EKS2Component) component).setUriEndpointOverride((java.lang.String) value); return true;
case "useDefaultCredentialsProvider": getOrCreateConfiguration((EKS2Component) component).setUseDefaultCredentialsProvider((boolean) value); return true;
Expand All @@ -476,6 +473,7 @@ protected boolean setPropertyOnComponent(
case "proxyPort": getOrCreateConfiguration((EKS2Component) component).setProxyPort((java.lang.Integer) value); return true;
case "proxyProtocol": getOrCreateConfiguration((EKS2Component) component).setProxyProtocol((software.amazon.awssdk.core.Protocol) value); return true;
case "accessKey": getOrCreateConfiguration((EKS2Component) component).setAccessKey((java.lang.String) value); return true;
case "profileCredentialsName": getOrCreateConfiguration((EKS2Component) component).setProfileCredentialsName((java.lang.String) value); return true;
case "secretKey": getOrCreateConfiguration((EKS2Component) component).setSecretKey((java.lang.String) value); return true;
case "sessionToken": getOrCreateConfiguration((EKS2Component) component).setSessionToken((java.lang.String) value); return true;
case "trustAllCertificates": getOrCreateConfiguration((EKS2Component) component).setTrustAllCertificates((boolean) value); return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,6 @@ default EKS2EndpointBuilder pojoRequest(String pojoRequest) {
doSetProperty("pojoRequest", pojoRequest);
return this;
}
/**
* If using a profile credentials provider, this parameter will set the
* profile name.
*
* The option is a: <code>java.lang.String</code> type.
*
* Default: false
* Group: producer
*
* @param profileCredentialsName the value to set
* @return the dsl builder
*/
default EKS2EndpointBuilder profileCredentialsName(String profileCredentialsName) {
doSetProperty("profileCredentialsName", profileCredentialsName);
return this;
}
/**
* The region in which EKS client needs to work. When using this
* parameter, the configuration will expect the lowercase name of the
Expand Down Expand Up @@ -341,6 +325,21 @@ default EKS2EndpointBuilder accessKey(String accessKey) {
doSetProperty("accessKey", accessKey);
return this;
}
/**
* If using a profile credentials provider, this parameter will set the
* profile name.
*
* The option is a: <code>java.lang.String</code> type.
*
* Group: security
*
* @param profileCredentialsName the value to set
* @return the dsl builder
*/
default EKS2EndpointBuilder profileCredentialsName(String profileCredentialsName) {
doSetProperty("profileCredentialsName", profileCredentialsName);
return this;
}
/**
* Amazon AWS Secret Key.
*
Expand Down