aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/tls/SecretStoreMock.java
blob: 2498668e28ad8dba518642ba0780f614392f076e (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
// 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.tls;

import com.yahoo.component.annotation.Inject;
import com.yahoo.security.KeyUtils;
import com.yahoo.security.X509CertificateUtils;
import com.yahoo.vespa.hosted.controller.tls.config.TlsConfig;

/**
 * A secret store mock that's pre-populated with a certificate and key.
 *
 * @author mpolden
 */
@SuppressWarnings("unused") // Injected
public class SecretStoreMock extends com.yahoo.vespa.hosted.controller.integration.SecretStoreMock {

    @Inject
    public SecretStoreMock(TlsConfig config) {
        addKeyPair(config);
    }

    private void addKeyPair(TlsConfig config) {
        setSecret(config.privateKeySecret(), KeyUtils.toPem(Keys.keyPair.getPrivate()));
        setSecret(config.certificateSecret(), X509CertificateUtils.toPem(Keys.certificate));
    }

}