STUB a server for Webhook response in CIRCLE-CI

circle.yml

#1

We are currently building our integration test. One of our test demand that we expect out test expect to receive (a callback response) from one of our services.

Stuff look like this

describe 'Integration Test' do 
  before(:each) do 
     @replies = { '/callback' => [200, {}, ["Callback Received"]] }
  end

  context 'Callback' do 
     it 'should receive a callback response' do  
       StubServer.open('4567', @replies) do |server|
         server.wait until server.recorded_reqs.any?
         req_body = JSON.parse(server.recorded_reqs.first["REQUEST_BODY"]).symbolize_keys
         expect(req_body[:data]).not_to be_nil 
       end
     end
  end
end

Service 1 trigger a callback to --> Integration Test (Stub Server Running) --> Integration Stub server intercept the request and run the matched expectation.

When Locally, we run StubServer (stub server running at http://localhost:4567) and we validate the acceptance test for the callback response callback response or a request originated from Service 1

If, I have to simulate the above behavior in Circle CI. I would need an endpoint along with port to run my stub server which should accessible from outside i.e from Service 1

Any Clue on this?


#2

Hi,

Sorry for the late reply, I see you posted this question twice, so I will reply here and remove your other post. I asked around about your question and the generic answer is that there are many ways to do what you are asking about and our API will be changing in the future, so the thinking is that this will be something for us to document in the not too distant future, but is not currently a focus (of course we welcome contributions of content if you do set this up and want to share that with others). Here is one example of how you might do such a thing in case it is still helpful to you.

https://www.twilio.com/blog/2013/10/test-your-webhooks-locally-with-ngrok.html

Regards,
Michelle


#3