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

[pact-jvm-consumer-junit], MockProviderConfig::url(), IPv6 host is not supported #405

Closed
SchulteMarkus opened this issue Apr 12, 2017 · 2 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@SchulteMarkus
Copy link
Contributor

This bug-report is about MockProviderConfig::url().

If MockProviderConfig.hostname is an IPv6 address, MockProviderConfig::url() will return an invalid URL. Here is a little test, demonstrating the issue.

import au.com.dius.pact.model.MockProviderConfig;
import java.net.URISyntaxException;
import org.junit.Assert;
import org.junit.Test;

public class MockProviderConfigTest {

  @Test
  public void ipv4works() throws URISyntaxException {
    final MockProviderConfig mockProviderConfig = new MockProviderConfig();
    mockProviderConfig.setHostname("127.0.0.1");

    final String url = mockProviderConfig.url();
    Assert.assertEquals("http://127.0.0.1:0", url);
  }

  @Test
  public void ipv6worksNot() throws URISyntaxException {
    final MockProviderConfig mockProviderConfig = new MockProviderConfig();

    mockProviderConfig.setHostname("::1");

    final String url = mockProviderConfig.url();
    Assert.assertEquals("http://[::1]:0", url); // fails. url is http://::1:0
  }
}

My current workaround is, to use guava.InetAddresses::toUriString() before constructing a PactProviderRule.

@uglyog uglyog added the bug Indicates an unexpected problem or unintended behavior label Apr 14, 2017
@rholshausen rholshausen changed the title [pact-jvm-consumer-junit], MockProviderConfig::url(), IPv6 host is not supported pact-jvm-consumer-junit, MockProviderConfig::url(), IPv6 host is not supported Jan 17, 2023
@rholshausen rholshausen changed the title pact-jvm-consumer-junit, MockProviderConfig::url(), IPv6 host is not supported pact-jvm-consumer-junit, MockProviderConfig url(), IPv6 host is not supported Jan 17, 2023
@rholshausen rholshausen changed the title pact-jvm-consumer-junit, MockProviderConfig url(), IPv6 host is not supported pact-jvm-consumer-junit, MockProviderConfig url, IPv6 host is not supported Jan 17, 2023
@rholshausen
Copy link
Contributor

/jira ticket

@github-actions
Copy link

👋 Thanks, Jira [PACT-594] ticket created.

@rholshausen rholshausen changed the title pact-jvm-consumer-junit, MockProviderConfig url, IPv6 host is not supported [pact-jvm-consumer-junit], MockProviderConfig::url(), IPv6 host is not supported Jan 17, 2023
rholshausen added a commit that referenced this issue Jan 18, 2023
rholshausen added a commit that referenced this issue Jan 18, 2023
rholshausen added a commit that referenced this issue Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants