Search in sources :

Example 1 with AuthorityOverrideFunction

use of com.github.nagyesta.lowkeyvault.http.AuthorityOverrideFunction in project lowkey-vault by nagyesta.

the class LowkeyVaultContainerVanillaTest method testContainerShouldStartUpWhenCalledWithoutVaultNames.

@Test
void testContainerShouldStartUpWhenCalledWithoutVaultNames() {
    // given
    final LowkeyVaultContainer underTest = new LowkeyVaultContainer(DockerImageName.parse(getCurrentLowkeyVaultImageName()).asCompatibleSubstituteFor(LowkeyVaultContainer.DEFAULT_IMAGE_NAME)).withImagePullPolicy(PullPolicy.defaultPolicy());
    // when
    underTest.start();
    // then
    final String endpoint = underTest.getDefaultVaultBaseUrl();
    final AuthorityOverrideFunction authorityOverrideFunction = new AuthorityOverrideFunction(underTest.getDefaultVaultAuthority(), underTest.getEndpointAuthority());
    final TokenCredential credentials = new BasicAuthenticationCredential(underTest.getUsername(), underTest.getPassword());
    verifyConnectionIsWorking(endpoint, new ApacheHttpClient(authorityOverrideFunction), credentials);
}
Also used : AuthorityOverrideFunction(com.github.nagyesta.lowkeyvault.http.AuthorityOverrideFunction) ApacheHttpClient(com.github.nagyesta.lowkeyvault.http.ApacheHttpClient) BasicAuthenticationCredential(com.azure.core.credential.BasicAuthenticationCredential) TokenCredential(com.azure.core.credential.TokenCredential) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with AuthorityOverrideFunction

use of com.github.nagyesta.lowkeyvault.http.AuthorityOverrideFunction in project lowkey-vault by nagyesta.

the class ManagementStepDefs method aVaultIsCreatedWithName.

@Given("a vault is created with name {name}")
public void aVaultIsCreatedWithName(final String vaultName) {
    final String vaultAuthority = vaultName + ".localhost:8443";
    final String vaultUrl = "https://" + vaultAuthority;
    final AuthorityOverrideFunction overrideFunction = new AuthorityOverrideFunction(vaultAuthority, CONTAINER_AUTHORITY);
    context.setProvider(new ApacheHttpClientProvider(vaultUrl, overrideFunction));
    context.getClient().createVault(URI.create(vaultUrl), RecoveryLevel.RECOVERABLE_AND_PURGEABLE, 90);
}
Also used : ApacheHttpClientProvider(com.github.nagyesta.lowkeyvault.http.ApacheHttpClientProvider) AuthorityOverrideFunction(com.github.nagyesta.lowkeyvault.http.AuthorityOverrideFunction) Given(io.cucumber.java.en.Given)

Example 3 with AuthorityOverrideFunction

use of com.github.nagyesta.lowkeyvault.http.AuthorityOverrideFunction in project lowkey-vault by nagyesta.

the class SecretsStepDefs method theSecretClientIsCreatedWithVaultNameSelected.

@Given("a secret client is created with the vault named {name}")
public void theSecretClientIsCreatedWithVaultNameSelected(final String vaultName) {
    final String vaultAuthority = vaultName + ".localhost:8443";
    final String vaultUrl = "https://" + vaultAuthority;
    final AuthorityOverrideFunction overrideFunction = new AuthorityOverrideFunction(vaultAuthority, CONTAINER_AUTHORITY);
    context.setProvider(new ApacheHttpClientProvider(vaultUrl, overrideFunction));
}
Also used : ApacheHttpClientProvider(com.github.nagyesta.lowkeyvault.http.ApacheHttpClientProvider) AuthorityOverrideFunction(com.github.nagyesta.lowkeyvault.http.AuthorityOverrideFunction) Given(io.cucumber.java.en.Given)

Example 4 with AuthorityOverrideFunction

use of com.github.nagyesta.lowkeyvault.http.AuthorityOverrideFunction in project lowkey-vault by nagyesta.

the class LowkeyVaultContainerJupiterTest method testContainerShouldStartUpWhenCalledWithValidNames.

@Test
void testContainerShouldStartUpWhenCalledWithValidNames() {
    // given + when test container is created
    // then
    final String endpoint = underTest.getVaultBaseUrl(VAULT_NAME);
    final AuthorityOverrideFunction authorityOverrideFunction = new AuthorityOverrideFunction(underTest.getVaultAuthority(VAULT_NAME), underTest.getEndpointAuthority());
    final TokenCredential credentials = new BasicAuthenticationCredential(underTest.getUsername(), underTest.getPassword());
    verifyConnectionIsWorking(endpoint, new ApacheHttpClient(authorityOverrideFunction), credentials);
}
Also used : AuthorityOverrideFunction(com.github.nagyesta.lowkeyvault.http.AuthorityOverrideFunction) ApacheHttpClient(com.github.nagyesta.lowkeyvault.http.ApacheHttpClient) BasicAuthenticationCredential(com.azure.core.credential.BasicAuthenticationCredential) TokenCredential(com.azure.core.credential.TokenCredential) Test(org.junit.jupiter.api.Test)

Example 5 with AuthorityOverrideFunction

use of com.github.nagyesta.lowkeyvault.http.AuthorityOverrideFunction in project lowkey-vault by nagyesta.

the class LowkeyVaultContainerVanillaTest method testContainerShouldStartUpWhenCalledWithValidNames.

@Test
void testContainerShouldStartUpWhenCalledWithValidNames() {
    // given
    final LowkeyVaultContainer underTest = new LowkeyVaultContainer(DockerImageName.parse(getCurrentLowkeyVaultImageName()).asCompatibleSubstituteFor(LowkeyVaultContainer.DEFAULT_IMAGE_NAME), Collections.singleton(VAULT_NAME)).withImagePullPolicy(PullPolicy.defaultPolicy());
    // when
    underTest.start();
    // then
    final String endpoint = underTest.getVaultBaseUrl(VAULT_NAME);
    final AuthorityOverrideFunction authorityOverrideFunction = new AuthorityOverrideFunction(underTest.getVaultAuthority(VAULT_NAME), underTest.getEndpointAuthority());
    final TokenCredential credentials = new BasicAuthenticationCredential(underTest.getUsername(), underTest.getPassword());
    verifyConnectionIsWorking(endpoint, new ApacheHttpClient(authorityOverrideFunction), credentials);
}
Also used : AuthorityOverrideFunction(com.github.nagyesta.lowkeyvault.http.AuthorityOverrideFunction) ApacheHttpClient(com.github.nagyesta.lowkeyvault.http.ApacheHttpClient) BasicAuthenticationCredential(com.azure.core.credential.BasicAuthenticationCredential) TokenCredential(com.azure.core.credential.TokenCredential) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

AuthorityOverrideFunction (com.github.nagyesta.lowkeyvault.http.AuthorityOverrideFunction)6 BasicAuthenticationCredential (com.azure.core.credential.BasicAuthenticationCredential)3 TokenCredential (com.azure.core.credential.TokenCredential)3 ApacheHttpClient (com.github.nagyesta.lowkeyvault.http.ApacheHttpClient)3 ApacheHttpClientProvider (com.github.nagyesta.lowkeyvault.http.ApacheHttpClientProvider)3 Given (io.cucumber.java.en.Given)3 Test (org.junit.jupiter.api.Test)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2