mitmproxy-java icon indicating copy to clipboard operation
mitmproxy-java copied to clipboard

Unable to reflect response in android app using appium and Java

Open ashuaviator1987 opened this issue 2 years ago • 1 comments

I am using below configuration.

  1. Installed MITM certificate on my emulator.
  2. Installed MITM proxy, websocket and other related dependecy as mentioned in appiumPro article

Part of code dealing with proxy is as per below ` List<InterceptedMessage> messages = new ArrayList<>();

    // remember to set local OS proxy settings in the Network Preferences
    proxy = new MitmproxyJava("C:\\Python311\\Scripts\\mitmdump.exe", (InterceptedMessage m) -> {
        if(

                m.getRequest().getUrl().toString().toLowerCase().startsWith(apiURL.toLowerCase()) &&
                m.getRequest().getMethod().equalsIgnoreCase("post")&&
                getJsonObject(new String(m.getRequest().getBody())).hasNonNull("operationName")&&
                getJsonObject(new String(m.getRequest().getBody())).get("operationName").asText().equalsIgnoreCase("getPharamcyTATInfo")
        )
        {

                JsonNode responseBodyJson = getJsonObject(new String(m.getResponse().getBody()));
                String modifiedResp = updateValuesInJson(responseBodyJson.toString(),
                        "data.getSkuInfo.tatInfo.tatResponse.inventoryExist",false,
                        "data.getSkuInfo.tatInfo.tatResponse.items[0].exist",false);
                m.getResponse().setBody(modifiedResp.getBytes(StandardCharsets.UTF_8));
                m.getResponse().getHeaders().add(new String[]{"My Test Resp Header","Header Value"});
                messages.add(m);
        }
        return m;
    });
    proxy.start();

    login(initializeDriver(testMethod),credentialManager);

`

now I have printed the intercepted message and modified response. but the app is still receiving the unmodified request. when I do below ` messages.forEach( x->{ LOGGER.info("########Request Operation : "+x.toString() +getJsonObject(new String(x.getRequest().getBody())).get("operationName")); LOGGER.info("########### Response Body :" +new String(x.getResponse().getBody())); }

    );`

i see the proper response (modified one), this response never made it app, it is still showing the normal behaviour.

P.S. the app is Android native app Please advice

ashuaviator1987 avatar Feb 14 '23 16:02 ashuaviator1987

@jlipps can we do a paid support for this issue

ashuaviator1987 avatar Feb 15 '23 19:02 ashuaviator1987