Skip to content

Commit

Permalink
change some properties
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaconsalvi committed Nov 27, 2024
1 parent 82402f3 commit 5f1e936
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package it.gov.pagopa.rtp.activator.configuration;


import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

Expand All @@ -24,7 +21,7 @@ public CosmosDBConfig(CosmosPropertiesConfig cosmosPropertiesConfig){

@Override
protected String getDatabaseName() {
return cosmosPropertiesConfig.getDbName();
return cosmosPropertiesConfig.getDatabase();
}

@Bean
Expand All @@ -33,8 +30,8 @@ public CosmosClientBuilder getCosmosClientBuilder() {
.build();

return new CosmosClientBuilder()
.endpoint(cosmosPropertiesConfig.getEndpoint())
.credential(credential);
.endpoint(cosmosPropertiesConfig.getUri())
.credential(credential);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import lombok.Getter;
import lombok.Setter;

@ConfigurationProperties(prefix = "cosmos.credential")
@ConfigurationProperties(prefix = "azure.cosmos")
@Getter
@Setter
public class CosmosPropertiesConfig {
private String dbName;
private String endpoint;
private String database;
private String uri;

public CosmosPropertiesConfig(String dbName, String endpoint) {
this.dbName = dbName;
this.endpoint = endpoint;
public CosmosPropertiesConfig(String database, String uri) {
this.database = database;
this.uri = uri;
}
}
6 changes: 3 additions & 3 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ management.endpoint.health.enabled=true
management.endpoint.health.probes.enabled=true

#repository
cosmos.credential.db-name=${DB_NAME:rtp}
cosmos.credential.endpoint=${COSMOS_ACCOUNT_RTP_ENDPOINT:}


azure.cosmos.uri=${COSMOS_ACCOUNT_RTP_ENDPOINT:}
azure.cosmos.key=${AZURE_COSMOS_KEY:}
azure.cosmos.database=${DB_NAME:rtp}
activation.base-url=${BASE_URL:http://localhost}
1 change: 1 addition & 0 deletions src/main/terraform/env/cstar-d-weu-rtp/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ rtp_activator_base_url = "https://mil-d-apim.azure-api.

rtp_environment_secrets = {
COSMOS_ACCOUNT_RTP_ENDPOINT : "cosmosdb-account-rtp-endpoint"
AZURE_COSMOS_KEY : "azure-cosmos-key"
APPLICATIONINSIGHTS_CONNECTION_STRING : "appinsights-connection-string"
}

Expand Down
1 change: 1 addition & 0 deletions src/main/terraform/env/cstar-p-weu-rtp/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ rtp_activator_base_url = "https://mil-d-apim.azure-api.
rtp_environment_secrets = {
COSMOS_ACCOUNT_RTP_ENDPOINT : "cosmosdb-account-rtp-endpoint"
APPLICATIONINSIGHTS_CONNECTION_STRING : "appinsights-connection-string"
AZURE_COSMOS_KEY : "azure-cosmos-key"
}

rtp_environment_configs = {
Expand Down
1 change: 1 addition & 0 deletions src/main/terraform/env/cstar-u-weu-rtp/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ rtp_activator_base_url = "https://mil-d-apim.azure-api.
rtp_environment_secrets = {
COSMOS_ACCOUNT_RTP_ENDPOINT : "cosmosdb-account-rtp-endpoint"
APPLICATIONINSIGHTS_CONNECTION_STRING : "appinsights-connection-string"
AZURE_COSMOS_KEY : "azure-cosmos-key"
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ class CosmosDBConfigTest {

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

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

@Test
void testGetCosmosClientBuilder() {
CosmosClientBuilder builder = cosmosDBConfig.getCosmosClientBuilder();
verify(cosmosPropertiesConfig).getEndpoint();
verify(cosmosPropertiesConfig).getUri();
assertNotNull(builder);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class CosmosPropertiesConfigTest {
@Test
void testPropertiesLoaded() {
assertNotNull(cosmosPropertiesConfig);
assertEquals("https://example.com/db/endpoint", cosmosPropertiesConfig.getEndpoint());
assertEquals("rtp", cosmosPropertiesConfig.getDbName());
assertEquals("https://example.com/db/endpoint", cosmosPropertiesConfig.getUri());
assertEquals("rtp", cosmosPropertiesConfig.getDatabase());

}
}
7 changes: 3 additions & 4 deletions src/test/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
logging.level.org.springframework.security=DEBUG
activation.baseUrl=https://example.com


cosmos.credential.db-name=rtp
cosmos.credential.endpoint=https://example.com/db/endpoint

azure.cosmos.uri=https://example.com/db/endpoint
azure.cosmos.key=your-primary-key
azure.cosmos.database=rtp

0 comments on commit 5f1e936

Please sign in to comment.