Skip to content

Commit

Permalink
Add Tests
Browse files Browse the repository at this point in the history
Signed-off-by: Lars Geyer-Blaumeiser <[email protected]>
  • Loading branch information
lgblaumeiser committed Jan 29, 2025
1 parent aa91759 commit 91a2423
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
*
*/

package org.eclipse.tractusx.bdrs.api.directory.authentication;

import org.eclipse.edc.api.auth.spi.ApiAuthenticationProvider;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;

class ApiAuthenticationProviderRegistryImplTest {

private final ApiAuthenticationProviderRegistryImpl registry = new ApiAuthenticationProviderRegistryImpl();

@Test
void shouldResolveRegisteredProvider() {
ApiAuthenticationProvider provider = mock();
registry.register("authType", provider);

var actual = registry.resolve("authType");

assertThat(actual).isSameAs(provider);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
* Copyright (c) 2025 Cofinity-X GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
*
*/

package org.eclipse.tractusx.bdrs.api.directory.authentication;

import org.eclipse.edc.iam.verifiablecredentials.spi.model.Issuer;
import org.junit.jupiter.api.Test;

import java.util.Map;

import static org.assertj.core.api.Assertions.assertThat;

class TrustedIssuerRegistryTest {

private final TrustedIssuerRegistryImpl registry = new TrustedIssuerRegistryImpl();

@Test
void trustedIssuer() {
var issuer = new Issuer("test-id", Map.of());

registry.register(issuer, "test-type1");
registry.register(issuer, "test-type2");

assertThat(registry.getSupportedTypes(issuer)).containsExactly("test-type1", "test-type2");
}

@Test
void invalidIssuer() {
var issuer = new Issuer("test-id", Map.of());

assertThat(registry.getSupportedTypes(issuer)).isEmpty();
}

}

0 comments on commit 91a2423

Please sign in to comment.