Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Tommy Situ
    @tommysitu
    @assaf unfortunately golang doesn't support negative lookahead regex. Please open an issue, we can provide an alternative solution.
    Siraj K
    @sirajka
    In our microservices Kubernetes development cluster, I'm trying to stand up Hoverfly to mock API calls to external clients.
    These external calls are over HTTPS.
    In order to proxy these calls to say, www.one.com and www.two.com,
    1. wouldn't we need the private key and public key from www.one.com and www.two.com?
      and
    2. can Hoverfly load multiple certificate pairs?
      Or am I incorrect in my approach?
    kdeepak270
    @kdeepak270
    I am trying to simulate a recorded simulation from a different machine.I have made the hoverfly to run using the command hoverfly -listen-on-host x.x.x.x. When i try to simulate using x.x.x.x:8550 , always it says it says "Got error: Could not find a match for request, create or record a valid matcher first!". But when i simulate the same using localhost:8500 it works. What am I missing here?
    RWerner254
    @RWerner254
    Hello, I am trying to figure out why HoverFly will capture a request in one situation, but not the other. When I make the request via Swagger, it is caught by HoverFly but when I make the request via a WCF web service, it doesn't. I hooked up WireShark to see if I could determine any difference between the two GET requests and they both look pretty dang close to identical. The Request URI is the same, the Host is the same, the host is the same, the request version is the same. I literally at a loss as to why one would get captured and one would not. I even tried it with no destination at all. Does anyone have any ideas as to why this would happen?
    Tommy Situ
    @tommysitu
    Tommy Situ
    @tommysitu
    @kdeepak270 your simulation probably has an exact matcher of the value “localhost:8500” for the destination field.
    Tommy Situ
    @tommysitu
    @RWerner254 your requests must be proxied through Hoverfly to do capturing. Check your proxy settings is what I’d suggest.
    RWerner254
    @RWerner254
    @tommysitu I went and manually setup the proxy on my machine to be the HoverFly proxy and then restarted IIS. Is there a way to confirm if IIS and/or the web application is using the proxy? I know it is when going through the Swagger web page. Wouldn't IIS automatically use the proxy defined on the machine through the Network & Internet->Proxy configuration as soon as it is restarted?
    Tommy Situ
    @tommysitu
    try putting hoverfly to simulate mode, if you still can access to your remote server that means your IIS is not using the hoverfly proxy.
    Unfortunately I don’t know much about IIS :(
    RWerner254
    @RWerner254
    The server isn't remote... this is all local. And re: IIS -> no worries! grin
    But I did see something about adding settings in the web.config to specify a proxy, so I'll give that a go and see
    RWerner254
    @RWerner254
    @tommysitu That was it! The web application wasn't using the proxy. Thank you!
    Tommy Situ
    @tommysitu
    Good to know hoverfly works with IIS too!
    kdeepak270
    @kdeepak270
    @tommysitu I donot have the exact matcher "localhost:8500" for the destination field in my simulation rather I have put glob matcher for it.
    Siraj K
    @sirajka
    @tommysitu i've read that doc a few times. anw i was able to fix it by adding the self signed cert to caller's trust store
    @kdeepak270 can u post ur request section from simulation?
    Kevin Jeu Chiem
    @kevinjchi
    Hi everyone, Is there a way for hoverfly to return a 400 response on the first request, then for it to return a 200 response on the second request to the same URL? I am trying to use Hoverfly to test retry logic.
    Tommy Situ
    @tommysitu
    You can use stateful simulation to do that.
    Serghei Luchianenco
    @luchianenco
    hi everyone,
    can you tell me plz if it possible to do with hoverfly:
    some endpoints return 302 status code and the Location header, is it possible to configure hoverfly in a way that it will reader Location header and do another request to provided redirect location and capture the response from that location?
    kdeepak270
    @kdeepak270
    Can I have custome date format like {{now "1s" "mm/dd/yyyy hh:MM:ss
    I am trying to capture a value from Request using xpath by using "Request.Body "xpath" "/root/element/element/value". Iam able to get the valuewith xpath using other tools but not with hoverfly.Please help
    John Davenport
    @JohnFDavenport

    @luchianenco No, I don’t think it can but can I check my understanding?

    You want Hoverfly to dynamically spot the 302 response from the first endpoint and take on the role of contacting the second endpoint on behalf of the client?

    Using Hoverfly to capture both interactions and manually changing the simulation is not what you want?

    Serghei Luchianenco
    @luchianenco
    @JohnFDavenport yes, this is what I would like to achieve - to do automatic substitute for the first endpoint response with the second response
    manoj-r
    @manoj-r

    Hi I'm looking for some suggestions for the issue that I have with starting hoverfly as side-car container, I'm passing arguments to change proxy port but the container always starts up in default port.
    Here s my deployment config for hoverfly

        - name: hoverfly
          imagePullPolicy: IfNotPresent
          image: spectolabs/hoverfly:v1.1.1
          env:
            - name: FLAGS
              value: "'-pp 8501'"
          args: ["$(FLAGS)"]
          ports:
          - containerPort:  8888
          - containerPort:  8501
          volumeMounts:
          - mountPath: /hoverfly
            name: simulation-volume

    Here s the kube-logs from the hoverfly container

    INFO[2019-11-19T06:33:00Z] Listen on specific interface host=0.0.0.0
    INFO[2019-11-19T06:33:00Z] Using memory backend
    INFO[2019-11-19T06:33:00Z] Proxy prepared... Destination=. Mode=simulate ProxyPort=8500
    INFO[2019-11-19T06:33:00Z] current proxy configuration destination=. mode=simulate port=8500
    INFO[2019-11-19T06:33:00Z] Admin interface is starting... AdminPort=8888
    INFO[2019-11-19T06:33:00Z] serving proxy

    Can someone pls provide your suggestion on this?

    Tommy Situ
    @tommysitu
    @manoj-r have you tried removing the single quotes:
    env:
            - name: FLAGS
              value: "-pp 8501"
    manoj-r
    @manoj-r

    @tommysitu yes I tried that and I got an error message along with list of all available options

    flag provided but not defined: -pp 8501
    Usage of /bin/hoverfly:
    -add
    Add new user '-add -username hfadmin -password hfpass'
    -admin
    Supply '-admin=false' to make this non admin user (default true)
    -ap string
    Admin port - run admin interface on another port (i.e. '-ap 1234' to run admin UI on port 1234)
    -auth
    Enable authentication
    -cache-size int
    Set the size of request/response cache (default 1000)```

    manoj-r
    @manoj-r

    I'm also trying to import a simulation json file to this sidecar container, so I would using something like
    '-import my-simulation.json'

    But that did not work either for me. Wondering if its due to single quotes but without that container would not start.

    Here is the kubernetes version
    Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.2"
    Server Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.0"

    Tommy Situ
    @tommysitu
    ok, I think this should work:
    env:
            - name: FLAGS
              value: -pp=8501
    no double or single quotes
    manoj-r
    @manoj-r
    That worked! Thanks a ton @tommysitu
    kdeepak270
    @kdeepak270
    @kdeepak270
    Can I have custome date format like {{now "1s" "mm/dd/yyyy hh:MM:ss
    I am trying to capture a value from Request using xpath by using "Request.Body "xpath" "/root/element/element/value". Iam able to get the valuewith xpath using other tools but not with hoverfly.Please help
    Tommy Situ
    @tommysitu
    Have you looked at the hovefly doc? Xpath for response templating is supported.
    kdeepak270
    @kdeepak270
    @tommysitu , I have read the doc and implemented as given in document, but iam unable to get the value after I did that.
    Amr Lotfy
    @LotfyOthman_twitter

    Hi,
    using hoverfly-java, we are using HttpClient, I have used useSystemProperties() and it works well for configuring proxy settings, however I still have TLS: unknown certificate error, I resolved it by adding hoverfly certificate to keystore

    wget https://raw.githubusercontent.com/SpectoLabs/hoverfly/master/core/cert.pem
    sudo $JAVA_HOME/bin/keytool -import -alias hoverfly -keystore $JAVA_HOME/jre/lib/security/cacerts -file cert.pem

    but I need this done without executing these shell commands, I suppose that useSystemProperties() should have added trust info which makes it unnecessary to use above commands, any hints about what went wrong?

    Amr Lotfy
    @LotfyOthman_twitter
    I tried adding sslContext
    CloseableHttpClient httpClient = httpClientBuilder.useSystemProperties().setSSLContext(ServiceNowConnectorTest.hoverflyRule.getSslConfigurer().getSslContext()).build();
    but still have TLS errors.
    Tommy Situ
    @tommysitu
    @LotfyOthman_twitter have you checked this out: https://hoverfly-java.readthedocs.io/en/latest/pages/misc/misc.html
    Tommy Situ
    @tommysitu
    @acoolcrazy you can try writing a middleware for that
    Amr Lotfy
    @LotfyOthman_twitter

    @tommysitu Thank you very much !!, I had to play around to get it to work because we needed to add some configurations as follows

    CloseableHttpClient httpClient = HttpClients.custom()
                    .setRetryHandler(new DefaultHttpRequestRetryHandler(2, true))
                    .setKeepAliveStrategy(new DefaultConnectionKeepAliveStrategy())
                    .setDefaultRequestConfig(requestConfig)
                    .setDefaultCredentialsProvider(credsProvider)
                    .setDefaultHeaders(headers)
                    .useSystemProperties()
                    .build();

    but there is another setting that when added causes TLS error again, that is setConnectionManager()
    previously we used httpClientBuilder as follows:

    PoolingHttpClientConnectionManager poolingConnectionManager = new PoolingHttpClientConnectionManager(30, TimeUnit.SECONDS);
            poolingConnectionManager.setMaxTotal(1000);
            poolingConnectionManager.setDefaultMaxPerRoute(1000);
            HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
            httpClientBuilder.setConnectionManager(poolingConnectionManager);

    so currently i dropped setting the PoolingHttpClientConnectionManager, Any ideas to avoid this problem ?

    Tommy Situ
    @tommysitu
    @LotfyOthman_twitter have a look at the OKHttpClient example and here: https://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html, you need to configure the ssl socket facotry for the ConnectionManager
    Amr Lotfy
    @LotfyOthman_twitter
    @tommysitu Thanks a lot !!, referring to SpectoLabs/hoverfly-java#137 i was able to add the required settings as follows:
    private PoolingHttpClientConnectionManager getPoolingHttpClientConnectionManager() {
            SSLConnectionSocketFactory sslsocketFactory = null;
            try {
                sslsocketFactory = new SSLConnectionSocketFactory(SSLContext.getDefault(), new DefaultHostnameVerifier());
            } catch (NoSuchAlgorithmException e) {
                e.printStackTrace();
            }
    
            Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
                                                                        .register("https", sslsocketFactory)
                                                                        .register("http", PlainConnectionSocketFactory.INSTANCE)
                                                                        .build();
    
            PoolingHttpClientConnectionManager poolingConnectionManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry); 
            poolingConnectionManager.setMaxTotal(1000);
            poolingConnectionManager.setDefaultMaxPerRoute(1000);
            // Used these settings instead of constructor parameters (long timeToLive, TimeUnit timeUnit)
            poolingConnectionManager.closeIdleConnections(30, TimeUnit.SECONDS);
    
            return poolingConnectionManager;
        }
    Amr Lotfy
    @LotfyOthman_twitter
    Tommy Situ
    @tommysitu
    :thumbsup:
    kdeepak270
    @kdeepak270
    @tommysitu , please help me in resolving an issue regarding the custom date format using {{now "1d" "mm/dd/yyyy hh:mm:ss"}}. Iam not getting the required the date format when I use the above one.Please help me in resolving this.
    Tommy Situ
    @tommysitu
    Hey @kdeepak270 sorry, didn’t quite get your question before. Hoverfly uses Golang date time format, have a look here for more info: https://docs.hoverfly.io/en/latest/pages/keyconcepts/templating/templating.html#example-date-time-formats
    acoolcrazy
    @acoolcrazy
    @tommysitu Can you please share example of python middleware code where values are captured from XML request and pass in to XML response body? Please note that in my case request content type is "x-www-form-urlencoded" and I am unable to capture values with XPath directly.
    kdeepak270
    @kdeepak270
    @tommysitu ,thanks for the help. I followed the golang syntax for date format and it worked. Thanks so much for the guidance. I have got one more issue.I want to access hoverfly using 'hoverfly -listen-on-port x.x.x.x'. I am able to access the admin dashboard on x.x.x.x:8888 after executing the command 'isletn-on-port...', but when try to simulate the existing simulation using x.x.x.x:8500, it says 'No request match found', what am I missing here?
    Tommy Situ
    @tommysitu
    @acoolcrazy sorry I hasn’t got an example for that. But you can find some other python middleware here: https://github.com/SpectoLabs/hoverfly/tree/master/examples/middleware
    @kdeepak270 you need check the log, it should tells you why the request was not matching