Commit 172a2d2c authored by Komal Makkar's avatar Komal Makkar
Browse files

intermediate changes

parent 923ddea5
......@@ -41,6 +41,7 @@
<reactor.netty.version>0.9.0.RELEASE</reactor.netty.version>
<reactor.core.version>3.3.0.RELEASE</reactor.core.version>
</properties>
<dependencies>
<dependency>
<groupId>com.microsoft.azure</groupId>
......@@ -53,58 +54,25 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.3.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-jwt</artifactId>
<version>1.0.10.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-jose</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>0.3.4</version>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-azure</artifactId>
<version>0.0.17</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>notification-core</artifactId>
......@@ -121,6 +89,7 @@
<artifactId>reactor-netty</artifactId>
<version>${reactor.netty.version}</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
......@@ -140,17 +109,28 @@
</exclusions>
<version>2.1.6.RELEASE</version>
</dependency>
<dependency>
<!--<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>-->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>jwks-rsa</artifactId>
<version>0.11.0</version>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>2.23.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
......
......@@ -15,6 +15,7 @@
# Log settings
logging.level.org.springframework.web=DEBUG
spring.profiles.active=local
LOG_PREFIX=notification
# Service settings
app.entitlements=${entitlements_service_endpoint}
......@@ -38,6 +39,9 @@ tenantInfo.container.name=TenantInfo
# Azure KeyVault configuration
azure.keyvault.url=${KEYVAULT_URI}
# Application name
spring.application.name=notification-azure
# Logging configuration
logging.transaction.enabled=true
logging.slf4jlogger.enabled=true
// Copyright © Microsoft Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package org.opengroup.osdu.notification.util;
import com.azure.security.keyvault.secrets.SecretClient;
import com.azure.security.keyvault.secrets.models.KeyVaultSecret;
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 org.opengroup.osdu.notification.provider.azure.util.AzureCosmosProperties;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.doReturn;
@ExtendWith(MockitoExtension.class)
public class AppPropertiesTests {
}
// Copyright © Microsoft Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package org.opengroup.osdu.notification.util;
import com.azure.security.keyvault.secrets.SecretClient;
import com.azure.security.keyvault.secrets.models.KeyVaultSecret;
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 org.opengroup.osdu.notification.provider.azure.util.AzureCosmosProperties;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.doReturn;
@ExtendWith(MockitoExtension.class)
public class AzureCosmosPropertiesTest {
@InjectMocks
private AzureCosmosProperties sut;
@Mock
private SecretClient kv;
@Mock
private KeyVaultSecret secret;
@Test
public void kvSecretChecksForNullResponse() {
// Set-Up
doReturn(null).when(kv).getSecret("secret-name");
// Act
IllegalStateException exception = assertThrows(IllegalStateException.class, () ->{
sut.getKeyVaultSecret(kv, "secret-name");
});
// Assert
assertEquals("No secret found with name secret-name", exception.getMessage());
}
@Test
public void kvSecretChecksForNullValueWithinResponse() {
// Set-Up
doReturn(null).when(secret).getValue();
doReturn(secret).when(kv).getSecret("secret-name");
// Act
IllegalStateException exception = assertThrows(IllegalStateException.class, () ->{
sut.getKeyVaultSecret(kv, "secret-name");
});
// Assert
assertEquals("Secret unexpectedly missing from KeyVault response for secret with name secret-name", exception.getMessage());
}
@Test
public void configReturnsCorrectSecretCosmosKey() {
// Set-Up
doReturn("cosmos-key-secret").when(secret).getValue();
doReturn(secret).when(kv).getSecret("cosmos-primary-key");
// Act
String secretValue = sut.cosmosKey(kv);
// Assert
assertEquals( "cosmos-key-secret", secretValue);
}
@Test
public void configReturnsCorrectSecretCosmosEndpoint() {
// Set-Up
doReturn("cosmos-endpoint-secret").when(secret).getValue();
doReturn(secret).when(kv).getSecret("cosmos-endpoint");
// Act
String secretValue = sut.cosmosEndpoint(kv);
// Assert
assertEquals( "cosmos-endpoint-secret", secretValue);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment