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

Allow using a HTTP proxy to send results #2285

Closed
aslakhellesoy opened this issue Apr 19, 2021 · 12 comments · Fixed by #2452
Closed

Allow using a HTTP proxy to send results #2285

aslakhellesoy opened this issue Apr 19, 2021 · 12 comments · Fixed by #2452
Labels
🙏 help wanted Help wanted - not prioritized by core team ✅ accepted The core team has agreed that it is a good idea to fix this ⚡ enhancement Request for new functionality
Milestone

Comments

@aslakhellesoy
Copy link
Contributor

We should allow users behind a HTTP(S) proxy to publish results. See https://docs.oracle.com/javase/8/docs/api/java/net/doc-files/net-properties.html

@aslakhellesoy aslakhellesoy added ⚡ enhancement Request for new functionality ✅ accepted The core team has agreed that it is a good idea to fix this labels Apr 19, 2021
@aslakhellesoy
Copy link
Contributor Author

We should make sure all implementations use the same environment variables to configure proxy settings.

@mpkorstanje
Copy link
Contributor

At this point it would be prudent to replace the HttpURLConnection with a proper shaded http client. When using the http.* properties will affect all components in java.net including those of the system under tests. So this may not be feasible. Especially in more complicated setups.

@mpkorstanje
Copy link
Contributor

Java 11 does come with a HttpClient that is an overall improvement over the HttpURLConnection, but as Cucumber is currently still on Java 8 we can not use this yet. We do have a major version in the works that would allow us to increase the minimum version of the JRE on which Cucumber is ran.

https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.html

@aslakhellesoy
Copy link
Contributor Author

Can't we just use a java.net.Proxy object and take the configuration from cucumber-specific environment variables? For example:

  • CUCUMBER_PUBLISH_HTTP_PROXY_HOST
  • CUCUMBER_PUBLISH_HTTP_PROXY_PORT

@mpkorstanje
Copy link
Contributor

Not on a HttpURLConnection, you could create a URL instance with a custom implementation of URLStreamHandler but that's all sorts painful.

@aslakhellesoy
Copy link
Contributor Author

Not on a HttpURLConnection, you could create a URL instance with a custom implementation of URLStreamHandler but that's all sorts painful.

Why not?

At

HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
we could pass in a proxy object. See https://docs.oracle.com/javase/7/docs/api/java/net/URL.html#openConnection%28java.net.Proxy%29

@mpkorstanje
Copy link
Contributor

Didn't even know you could do that.

@mpkorstanje
Copy link
Contributor

We can probably extend the curl option syntax with the curl option for proxy:

curl https://example.com -x http://<proxy>:<port>

@aslakhellesoy
Copy link
Contributor Author

We can probably extend the curl option syntax with the curl option for proxy

Ooo nice idea!!!

@mpkorstanje
Copy link
Contributor

And if we could use PluginOption.forClass with a curl option as an argument this would also be a bit simpler:

    private List<Plugin> getPublishPlugin() {
        if (!enablePublishPlugin) {
            return emptyList();
        }
        if (publishToken != null) {
            return singletonList(PluginOption.forClass(PublishFormatter.class, publishToken));
        }
        if (publish) {
            return singletonList(PluginOption.forClass(PublishFormatter.class));
        }
        if (publishQuiet) {
            return emptyList();
        }
        return singletonList(PluginOption.forClass(NoPublishFormatter.class));
    }

Esp because then we wouldn't need CucumberProperties.create(); in PublishFormatter which doesn't look at at junit-platform.properties.

    private static CurlOption createCurlOption(String token) {
        Map<String, String> properties = CucumberProperties.create();
        String url = properties.getOrDefault(PLUGIN_PUBLISH_URL_PROPERTY_NAME, DEFAULT_CUCUMBER_MESSAGE_STORE_URL);
        if (token != null) {
            url = url + String.format(" -H 'Authorization: Bearer %s'", token);
        }
        return CurlOption.parse(url);
    }

@ghost
Copy link

ghost commented May 26, 2021

Is there any progress?

@aslakhellesoy
Copy link
Contributor Author

Not yet. You could help by submitting a pull request.

@aslakhellesoy aslakhellesoy added the 🙏 help wanted Help wanted - not prioritized by core team label May 26, 2021
@mpkorstanje mpkorstanje added this to the v7.x.x milestone Oct 6, 2021
mpkorstanje added a commit that referenced this issue Jan 1, 2022
Users looking to publish cucumber reports behind a proxy can add to
`cucumber.properties`:

```
cucumber.publish.proxy.url=https://proxy.example.com:3129
```

Note: The publish-plugin only reads properties from `cucumber.properties`. And
not `junit-platform.properties`.

Fixes: #2285
mpkorstanje added a commit that referenced this issue Jan 1, 2022
Users looking to publish cucumber reports behind a proxy can add to
`cucumber.properties`:

```
cucumber.publish.proxy=https://proxy.example.com:3129
```

Note: The publish-plugin only reads properties from `cucumber.properties`. And
not `junit-platform.properties`.

Fixes: #2285
mpkorstanje added a commit that referenced this issue Jan 1, 2022
Users looking to publish cucumber reports behind a proxy can add to
`cucumber.properties`:

```
cucumber.publish.proxy=https://proxy.example.com:3129
```

Note: The publish-plugin only reads properties from the `cucumber.properties`,
the environment, system properties. And not `junit-platform.properties`.

Fixes: #2285
mpkorstanje added a commit that referenced this issue Jan 3, 2022
Users looking to publish cucumber reports behind a proxy can add to
`cucumber.properties`:

```
cucumber.publish.proxy=https://proxy.example.com:3129
```

Note: The publish-plugin only reads properties from the `cucumber.properties`,
the environment, system properties. And not `junit-platform.properties`.

Fixes: #2285

Co-authored-by: Aslak Hellesøy <aslak.hellesoy@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙏 help wanted Help wanted - not prioritized by core team ✅ accepted The core team has agreed that it is a good idea to fix this ⚡ enhancement Request for new functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants