aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/WellKnownApiHandlerTest.java
blob: ffdf6796d9dba4b5ec8a0896fd1f9c3971c731bb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.restapi.controller;

import com.yahoo.application.container.handler.Request;
import com.yahoo.vespa.hosted.controller.restapi.ContainerTester;
import com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
 * @author olaa
 */
class WellKnownApiHandlerTest extends ControllerContainerTest  {

    private ContainerTester tester;
    private final String SECURITY_TXT = "Mocked security txt";

    @BeforeEach
    public void before() {
        tester = new ContainerTester(container, "src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/");
    }

    @Test
    void securityTxt() {
        tester.assertResponse(new Request("http://localhost:8080/.well-known/security.txt"), SECURITY_TXT);
    }

    @Override
    protected String variablePartXml() {
        return String.format("""
                <component id='com.yahoo.vespa.hosted.controller.security.CloudAccessControlRequests'/>
                <component id='com.yahoo.vespa.hosted.controller.security.CloudAccessControl'/>
                <handler id="com.yahoo.vespa.hosted.controller.restapi.controller.WellKnownApiHandler" bundle="controller-clients" >
                  <config name="vespa.hosted.controller.config.well-known-folder">
                    <securityTxt>%s</securityTxt>
                  </config>
                  <binding>http://*/.well-known/*</binding>
                </handler>
                <http>
                  <server id='default' port='8080' />
                  <filtering>
                    <request-chain id='default'>
                      <filter id='com.yahoo.jdisc.http.filter.security.misc.NoopFilter'/>
                      <binding>http://*/*</binding>
                    </request-chain>
                  </filtering>
                </http>
                """, SECURITY_TXT);
    }

}