Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Harsh Pareek
    @harshpare
    Hi, Is it possible to do an export of captured simulation data through API instead of CLI?
    1 reply
    ronald6776
    @ronald6776
    Hi, Is it possible to get the value of request body which contains a key with space (ex. "Key 1":"value") using templates? Have tried with jsonpath options but no luck. @tommysitu- can you please help on this?
    2 replies
    ronald6776
    @ronald6776
    Can anybody help with the above issue?
    Harsh Pareek
    @harshpare
    Hi, I have setup hoverfly in proxy mode (through JVM proxy settings) and its working fine for most calls. But for one specific call the request is visible in journal when i run hoverfly in spy mode ( request goes to actual backend) but when I change the mode to simulate the request is still hitting the actual end point instead of giving captured response or failing ( if no simulation exist for it). In certain cases I am also experiencing Capture mode failing to capture few request. Has anyone faced such issues?
    2 replies
    hari avvari
    @hariavvari_twitter
    Hi , when the "encodedBody" is set to true, what kind of encoding is used ? I thought it was base64 encoding.....I exported the simulation, copied the body and tried to decode using UTF-8 character set but it doesn't decode properly...So either the body is not encoded in base64 or a different character set is being used..Can anyone help on this?
    3 replies
    Sheril Paul Vazhappilly
    @sheril-infy
    Hi, I am trying to use XPath functions to capture value from the request and return it in the response. eg: string-length('hoverfly'), string(format-date(//Date/@ArrivalDate, '[M01]-[D01]-[Y0001]'))
    But it's returning blank. Can anyone help with this?
    Format I tried in response : {{ Request.Body \"xpath\" \"string-length('hoverfly')\" }}
    gurukraj
    @gurukraj
    Hi, I am using hoverfly for our one of the microservice architecture application to record and replay the REST payload. I started the hoverfly with its root ca certificate using "./hoverfly -listen-on-host 0.0.0.0 --cert ./cert.pem --key ./key.pem" where cert.pem and key.pem are located in same current directory. I then started the hoverfly in capture mode. Tried to run the POST command using curl "curl --proxy http://localhost:8500 --cacert /home/admin/Guru_Test/HoverflyTool/cert.pem -i -X POST -H 'Content-Type: application/json' -d '{"username": "admin", "password": "xxxxxxx"}' https://localhost:8443/api/v2/login". It failed with message "Hoverfly Error!
    There was an error when forwarding the request to the intended destination
    Got error: Post "https://localhost:8443/api/v2/login": x509: certificate signed by unknown authority". Could you please help to get this resolved? I cannot use "http" instead of https since our auth service is TLS enabled and I followed the link "https://docs.hoverfly.io/en/latest/pages/tutorials/advanced/configuressl/configuressl.html" This is not helping. Please let me know what I am missing
    1 reply
    raghanag
    @raghanag
    Hi Is it better to use middleware to serve different responses for different types of users doing the same actions on the site or do we need to record all user interactions and let the proxy server takes care of serving it raw?
    2 replies
    vkutepov
    @vkutepov
    HI.
    I'm just starting to read the documentation hoverfly and judging by the schematics it looks like a moc server
    https://howtodoinjava.com/wp-content/uploads/2017/08/1-1.jpg
    But is it acceptable to send recorded queries and responses in microservice instead of hoverfly?
    For regression testing
    I would like to record a history of queries on the production
    and then run it on staging, only to have the requests go to the actual microservice.
    3 replies
    Sheril Paul Vazhappilly
    @sheril-infy
    SpectoLabs/hoverfly-java#253
    @tommysitu would you be able to look into this?
    vprudnikov
    @vprudnikov
    Hi, is it possible to simulate an async integration scenario with Hoverfly? I need to do a webhook (or execute any code) after the response has been returned in the calling thread
    hoverfly.simulate(dsl(
    service(baseUrl).anyMethod("/path/").willReturn(success(json(...))) //plus call another url here AND/OR execute an arbitraty code
    ))
    1 reply
    raghanag
    @raghanag
    HI @JohnFDavenport Can you tell me whats the difference between spy mode and
    The destination setting applies to all Hoverfly modes. If a destination value is set while Hoverfly is running in Simulate mode, requests that are excluded by the destination setting will be passed through to the real URLs. This makes it possible to return both real and simulated responses.
    because with destination filtering you can really turn hoverfly into spy mode in a simulation mode right?
    Kishore Venkatachalam
    @kishorevinay_twitter
    Hi, Is it possible to simulate https calls without adding hoverfly certificate to keystore?
    4 replies
    Lisandro Diaz
    @lisandrod_gitlab
    Looking at some of the source, it seems that request body templating is only possible for json or xml, any ideas how to handle raw strings?
    1 reply
    Lisandro Diaz
    @lisandrod_gitlab
    also how do you disable middleware once it set?
    1 reply
    Alexey
    @WouldYouKindly

    Hi! Is there any way to get structured information when the matcher fails? I want to show the diff when the test fails: currently I show the last Hoverfly log record with error, but it's a lot of text, and I would like to highlight/show only the non-matched fields.

    I'm talking about these logs:

    Could not find a match for request, create or record a valid matcher first!
    
    The following request was made, but was not matched by Hoverfly:
    
    {
        "Path": "/versio",
        "Method": "GET",
        "Destination": "foaas.com",
        "Scheme": "https",
        "Query": {},
        "Body": "",
        "Headers": {
            "accept": [
                "application/json"
            ],
            "accept-encoding": [
                "gzip, deflate"
            ],
            "connection": [
                "keep-alive"
            ],
            "user-agent": [
                "python-requests/2.25.1"
            ]
        }
    }
    DavidLivingston
    @DavidLivingston
    Hi, is Hoverfly capable of recording and mocking websockets, is there an example if so ?
    Ayush khandalkar
    @KhandalkarAyush_twitter
    Hi Guys,
    I wanted to match the jsonpath matcher "body": [{
    "matcher": "jsonpath",
    "value": "$.tracingContext.correlationId?(@ == \"1234\")"
    }]
    but this validation does not seem to be working
    Is there any other go to validate jsonpath matcher to regex?
    Mahesh Rajannan
    @maheshrajannan:matrix.org
    [m]

    I referred the hoverfly issue 515(SpectoLabs/hoverfly#515) and arrived at this one(https://github.com/d-lorenc/hoverfly-on-cf). I tried the same way of deploying to pcf, which is to use hoverfly start(./hoverfly -webserver) instead of hoverctl. But ./hoverfly start is NOT starting it, i can see that when trying it on a linux box separately. It only starts if i do hoverctl start.

    Can you please help us by addressing this issue ? or pointing me to correct direction. Your help is highly appreciated.

    raghanag
    @raghanag
    Hi Team, I am seeing that when we use hoverfly as a proxy server in chrome the remote address header is having the hoverfly ip address value which is causing the backend to not return any data and thus we are not able to capture any data.
    raghanag
    @raghanag
    I can only see this issue when we used --upstream-proxy flag when starting hoverfly @JohnFDavenport any suggestions?
    renanhguerra
    @renanhguerra
    Hello
    is there a way to set the destination url for some requests received
    while using hoverfly either as webserver or proxy?
    I can't send the requests like: curl http://hoverfly.io --proxy http://proxy-ip:port
    I would like to send the request to http://proxy-ip:port and then the hoverfly itself knows that it should be send to the real service http://hoverfly.io
    3 replies
    patown
    @patown
    Is it possible to make Response fields not final? Or what's correct way to modify response in hoverfly-java ? I am trying to make dynamic respone via interface SimulationPreprocessor but it looks like Response was designed not to be changed .
    patown
    @patown
    Let me make it more clear.

    package io.specto.hoverfly.junit5;

    import com.fasterxml.jackson.core.JsonProcessingException;
    import com.fasterxml.jackson.databind.ObjectMapper;
    import io.specto.hoverfly.junit.core.Hoverfly;
    import io.specto.hoverfly.junit.core.SimulationPreprocessor;
    import io.specto.hoverfly.junit.core.model.*;
    import io.specto.hoverfly.junit5.api.HoverflyConfig;
    import io.specto.hoverfly.junit5.api.HoverflySimulate;
    import org.junit.jupiter.api.Test;
    import org.junit.jupiter.api.extension.ExtendWith;
    import java.time.LocalDateTime;
    import java.util.HashSet;
    import java.util.Set;

    @HoverflySimulate(
    config = @HoverflyConfig(
    simulationPreprocessor = PreProcessResponseTest.TimeSimulationPreprocessor.class
    ), source = @HoverflySimulate.Source(value = "hoverfly/test-service.json",
    type = HoverflySimulate.SourceType.CLASSPATH)
    )
    @ExtendWith({HoverflyExtension.class})
    public class PreProcessResponseTest {
    static class TimeSimulationPreprocessor implements SimulationPreprocessor {
    @Override
    public void accept(Simulation simulation) {
    HoverflyData originData= simulation.getHoverflyData();
    HoverflyMetaData originMetaData=simulation.getHoverflyMetaData();
    Set<RequestResponsePair> pairs= new HashSet<>();
    originData.getPairs().stream()
    .forEach(p ->
    {

                     Response origin= p.getResponse();
                        String body =origin.getBody();
                        String replaced=    body.replace("NOW", LocalDateTime.now().toString());
                        Response rsp= new Response(origin.getStatus(),replaced,origin.isEncodedBody(),origin.isTemplated(),origin.getHeaders()
                        ,origin.getTransitionsState(),origin.getRemovesState(),origin.getFixedDelay(),origin.getLogNormalDelay());
    
                        origin=rsp;
    
                        ObjectMapper mapper = new ObjectMapper();
                        try {
                            System.out.println(mapper.writeValueAsString(origin));
                            System.out.println(mapper.writeValueAsString(rsp));
                        } catch (JsonProcessingException e) {
                            e.printStackTrace();
                        }
                        RequestResponsePair pair =new RequestResponsePair(p.getRequest(),rsp);
                        pairs.add(pair);
                    });
          //  HoverflyData  hoverflyData=new HoverflyData(pairs,simulation.getHoverflyData().getGlobalActions());
            simulation=new Simulation(new HoverflyData(pairs,simulation.getHoverflyData().getGlobalActions()), simulation.getHoverflyMetaData());
          //  simulation.setHoverflyData(hoverflyData);
            ObjectMapper mapper = new ObjectMapper();
            try {
                System.out.println("class::\n"+mapper.writeValueAsString(simulation));
            } catch (JsonProcessingException e) {
                e.printStackTrace();
            }
        }
    
    }
    @Test
    void shouldUseCustomPorts(Hoverfly hoverfly) throws JsonProcessingException {
        ObjectMapper mapper = new ObjectMapper();
        System.out.println("test::\n"+mapper.writeValueAsString(hoverfly.getSimulation()));
    }

    }

    All Response class's fields are 'final' and there is no setHoverflyData method in Simulation class. So it looks there is no convenient way to modify response once loaded from json file.
    patown
    @patown
    I am considering to support such scenario, when returning a response, replace a TIMESTAMP with NOW placeholder with current time instead of the time when last recorded.
    6 replies
    Any suggestion ?
    patown
    @patown
    @tommysitu
    kumar275
    @kumar275:matrix.org
    [m]

    Hi,

    Started hoverfly using "hoverctl.exe". Can I use same instance in JAVA using "HoverflyConfig" and not starting again?

    also can I start Hoverfly instance in forever open mode (JAVA) and add simulations dynamically?
    Instance should stop upon issuing the "honverflyInstance.close();" (I mean disable auto destroy)
    Oliver Flint
    @OliverFlint
    Hello
    I'm new to Hoverfly. Was hoping to use it so virtualise some services we have connected to azure service bus
    Anyone have any experience with Hoverfly and ASB?
    Ankita Nallana
    @saturnian_s_twitter
    Hello! Heard that for gRPC support we need a paid version of Hoverfly? Where can I get more info on it? @tommysitu
    2 replies
    Jonathan Rodriguez
    @jarpz

    Hi, any experience with troubles using Hoverfly and spring webClient?

    I have this code.. but I can make works, I seems spring webClient can not be proxied by hoverfly.

    hoverfly.simulate(dsl(
                    service("http://myapi")
                            .post("/admin")
                            .willReturn(HoverflyDsl.response().status(200))))
    
            val reactorResourceFactory = ReactorResourceFactory()
                    .also { it.afterPropertiesSet() }
    
            val connector: ClientHttpConnector = ReactorClientHttpConnector(reactorResourceFactory
            ) { httpClient ->
                httpClient
    //                    .wiretap(true)
                        .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10_000)
                        .responseTimeout(Duration.ofMillis(60_000))
                        .proxy { proxy ->
                            proxy.type(ProxyProvider.Proxy.HTTP)
                                    .host(hoverfly.hoverflyConfig.host)
                                    .port(hoverfly.hoverflyConfig.proxyPort)
                        }
            }
            val r = WebClient
                    .builder()
                    .baseUrl("http://myapi")
                    .filter(ExchangeFilterFunction { originalRequest, nextFilter ->
                        val clientRequest = ClientRequest.from(originalRequest)
                                .header("X-Shopify-Access-Token", "n")
                                .build()
                        return@ExchangeFilterFunction nextFilter.exchange(clientRequest)
                    })
                    .clientConnector(connector)
                    .build()
                    .post().uri("/admin")
                    .exchangeToMono { r -> Mono.just(r.rawStatusCode()) }
                    .block()
    
            println("$$$$$$$$$$$$ $r")
    
            hoverfly.verifyAll() ** fails ->

    error -> >

    ailed to resolve 'myapi' after 2 queries ; nested exception is java.net.UnknownHostException: failed to resolve 'myapi' after 2 queries 
    org.springframework.web.reactive.function.client.WebClientRequestException: failed to resolve 'myapi' after 2 queries ; nested exception is java.net.UnknownHostException: failed to resolve 'myapi' after 2 queries 
        at org.springframework.web.reactive.function.client.ExchangeFunctions$DefaultExchangeFunction.lambda$wrapException$9(ExchangeFunctions.java:141)
        Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
    Error has been observed at the following site(s):
        |_ checkpoint ⇢ Request to POST http://myapi/admin [DefaultWebClient]
    Joe DeSantis
    @desantisjmd_twitter
    @jarpz this is how we configure the web client(org.springframework.web.reactive.function.client.WebClient) ​for our int tests to be used with hoverfly.
    One down side to this approach that we have yet to get around... You need to manually set the port for the hoverfly instance
    @HoverflySimulate(config = @HoverflyConfig(proxyPort = HOVERFLY_PROXY_PORT))
    @Configuration
    public class WebClientTestConfig {
       ​private static final int CONNECTION_TIMEOUT = 10000;
       ​private static final int READ_TIMEOUT = 40000;
       ​private static final int WRITE_TIMEOUT = 10000;
       ​public static final int HOVERFLY_PROXY_PORT = 49471; //RANDOM UNUSED PORT@Primary@Beanpublic static WebClient integrationTestWebClient() throws SSLException {
           ​SslContext sslContext = SslContextBuilder
               ​.forClient()
               ​.trustManager(InsecureTrustManagerFactory.INSTANCE)
               ​.build();
           ​TcpClient tcpClient = TcpClient.create()
               ​.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, CONNECTION_TIMEOUT) // Connection Timeout
               ​.secure(contextSpec -> contextSpec.sslContext(sslContext))
               ​.proxy(proxy -> proxy.type(ProxyProvider.Proxy.HTTP).host("localhost")
                   ​.port(HOVERFLY_PROXY_PORT))
               ​.doOnConnected(connection ->
                   ​connection.addHandlerLast(new ReadTimeoutHandler(READ_TIMEOUT)) // Read Timeout
                       ​.addHandlerLast(new WriteTimeoutHandler(WRITE_TIMEOUT))); // Write Timeoutreturn WebClient.builder()
               ​.clientConnector(new ReactorClientHttpConnector(HttpClient.from(tcpClient)))
               ​.build();
       ​}
    }
    Malcolm J O'Callaghan
    @mr-jolly

    hello - i am getting the following error on an api specification that validates in the swagger editor:

    >hoverctl import api.json
    Could not import simulation
    
    Invalid JSON, missing "meta" object

    is there a particular validation process i should follow or a standard that your import process is coded to that i should validate against?

    2 replies
    mkammy
    @mkammy
    I have installed hoverfly on kubernetes by using helm. (https://docs.hoverfly.io/en/latest/pages/introduction/downloadinstallation.html#kubernetes). When i login the pod i can see hoverfly in running. But hoverctl command not working. Can anyone tell me what i am doing the wrong here
    1 reply
    Joe DeSantis
    @desantisjmd_twitter
    @mkammy Just a thought, I would try just placing a copy of the hoverctl on the pod, and see how that works. IE. something like wget https://github.com/SpectoLabs/hoverfly/releases/download/v1.3.2/hoverfly_bundle_linux_amd64.zip && unzip hoverfly_bundle_linux_amd64.zip && cd hoverfly_bundle_linux_amd64 && ./hoverctl
    Have you looked into remote hoverfly hoverctl control as well? https://docs.hoverfly.io/en/latest/pages/tutorials/advanced/remotehoverfly/remotehoverfly.html
    mkammy
    @mkammy
    Thanks @desantisjmd_twitter that worked. But curl command is not working in this pod. This is the deprecated version that i have installed. Can someone please share the link of latest helm chart. Thanks in advance
    Joe DeSantis
    @desantisjmd_twitter
    @mkammy Try apk update && apk upgrade && apk add curl
    apoorv sharda
    @iamapoorvsharda_twitter

    Hi All,

    I am trying to capture requests using hoverfly on Docker, I am able to capture the requests using curl command by following hoverfly documentations, but i want to know if there is a way to capture all the incoming requests to that particular VM? for example how when we are setting Proxy in SoapUI when we are using hoverfly on our local and it captures all the traffic.

    Ankita Nallana
    @saturnian_s_twitter
    Hi folks - any examples on how to mock gRPC requests? I have the trial license
    3 replies