Configuring nginx-ingress for E2E tests

6/14/2018

I have a integration Kubernetes cluster in AWS, and I want to conduct end-to-end tests on that cluster.

I currently use Deployments and Services.

The proposed approach is to use Ingress and configure it to use cookie injection for ensuring access to web page that implements the following logic:

  1. When special header is recognized in request -> allow the agent to enter the webpage (used for automated tests)

  2. When special header is not recognized in request -> display popup for basic http authentication (used for normal users).

I also want to use a single entry point for both cases (the same url).

I've been browsing official documentation, but didn't find the specified use case, nor did I find any examples that might be close to what I want to achieve.

I'm interested if anyone has used similar approach or something that might be similar in use.

Many thanks!

-- Bartosz Zawadzki
cookies
kubernetes
kubernetes-ingress
nginx

1 Answer

6/15/2018

It sounds like either configuration-snippet or a full-blown custom template may do what you want, along with the nginx if and add_header using something like:

if ($http_user_agent ~ "My Sekrit Agent/666") {
    add_header Authentication "Basic dXNlcm5hbWU6cGFzc3dvcmQ=";
}
-- mdaniel
Source: StackOverflow