Hey Everyone, I am trying to setup wiremock with m...
# help
s
Hey Everyone, I am trying to setup wiremock with my emulator to capture and modify(similar to what mitmproxy does) http and https request for android native app. 1. I have installed the certificate in emulator. 2. I want to only intercept 2-3 any call (there are 100s of different call to different host). So basically want to whitelist every other call except the ones I wan to put stub for.
Copy code
HashMap<ExecutionDataKeys, Object> executionStates = new HashMap<>();
WireMockServer wireMockServer = new WireMockServer(
        new WireMockConfiguration().port(8080)
                .notifier(new Slf4jNotifier(true))
);
wireMockServer.start();
ArrayList<String> hostNames = new ArrayList<>(
        Arrays.asList(
                "<https://host1.com>",
                "<https://host2.com>",
        ));

hostNames.forEach(host->{
    wireMockServer.stubFor(any(urlMatching(host+".*"))
            .atPriority(10)
            .willReturn(aResponse().proxiedFrom(host)));
});
I have also set proxy in emulator to localhost:8080. But it seems whitlisting is not working. all of my request are getting blocked. P.S. I am trying to use appium along with wiremock to test state changes in application [10:53 PM] I have already waster 3-4 days on this, and feeling kind exausted in this. [10:53 PM] Please advice
d
Hi @Shruti Sagar Mishra, I am completely sure we encountered the same issues and also new to WireMock, but eventually my issue was the url didn't config right. What I did in configuration is like this:
Copy code
private static int port = 6677; @BeforeEach
  public void setup() {
    wireMockServer =
        new WireMockServer(WireMockConfiguration.wireMockConfig().port(port));
    wireMockServer.start();
    <http://log.info|log.info>("WireMockServer started at : {}", wireMockServer.baseUrl());
  }
I also posted this question in stackoverflow hope it helps
s
this is what i got
2023-02-15 234353 IApolloUIMethods [TestNG-PoolService-0-22] [INFO] WireMockServer started at : http://localhost:8080
d
I am not sure 8080 will work. What I changed the port number is
6677
which works for me. but I think you can use other port number as well
s
can we connect over call if possible. it will really get me out of jiffy.u r the first person i met who had done it successfully
did u do this for emulator?
r
Answering in #wiremock-open-source It's hard to keep track of conversations when you cross post the same one to multiple channels.