Varnish testing (VTC) with OAuth Backend

118 Views Asked by At

I am trying to write some Varnish (VTC) tests in order to test our (partly) varnish-managed OAuth Backend functionality.

Simply varnish is just taking the OAuth Cookie (from client), checks it's token against our OAuth backend and responds either with cached data or redirects to login page, if token is invalid/expired.

In my test, I do not want to call the OAuth Client. I want to mock it for the test context, so I would need to override the default varnish configuration, which looks like this:

varnish v1 -vcl {
     backend default {
       .host = "${s1_addr}";
       .port = "${s1_port}";
       .first_byte_timeout = 350s;
     }

     include "./includes.vcl";

 } -start

This default configuration works with the live working OAuth server. I tried to override the OAuth config like this:

 backend oauth {
     .host = "127.0.0.1";
     .port = "8090";
 }

But it did not succeed. Instead it exited with a failure code without any explaining message.

I could not find any proper documentation, hope someone had this issue before.

Thanks in regards.

1

There are 1 best solutions below

0
On

You can also define servers/backends in varnish tests. Try this way:

# default backend
server s1 {
    rxreq
    txresp -hdr "Set-Cookie: ignore=cookie; expires=Tue, 06-Dec-2016 22:00:00 GMT; Max-Age=2588826; path=/"
}

server s1 -start

varnish v1 -vcl+backend {
    include "./includes.vcl";
} -start

client c1 {
    txreq -url "/" -hdr "Host: www.domain.com" -hdr "Cookie: client=cookie_here"
    rxresp
    expect resp.status == 200
} -run