Skip to content

Commit

Permalink
add config test and secret for managed identity
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaconsalvi committed Nov 27, 2024
1 parent 3c8aab5 commit bad459d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/terraform/container_app.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ resource "azurerm_container_app" "rtp-activator" {
secret_name = "identity-client-id"
}

env {
name = "AZURE_CLIENT_ID"
secret_name = "identity-client-id"
}

dynamic "env" {
for_each = var.rtp_environment_configs
content {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package it.gov.pagopa.rtp.activator.configuration;

import com.azure.cosmos.CosmosClientBuilder;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;

import org.mockito.junit.jupiter.MockitoExtension;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.verify;

@ExtendWith(MockitoExtension.class)
class CosmosDBConfigTest {

@Mock
private CosmosPropertiesConfig cosmosPropertiesConfig;

@InjectMocks
private CosmosDBConfig cosmosDBConfig;

@BeforeEach
void setUp() {
lenient().when(cosmosPropertiesConfig.getDbName()).thenReturn("test-db");
lenient().when(cosmosPropertiesConfig.getEndpoint()).thenReturn("https://test-endpoint:443/");
}

@Test
void testGetDatabaseName() {
String dbName = cosmosDBConfig.getDatabaseName();
assertEquals("test-db", dbName);
}

@Test
void testGetCosmosClientBuilder() {
CosmosClientBuilder builder = cosmosDBConfig.getCosmosClientBuilder();
verify(cosmosPropertiesConfig).getEndpoint();
assertNotNull(builder);
}
}

0 comments on commit bad459d

Please sign in to comment.