Skip to content

Commit c720475

Browse files
authored
Merge pull request #34 from bdpiparva/rename-oauth-token-key
Changed oauth_token in get plugin settings configuration
2 parents d2b8d27 + a1f25e7 commit c720475

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

src/main/java/cd/go/contrib/elasticagent/executors/GetPluginConfigurationExecutor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class GetPluginConfigurationExecutor implements RequestExecutor {
3333
public static final Field MAX_PENDING_PODS = new PositiveNumberField("pending_pods_count", "Maximum pending pods", "10", false, false, "2");
3434
public static final Field CLUSTER_URL = new HttpsURLField("kubernetes_cluster_url", "Cluster URL", true, "3");
3535
public static final Field NAMESPACE = new Field("namespace", "Namespace", "default", false, false, "4");
36-
public static final Field OAUTH_TOKEN = new NonBlankField("oauth_token", "Oauth token", true, "5");
36+
public static final Field SECURITY_TOKEN = new NonBlankField("security_token", "Security token", true, "5");
3737
public static final Field CLUSTER_CA_CERT = new Field("kubernetes_cluster_ca_cert", "Cluster ca certificate", null, false, true, "6");
3838

3939
static {
@@ -42,7 +42,7 @@ public class GetPluginConfigurationExecutor implements RequestExecutor {
4242
FIELDS.put(MAX_PENDING_PODS.key(), MAX_PENDING_PODS);
4343
FIELDS.put(CLUSTER_URL.key(), CLUSTER_URL);
4444
FIELDS.put(CLUSTER_CA_CERT.key(), CLUSTER_CA_CERT);
45-
FIELDS.put(OAUTH_TOKEN.key(), OAUTH_TOKEN);
45+
FIELDS.put(SECURITY_TOKEN.key(), SECURITY_TOKEN);
4646
FIELDS.put(NAMESPACE.key(), NAMESPACE);
4747
}
4848

src/main/resources/plugin-settings.template.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@
116116
<label>Security token
117117
<span class='asterix'>*</span>
118118
</label>
119-
<textarea rows="5" ng-model="oauth_token"></textarea>
120-
<span class="form_error form-error" ng-show="GOINPUTNAME[oauth_token].$error.server">{{GOINPUTNAME[oauth_token].$error.server}}</span>
119+
<textarea rows="5" ng-model="security_token"></textarea>
120+
<span class="form_error form-error" ng-show="GOINPUTNAME[security_token].$error.server">{{GOINPUTNAME[security_token].$error.server}}</span>
121121
<label class="form-help-content">
122122
Get the service account token by running following command <code>kubectl describe secret
123123
TOKEN_NAME</code> and copy the value of token here.

src/test/java/cd/go/contrib/elasticagent/executors/GetPluginConfigurationExecutorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ public void assertJsonStructure() throws Exception {
8080
" \"secure\": false,\n" +
8181
" \"display-order\": \"4\"\n" +
8282
" },\n" +
83-
" \"oauth_token\": {\n" +
84-
" \"display-name\": \"Oauth token\",\n" +
83+
" \"security_token\": {\n" +
84+
" \"display-name\": \"Security token\",\n" +
8585
" \"required\": true,\n" +
8686
" \"secure\": true,\n" +
8787
" \"display-order\": \"5\"\n" +

src/test/java/cd/go/contrib/elasticagent/executors/ValidateConfigurationExecutorTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ public void shouldValidateABadConfiguration() throws Exception {
8787
" \"key\": \"kubernetes_cluster_url\"\n" +
8888
" },\n" +
8989
" {\n" +
90-
" \"message\": \"Oauth token must not be blank.\",\n" +
91-
" \"key\": \"oauth_token\"\n" +
90+
" \"message\": \"Security token must not be blank.\",\n" +
91+
" \"key\": \"security_token\"\n" +
9292
" }\n" +
9393
"]", response.responseBody(), true);
9494
}
@@ -100,7 +100,7 @@ public void shouldValidateAGoodConfiguration() throws Exception {
100100
ValidatePluginSettingsRequest settings = new ValidatePluginSettingsRequest();
101101
settings.put("go_server_url", "https://ci.example.com/go");
102102
settings.put("kubernetes_cluster_url", "https://cluster.example.com");
103-
settings.put("oauth_token", "some-token");
103+
settings.put("security_token", "some-token");
104104
GoPluginApiResponse response = new ValidateConfigurationExecutor(settings, null, factory).execute();
105105

106106
assertThat(response.responseCode(), is(200));
@@ -114,7 +114,7 @@ public void shouldValidateGoServerUrl() throws Exception {
114114
ValidatePluginSettingsRequest settings = new ValidatePluginSettingsRequest();
115115
serverInfo.setSecureSiteUrl(null);
116116
settings.put("kubernetes_cluster_url", "https://cluster.example.com");
117-
settings.put("oauth_token", "some-token");
117+
settings.put("security_token", "some-token");
118118
GoPluginApiResponse response = new ValidateConfigurationExecutor(settings, pluginRequest, factory).execute();
119119

120120
assertThat(response.responseCode(), is(200));
@@ -133,7 +133,7 @@ public void shouldValidateGoServerHTTPSUrlFormat() throws Exception {
133133
ValidatePluginSettingsRequest settings = new ValidatePluginSettingsRequest();
134134
settings.put("go_server_url", "foo.com/go(");
135135
settings.put("kubernetes_cluster_url", "https://cluster.example.com");
136-
settings.put("oauth_token", "some-token");
136+
settings.put("security_token", "some-token");
137137
GoPluginApiResponse response = new ValidateConfigurationExecutor(settings, pluginRequest, factory).execute();
138138

139139
assertThat(response.responseCode(), is(200));
@@ -152,7 +152,7 @@ public void shouldValidateGoServerUrlFormat() throws Exception {
152152
ValidatePluginSettingsRequest settings = new ValidatePluginSettingsRequest();
153153
settings.put("go_server_url", "https://foo.com");
154154
settings.put("kubernetes_cluster_url", "https://cluster.example.com");
155-
settings.put("oauth_token", "some-token");
155+
settings.put("security_token", "some-token");
156156
GoPluginApiResponse response = new ValidateConfigurationExecutor(settings, pluginRequest, factory).execute();
157157

158158
assertThat(response.responseCode(), is(200));
@@ -178,8 +178,8 @@ public void shouldValidateOAuthTokenWhenAuthenticationStrategyIsSetToOauthToken(
178178

179179
JSONAssert.assertEquals("[" +
180180
" {\n" +
181-
" \"message\": \"Oauth token must not be blank.\",\n" +
182-
" \"key\": \"oauth_token\"\n" +
181+
" \"message\": \"Security token must not be blank.\",\n" +
182+
" \"key\": \"security_token\"\n" +
183183
" }\n" +
184184
"]", response.responseBody(), true);
185185
}
@@ -191,7 +191,7 @@ public void shouldValidateNamespaceExistence() throws JSONException {
191191
ValidatePluginSettingsRequest settings = new ValidatePluginSettingsRequest();
192192
settings.put("go_server_url", "https://ci.example.com/go");
193193
settings.put("kubernetes_cluster_url", "https://cluster.example.com");
194-
settings.put("oauth_token", "some-token");
194+
settings.put("security_token", "some-token");
195195
settings.put("namespace", "gocd");
196196
GoPluginApiResponse response = new ValidateConfigurationExecutor(settings, null, factory).execute();
197197

0 commit comments

Comments
 (0)