Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize useUserAccessToken to false. #6072

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.dataflow.core.DataFlowPropertyKeys;
import org.springframework.util.Assert;

/**
* Properties used to define the behavior of the composed task runner.
Expand All @@ -44,7 +45,7 @@ public class ComposedTaskRunnerConfigurationProperties {
* If true SCDF will set the dataflow-server-access-token for the composed
* task runner to the user's token when launching composed tasks.
*/
private Boolean useUserAccessToken;
private Boolean useUserAccessToken = false;

public String getUri() {
return uri;
Expand All @@ -67,6 +68,7 @@ public Boolean isUseUserAccessToken() {
}

public void setUseUserAccessToken(Boolean useUserAccessToken) {
Assert.notNull(useUserAccessToken, "'useUserAccessToken' cannot be null");
this.useUserAccessToken = useUserAccessToken;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

public class ComposedTaskRunnerConfigurationPropertiesTests {

Expand All @@ -43,7 +44,16 @@ void useUserAccessTokenFromCTRPropFalse() {
void useUserAccessTokenFromCTRPropNotSet() {
ComposedTaskRunnerConfigurationProperties composedTaskRunnerConfigurationProperties =
new ComposedTaskRunnerConfigurationProperties();
assertThat(composedTaskRunnerConfigurationProperties.isUseUserAccessToken()).as("Use user access token should be false").isNull();
assertThat(composedTaskRunnerConfigurationProperties.isUseUserAccessToken()).as("Use user access token should be false").isFalse();
onobc marked this conversation as resolved.
Show resolved Hide resolved
}

@Test
void setUserAccessTokenFromCTRToNull() {
ComposedTaskRunnerConfigurationProperties composedTaskRunnerConfigurationProperties =
new ComposedTaskRunnerConfigurationProperties();
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> composedTaskRunnerConfigurationProperties.setUseUserAccessToken(null)).
onobc marked this conversation as resolved.
Show resolved Hide resolved
withMessageContaining("'useUserAccessToken' cannot be null")
;
}

@Test
Expand Down
Loading