From 5b105b2b10e5ef0055e152992d4ec827728ebe8e Mon Sep 17 00:00:00 2001 From: Jake Cohen Date: Fri, 24 May 2024 14:06:53 -0700 Subject: [PATCH 1/9] testing property mapping --- .../edu/ohio/ais/rundeck/HttpDescription.java | 2 + .../rundeck/HttpWorkflowNodeStepPlugin.java | 45 ++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/ohio/ais/rundeck/HttpDescription.java b/src/main/java/edu/ohio/ais/rundeck/HttpDescription.java index db1034f..e3fd382 100644 --- a/src/main/java/edu/ohio/ais/rundeck/HttpDescription.java +++ b/src/main/java/edu/ohio/ais/rundeck/HttpDescription.java @@ -165,6 +165,8 @@ public Description getDescription() { .defaultValue("false") .renderingOption(StringRenderingConstants.GROUP_NAME,"Print") .build()) + .mapping("proxyIP","project.plugin.WorkflowNodeStep.HttpWorkflowNodeStepPlugin.proxyIP") + .build(); } } diff --git a/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPlugin.java b/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPlugin.java index ff4cd30..e1c2ec8 100644 --- a/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPlugin.java +++ b/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPlugin.java @@ -5,16 +5,20 @@ import com.dtolabs.rundeck.core.execution.ExecutionContext; import com.dtolabs.rundeck.core.execution.proxy.ProxySecretBundleCreator; import com.dtolabs.rundeck.core.execution.proxy.SecretBundle; +import com.dtolabs.rundeck.core.execution.utils.ResolverUtil; import com.dtolabs.rundeck.core.execution.workflow.steps.StepException; import com.dtolabs.rundeck.core.execution.workflow.steps.StepFailureReason; import com.dtolabs.rundeck.core.execution.workflow.steps.node.NodeStepException; import com.dtolabs.rundeck.core.plugins.Plugin; import com.dtolabs.rundeck.core.plugins.configuration.Describable; import com.dtolabs.rundeck.core.plugins.configuration.Description; +import com.dtolabs.rundeck.core.utils.IPropertyLookup; import com.dtolabs.rundeck.plugins.PluginLogger; import com.dtolabs.rundeck.plugins.ServiceNameConstants; +import com.dtolabs.rundeck.plugins.descriptions.PluginProperty; import com.dtolabs.rundeck.plugins.step.NodeStepPlugin; import com.dtolabs.rundeck.plugins.step.PluginStepContext; +import com.dtolabs.rundeck.plugins.util.DescriptionBuilder; import edu.ohio.ais.rundeck.util.OAuthClient; import edu.ohio.ais.rundeck.util.SecretBundleUtil; import org.apache.http.HttpEntity; @@ -26,7 +30,7 @@ import java.util.*; @Plugin(name = HttpWorkflowNodeStepPlugin.SERVICE_PROVIDER_NAME, service = ServiceNameConstants.WorkflowNodeStep) -public class HttpWorkflowNodeStepPlugin implements NodeStepPlugin, Describable, ProxySecretBundleCreator { +public class HttpWorkflowNodeStepPlugin implements NodeStepPlugin, Describable, ProxySecretBundleCreator, DescriptionBuilder.Collaborator { public static final String SERVICE_PROVIDER_NAME = "edu.ohio.ais.rundeck.HttpWorkflowNodeStepPlugin"; /** @@ -40,6 +44,12 @@ public class HttpWorkflowNodeStepPlugin implements NodeStepPlugin, Describable, */ public static final Integer DEFAULT_TIMEOUT = 30*1000; +// @PluginProperty( +// title = "Proxy URL", +// description = "HTTP URL to which to make the request.", +// required = true +// ) +// String proxyURL; /** * Synchronized map of all existing OAuth clients. This is indexed by @@ -58,6 +68,14 @@ public Description getDescription() { public void executeNodeStep(PluginStepContext context, Map configuration, INodeEntry entry) throws NodeStepException { PluginLogger log = context.getLogger(); + System.out.println("pre-resolver proxyIp: " + configuration.get("proxyIP")); +// propertyResolver("proxySettings", configuration, context); + propertyResolver("proxyIP", configuration, context); +// propertyResolver("proxyPort", configuration, context); + + System.out.println("post-resolver proxyIp: " + configuration.get("proxyIP")); +// System.out.println("proxySettings: " + configuration.get("proxySettings")); + // Parse out the options String remoteUrl = configuration.containsKey("remoteUrl") ? configuration.get("remoteUrl").toString() : null; String method = configuration.containsKey("method") ? configuration.get("method").toString() : null; @@ -146,4 +164,29 @@ public SecretBundle prepareSecretBundleWorkflowNodeStep(ExecutionContext context public List listSecretsPathWorkflowNodeStep(ExecutionContext context, INodeEntry node, Map configuration) { return SecretBundleUtil.getListSecrets(configuration); } + + void propertyResolver(String property, Map Configuration, PluginStepContext context) { + + String projectPrefix = "project.plugin.WorkflowNodeStep." + "HttpWorkflowNodeStepPlugin" + "."; + String frameworkPrefix = "framework.plugin.WorkflowNodeStep" + SERVICE_PROVIDER_NAME + "."; + + Map projectProperties = context.getFramework().getFrameworkProjectMgr().getFrameworkProject(context.getFrameworkProject()).getProperties(); + IPropertyLookup frameworkProperties = context.getFramework().getPropertyLookup(); + + if(!Configuration.containsKey(property) && projectProperties.containsKey(projectPrefix + property)) { + + Configuration.put(property, projectProperties.get(projectPrefix + property)); + + } else if (!Configuration.containsKey(property) && frameworkProperties.hasProperty(frameworkPrefix + property)) { + + Configuration.put(property, frameworkProperties.getProperty(frameworkPrefix + property)); + + } + System.out.println("resolver: " + Configuration.get(property)); + } + + @Override + public void buildWith(DescriptionBuilder descriptionBuilder) { + descriptionBuilder.mapping("proxyIP", "project.plugin.WorkflowNodeStep.HTTPRequest.proxyIP"); + } } From 966510e16ea4842e200a355e8310a6121af9516c Mon Sep 17 00:00:00 2001 From: Jake Cohen Date: Fri, 24 May 2024 14:26:44 -0700 Subject: [PATCH 2/9] refining solution --- .../edu/ohio/ais/rundeck/HttpDescription.java | 2 -- .../rundeck/HttpWorkflowNodeStepPlugin.java | 18 ++++++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/main/java/edu/ohio/ais/rundeck/HttpDescription.java b/src/main/java/edu/ohio/ais/rundeck/HttpDescription.java index e3fd382..db1034f 100644 --- a/src/main/java/edu/ohio/ais/rundeck/HttpDescription.java +++ b/src/main/java/edu/ohio/ais/rundeck/HttpDescription.java @@ -165,8 +165,6 @@ public Description getDescription() { .defaultValue("false") .renderingOption(StringRenderingConstants.GROUP_NAME,"Print") .build()) - .mapping("proxyIP","project.plugin.WorkflowNodeStep.HttpWorkflowNodeStepPlugin.proxyIP") - .build(); } } diff --git a/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPlugin.java b/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPlugin.java index e1c2ec8..6d44137 100644 --- a/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPlugin.java +++ b/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPlugin.java @@ -30,7 +30,7 @@ import java.util.*; @Plugin(name = HttpWorkflowNodeStepPlugin.SERVICE_PROVIDER_NAME, service = ServiceNameConstants.WorkflowNodeStep) -public class HttpWorkflowNodeStepPlugin implements NodeStepPlugin, Describable, ProxySecretBundleCreator, DescriptionBuilder.Collaborator { +public class HttpWorkflowNodeStepPlugin implements NodeStepPlugin, Describable, ProxySecretBundleCreator { public static final String SERVICE_PROVIDER_NAME = "edu.ohio.ais.rundeck.HttpWorkflowNodeStepPlugin"; /** @@ -68,9 +68,11 @@ public Description getDescription() { public void executeNodeStep(PluginStepContext context, Map configuration, INodeEntry entry) throws NodeStepException { PluginLogger log = context.getLogger(); - System.out.println("pre-resolver proxyIp: " + configuration.get("proxyIP")); -// propertyResolver("proxySettings", configuration, context); - propertyResolver("proxyIP", configuration, context); + Description description = new HttpDescription(SERVICE_PROVIDER_NAME, "HTTP Request Node Step", "Performs an HTTP request with or without authentication (per node)").getDescription(); + description.getProperties().forEach(prop-> + propertyResolver(prop.getName(), configuration, context) + ); +// propertyResolver("proxyIP", configuration, context); // propertyResolver("proxyPort", configuration, context); System.out.println("post-resolver proxyIp: " + configuration.get("proxyIP")); @@ -167,7 +169,7 @@ public List listSecretsPathWorkflowNodeStep(ExecutionContext context, IN void propertyResolver(String property, Map Configuration, PluginStepContext context) { - String projectPrefix = "project.plugin.WorkflowNodeStep." + "HttpWorkflowNodeStepPlugin" + "."; + String projectPrefix = "project.plugin.WorkflowNodeStep." + SERVICE_PROVIDER_NAME + "."; String frameworkPrefix = "framework.plugin.WorkflowNodeStep" + SERVICE_PROVIDER_NAME + "."; Map projectProperties = context.getFramework().getFrameworkProjectMgr().getFrameworkProject(context.getFrameworkProject()).getProperties(); @@ -182,11 +184,7 @@ void propertyResolver(String property, Map Configuration, PluginS Configuration.put(property, frameworkProperties.getProperty(frameworkPrefix + property)); } - System.out.println("resolver: " + Configuration.get(property)); + System.out.println("resolver: " + property + Configuration.get(property)); } - @Override - public void buildWith(DescriptionBuilder descriptionBuilder) { - descriptionBuilder.mapping("proxyIP", "project.plugin.WorkflowNodeStep.HTTPRequest.proxyIP"); - } } From b47ec158e60346217d7f2c76323f87bdd59160f9 Mon Sep 17 00:00:00 2001 From: Jake Cohen Date: Fri, 24 May 2024 15:00:13 -0700 Subject: [PATCH 3/9] adding property resolver to both plugins --- .../edu/ohio/ais/rundeck/HttpBuilder.java | 22 ++++++++++++ .../rundeck/HttpWorkflowNodeStepPlugin.java | 36 ++----------------- .../ais/rundeck/HttpWorkflowStepPlugin.java | 7 ++++ .../HttpWorkflowNodeStepPluginTest.java | 19 ++++++++++ 4 files changed, 51 insertions(+), 33 deletions(-) diff --git a/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java b/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java index 9da715e..28763d2 100644 --- a/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java +++ b/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java @@ -4,6 +4,7 @@ import com.dtolabs.rundeck.core.execution.workflow.steps.StepException; import com.dtolabs.rundeck.core.execution.workflow.steps.StepFailureReason; import com.dtolabs.rundeck.core.storage.ResourceMeta; +import com.dtolabs.rundeck.core.utils.IPropertyLookup; import com.dtolabs.rundeck.plugins.PluginLogger; import com.dtolabs.rundeck.plugins.step.PluginStepContext; import com.google.gson.Gson; @@ -108,6 +109,9 @@ public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws Ce httpClientBuilder.setSSLContext(sslContextBuilder.build()); } if(options.containsKey("proxySettings") && Boolean.parseBoolean(options.get("proxySettings").toString())){ + log.log(5, "using proxy IP: " + options.get("proxyIP").toString()); + log.log(5, "using proxy Port: " + options.get("proxyPort").toString()); + HttpHost proxy = new HttpHost(options.get("proxyIP").toString(), Integer.valueOf((String)options.get("proxyPort")), "http"); httpClientBuilder.setProxy(proxy); } @@ -460,5 +464,23 @@ public void setHeaders(String headers, RequestBuilder request){ } } + static void propertyResolver(String property, Map Configuration, PluginStepContext context, String SERVICE_PROVIDER_NAME) { + + String projectPrefix = "project.plugin.WorkflowNodeStep." + SERVICE_PROVIDER_NAME + "."; + String frameworkPrefix = "framework.plugin.WorkflowNodeStep" + SERVICE_PROVIDER_NAME + "."; + + Map projectProperties = context.getFramework().getFrameworkProjectMgr().getFrameworkProject(context.getFrameworkProject()).getProperties(); + IPropertyLookup frameworkProperties = context.getFramework().getPropertyLookup(); + + if(!Configuration.containsKey(property) && projectProperties.containsKey(projectPrefix + property)) { + + Configuration.put(property, projectProperties.get(projectPrefix + property)); + + } else if (!Configuration.containsKey(property) && frameworkProperties.hasProperty(frameworkPrefix + property)) { + + Configuration.put(property, frameworkProperties.getProperty(frameworkPrefix + property)); + + } + } } diff --git a/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPlugin.java b/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPlugin.java index 6d44137..60789e5 100644 --- a/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPlugin.java +++ b/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPlugin.java @@ -29,6 +29,8 @@ import java.io.UnsupportedEncodingException; import java.util.*; +import static edu.ohio.ais.rundeck.HttpBuilder.propertyResolver; + @Plugin(name = HttpWorkflowNodeStepPlugin.SERVICE_PROVIDER_NAME, service = ServiceNameConstants.WorkflowNodeStep) public class HttpWorkflowNodeStepPlugin implements NodeStepPlugin, Describable, ProxySecretBundleCreator { public static final String SERVICE_PROVIDER_NAME = "edu.ohio.ais.rundeck.HttpWorkflowNodeStepPlugin"; @@ -44,13 +46,6 @@ public class HttpWorkflowNodeStepPlugin implements NodeStepPlugin, Describable, */ public static final Integer DEFAULT_TIMEOUT = 30*1000; -// @PluginProperty( -// title = "Proxy URL", -// description = "HTTP URL to which to make the request.", -// required = true -// ) -// String proxyURL; - /** * Synchronized map of all existing OAuth clients. This is indexed by * the Client ID and the token URL so that we can store and re-use access tokens. @@ -70,13 +65,8 @@ public void executeNodeStep(PluginStepContext context, Map confi Description description = new HttpDescription(SERVICE_PROVIDER_NAME, "HTTP Request Node Step", "Performs an HTTP request with or without authentication (per node)").getDescription(); description.getProperties().forEach(prop-> - propertyResolver(prop.getName(), configuration, context) + propertyResolver(prop.getName(), configuration, context, SERVICE_PROVIDER_NAME) ); -// propertyResolver("proxyIP", configuration, context); -// propertyResolver("proxyPort", configuration, context); - - System.out.println("post-resolver proxyIp: " + configuration.get("proxyIP")); -// System.out.println("proxySettings: " + configuration.get("proxySettings")); // Parse out the options String remoteUrl = configuration.containsKey("remoteUrl") ? configuration.get("remoteUrl").toString() : null; @@ -167,24 +157,4 @@ public List listSecretsPathWorkflowNodeStep(ExecutionContext context, IN return SecretBundleUtil.getListSecrets(configuration); } - void propertyResolver(String property, Map Configuration, PluginStepContext context) { - - String projectPrefix = "project.plugin.WorkflowNodeStep." + SERVICE_PROVIDER_NAME + "."; - String frameworkPrefix = "framework.plugin.WorkflowNodeStep" + SERVICE_PROVIDER_NAME + "."; - - Map projectProperties = context.getFramework().getFrameworkProjectMgr().getFrameworkProject(context.getFrameworkProject()).getProperties(); - IPropertyLookup frameworkProperties = context.getFramework().getPropertyLookup(); - - if(!Configuration.containsKey(property) && projectProperties.containsKey(projectPrefix + property)) { - - Configuration.put(property, projectProperties.get(projectPrefix + property)); - - } else if (!Configuration.containsKey(property) && frameworkProperties.hasProperty(frameworkPrefix + property)) { - - Configuration.put(property, frameworkProperties.getProperty(frameworkPrefix + property)); - - } - System.out.println("resolver: " + property + Configuration.get(property)); - } - } diff --git a/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowStepPlugin.java b/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowStepPlugin.java index fbe4dbb..c5c2083 100644 --- a/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowStepPlugin.java +++ b/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowStepPlugin.java @@ -23,6 +23,8 @@ import java.io.*; import java.util.*; +import static edu.ohio.ais.rundeck.HttpBuilder.propertyResolver; + /** * Main implementation of the plugin. This will handle fetching @@ -69,6 +71,11 @@ public Description getDescription() { public void executeStep(PluginStepContext pluginStepContext, Map options) throws StepException { PluginLogger log = pluginStepContext.getLogger(); + Description description = new HttpDescription(SERVICE_PROVIDER_NAME, "HTTP Request Node Step", "Performs an HTTP request with or without authentication (per node)").getDescription(); + description.getProperties().forEach(prop-> + propertyResolver(prop.getName(), options, pluginStepContext, SERVICE_PROVIDER_NAME) + ); + // Parse out the options String remoteUrl = options.containsKey("remoteUrl") ? options.get("remoteUrl").toString() : null; String method = options.containsKey("method") ? options.get("method").toString() : null; diff --git a/src/test/java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPluginTest.java b/src/test/java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPluginTest.java index 85aea58..5b0dfea 100644 --- a/src/test/java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPluginTest.java +++ b/src/test/java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPluginTest.java @@ -1,11 +1,15 @@ package edu.ohio.ais.rundeck; +import com.dtolabs.rundeck.core.common.Framework; +import com.dtolabs.rundeck.core.common.FrameworkProject; +import com.dtolabs.rundeck.core.common.FrameworkProjectMgr; import com.dtolabs.rundeck.core.common.INodeEntry; import com.dtolabs.rundeck.core.execution.ExecutionContext; import com.dtolabs.rundeck.core.execution.ExecutionLogger; import com.dtolabs.rundeck.core.execution.workflow.steps.StepFailureReason; import com.dtolabs.rundeck.core.execution.workflow.steps.node.NodeStepException; import com.dtolabs.rundeck.core.plugins.configuration.Description; +import com.dtolabs.rundeck.core.utils.IPropertyLookup; import com.dtolabs.rundeck.plugins.PluginLogger; import com.dtolabs.rundeck.plugins.step.PluginStepContext; import com.github.tomakehurst.wiremock.client.WireMock; @@ -27,6 +31,7 @@ import java.util.Map; import static org.junit.Assert.*; +import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.when; public class HttpWorkflowNodeStepPluginTest { @@ -176,6 +181,20 @@ public void setUp() { when(pluginContext.getLogger()).thenReturn(pluginLogger); when(pluginContext.getExecutionContext()).thenReturn(executionContext); + // Mock the necessary objects + Framework framework = Mockito.mock(Framework.class); + FrameworkProjectMgr frameworkProjectMgr = Mockito.mock(FrameworkProjectMgr.class); + FrameworkProject frameworkProject = Mockito.mock(FrameworkProject.class); + IPropertyLookup frameworkProperties = Mockito.mock(IPropertyLookup.class); + + // Mock the interactions + when(pluginContext.getFramework()).thenReturn(framework); + when(framework.getFrameworkProjectMgr()).thenReturn(frameworkProjectMgr); + when(frameworkProjectMgr.getFrameworkProject(anyString())).thenReturn(frameworkProject); + when(frameworkProject.getProperties()).thenReturn(new HashMap()); + when(framework.getPropertyLookup()).thenReturn(frameworkProperties); + when(frameworkProperties.hasProperty(anyString())).thenReturn(true); + dataContext =new HashMap<>(); when(pluginContext.getDataContext()).thenReturn(dataContext); From e745a5d4a15373fa6f64fb7855782233895366d2 Mon Sep 17 00:00:00 2001 From: Jake Cohen Date: Tue, 28 May 2024 14:06:21 -0700 Subject: [PATCH 4/9] add logic for workflowstep --- src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java | 6 +++--- .../edu/ohio/ais/rundeck/HttpWorkflowNodeStepPlugin.java | 2 +- .../java/edu/ohio/ais/rundeck/HttpWorkflowStepPlugin.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java b/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java index 28763d2..756cf87 100644 --- a/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java +++ b/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java @@ -464,10 +464,10 @@ public void setHeaders(String headers, RequestBuilder request){ } } - static void propertyResolver(String property, Map Configuration, PluginStepContext context, String SERVICE_PROVIDER_NAME) { + static void propertyResolver(String pluginType, String property, Map Configuration, PluginStepContext context, String SERVICE_PROVIDER_NAME) { - String projectPrefix = "project.plugin.WorkflowNodeStep." + SERVICE_PROVIDER_NAME + "."; - String frameworkPrefix = "framework.plugin.WorkflowNodeStep" + SERVICE_PROVIDER_NAME + "."; + String projectPrefix = "project.plugin." + pluginType + "." + SERVICE_PROVIDER_NAME + "."; + String frameworkPrefix = "framework.plugin." + pluginType + "." + SERVICE_PROVIDER_NAME + "."; Map projectProperties = context.getFramework().getFrameworkProjectMgr().getFrameworkProject(context.getFrameworkProject()).getProperties(); IPropertyLookup frameworkProperties = context.getFramework().getPropertyLookup(); diff --git a/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPlugin.java b/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPlugin.java index 60789e5..155759a 100644 --- a/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPlugin.java +++ b/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPlugin.java @@ -65,7 +65,7 @@ public void executeNodeStep(PluginStepContext context, Map confi Description description = new HttpDescription(SERVICE_PROVIDER_NAME, "HTTP Request Node Step", "Performs an HTTP request with or without authentication (per node)").getDescription(); description.getProperties().forEach(prop-> - propertyResolver(prop.getName(), configuration, context, SERVICE_PROVIDER_NAME) + propertyResolver("WorlflowNodeStep", prop.getName(), configuration, context, SERVICE_PROVIDER_NAME) ); // Parse out the options diff --git a/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowStepPlugin.java b/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowStepPlugin.java index c5c2083..f7a9d7c 100644 --- a/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowStepPlugin.java +++ b/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowStepPlugin.java @@ -73,7 +73,7 @@ public void executeStep(PluginStepContext pluginStepContext, Map Description description = new HttpDescription(SERVICE_PROVIDER_NAME, "HTTP Request Node Step", "Performs an HTTP request with or without authentication (per node)").getDescription(); description.getProperties().forEach(prop-> - propertyResolver(prop.getName(), options, pluginStepContext, SERVICE_PROVIDER_NAME) + propertyResolver("WorflowStep",prop.getName(), options, pluginStepContext, SERVICE_PROVIDER_NAME) ); // Parse out the options From 75ed501cfc82657ca3da49804a59c3e886673b5d Mon Sep 17 00:00:00 2001 From: Jake Cohen Date: Thu, 30 May 2024 08:46:09 -0700 Subject: [PATCH 5/9] fixing typos --- .../java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPlugin.java | 2 +- src/main/java/edu/ohio/ais/rundeck/HttpWorkflowStepPlugin.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPlugin.java b/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPlugin.java index 155759a..fada760 100644 --- a/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPlugin.java +++ b/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowNodeStepPlugin.java @@ -65,7 +65,7 @@ public void executeNodeStep(PluginStepContext context, Map confi Description description = new HttpDescription(SERVICE_PROVIDER_NAME, "HTTP Request Node Step", "Performs an HTTP request with or without authentication (per node)").getDescription(); description.getProperties().forEach(prop-> - propertyResolver("WorlflowNodeStep", prop.getName(), configuration, context, SERVICE_PROVIDER_NAME) + propertyResolver("WorkflowNodeStep", prop.getName(), configuration, context, SERVICE_PROVIDER_NAME) ); // Parse out the options diff --git a/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowStepPlugin.java b/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowStepPlugin.java index f7a9d7c..bff7b7a 100644 --- a/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowStepPlugin.java +++ b/src/main/java/edu/ohio/ais/rundeck/HttpWorkflowStepPlugin.java @@ -73,7 +73,7 @@ public void executeStep(PluginStepContext pluginStepContext, Map Description description = new HttpDescription(SERVICE_PROVIDER_NAME, "HTTP Request Node Step", "Performs an HTTP request with or without authentication (per node)").getDescription(); description.getProperties().forEach(prop-> - propertyResolver("WorflowStep",prop.getName(), options, pluginStepContext, SERVICE_PROVIDER_NAME) + propertyResolver("WorkflowStep",prop.getName(), options, pluginStepContext, SERVICE_PROVIDER_NAME) ); // Parse out the options From 2a604a57f28acb1cc30c4e23cee32c6cf3f98b7b Mon Sep 17 00:00:00 2001 From: Jake Cohen Date: Fri, 31 May 2024 14:49:23 -0700 Subject: [PATCH 6/9] adding option to use jvm proxy settings --- src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java | 11 +++++++++-- .../java/edu/ohio/ais/rundeck/HttpDescription.java | 7 +++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java b/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java index 756cf87..50cf752 100644 --- a/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java +++ b/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java @@ -23,6 +23,7 @@ import org.apache.http.entity.ContentType; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.conn.SystemDefaultRoutePlanner; import org.apache.http.ssl.SSLContextBuilder; import org.apache.http.util.EntityUtils; import org.dom4j.DocumentHelper; @@ -34,6 +35,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor; import java.io.*; +import java.net.ProxySelector; import java.security.GeneralSecurityException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; @@ -109,13 +111,18 @@ public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws Ce httpClientBuilder.setSSLContext(sslContextBuilder.build()); } if(options.containsKey("proxySettings") && Boolean.parseBoolean(options.get("proxySettings").toString())){ - log.log(5, "using proxy IP: " + options.get("proxyIP").toString()); - log.log(5, "using proxy Port: " + options.get("proxyPort").toString()); + log.log(5, "proxy IP set in job: " + options.get("proxyIP").toString()); HttpHost proxy = new HttpHost(options.get("proxyIP").toString(), Integer.valueOf((String)options.get("proxyPort")), "http"); httpClientBuilder.setProxy(proxy); } + if(options.get("useSystemProxySettings").equals("true")) { + + httpClientBuilder.setRoutePlanner(new SystemDefaultRoutePlanner(ProxySelector.getDefault())); + + } + return httpClientBuilder.build(); } diff --git a/src/main/java/edu/ohio/ais/rundeck/HttpDescription.java b/src/main/java/edu/ohio/ais/rundeck/HttpDescription.java index db1034f..5cead91 100644 --- a/src/main/java/edu/ohio/ais/rundeck/HttpDescription.java +++ b/src/main/java/edu/ohio/ais/rundeck/HttpDescription.java @@ -2,6 +2,7 @@ import com.dtolabs.rundeck.core.plugins.configuration.Describable; import com.dtolabs.rundeck.core.plugins.configuration.Description; +import com.dtolabs.rundeck.core.plugins.configuration.PropertyScope; import com.dtolabs.rundeck.core.plugins.configuration.StringRenderingConstants; import com.dtolabs.rundeck.plugins.util.DescriptionBuilder; import com.dtolabs.rundeck.plugins.util.PropertyBuilder; @@ -165,6 +166,12 @@ public Description getDescription() { .defaultValue("false") .renderingOption(StringRenderingConstants.GROUP_NAME,"Print") .build()) + .property(PropertyBuilder.builder() + .booleanType("useSystemProxySettings") + .description("Choose whether to use proxy settings set on the JVM.") + .defaultValue("false") + .scope(PropertyScope.Project) + .build()) .build(); } } From 9721f4c5cd1b9329b60c20c5215a3e54eb4656f2 Mon Sep 17 00:00:00 2001 From: Jake Cohen Date: Fri, 31 May 2024 15:34:29 -0700 Subject: [PATCH 7/9] cleaning up --- src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java b/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java index 50cf752..a3e218a 100644 --- a/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java +++ b/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java @@ -119,6 +119,8 @@ public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws Ce if(options.get("useSystemProxySettings").equals("true")) { + log.log(5, "Using proxy settings set on system"); + httpClientBuilder.setRoutePlanner(new SystemDefaultRoutePlanner(ProxySelector.getDefault())); } From 2c3cc840deb74a4b4c4ccc170af45a9b89b2a143 Mon Sep 17 00:00:00 2001 From: Jake Cohen Date: Mon, 10 Jun 2024 15:44:29 -0700 Subject: [PATCH 8/9] allow job-level override --- src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java b/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java index a3e218a..261484c 100644 --- a/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java +++ b/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java @@ -110,13 +110,6 @@ public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws Ce httpClientBuilder.setSSLHostnameVerifier(new NoopHostnameVerifier()); httpClientBuilder.setSSLContext(sslContextBuilder.build()); } - if(options.containsKey("proxySettings") && Boolean.parseBoolean(options.get("proxySettings").toString())){ - log.log(5, "proxy IP set in job: " + options.get("proxyIP").toString()); - - HttpHost proxy = new HttpHost(options.get("proxyIP").toString(), Integer.valueOf((String)options.get("proxyPort")), "http"); - httpClientBuilder.setProxy(proxy); - } - if(options.get("useSystemProxySettings").equals("true")) { log.log(5, "Using proxy settings set on system"); @@ -124,6 +117,12 @@ public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws Ce httpClientBuilder.setRoutePlanner(new SystemDefaultRoutePlanner(ProxySelector.getDefault())); } + if(options.containsKey("proxySettings") && Boolean.parseBoolean(options.get("proxySettings").toString())){ + log.log(5, "proxy IP set in job: " + options.get("proxyIP").toString()); + + HttpHost proxy = new HttpHost(options.get("proxyIP").toString(), Integer.valueOf((String)options.get("proxyPort")), "http"); + httpClientBuilder.setProxy(proxy); + } return httpClientBuilder.build(); } From adc37c991357947eaa464a6023cb033ee59651eb Mon Sep 17 00:00:00 2001 From: Jake Cohen Date: Mon, 15 Jul 2024 23:07:47 -0700 Subject: [PATCH 9/9] fixing logic of overriding proxy settings from job level --- src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java b/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java index 261484c..8b5a895 100644 --- a/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java +++ b/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java @@ -110,7 +110,7 @@ public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws Ce httpClientBuilder.setSSLHostnameVerifier(new NoopHostnameVerifier()); httpClientBuilder.setSSLContext(sslContextBuilder.build()); } - if(options.get("useSystemProxySettings").equals("true")) { + if(options.get("useSystemProxySettings").equals("true") && !Boolean.parseBoolean(options.get("proxySettings").toString())) { log.log(5, "Using proxy settings set on system");