Skip to content
Snippets Groups Projects
Commit 663d5706 authored by Aliaksei Darafeyeu's avatar Aliaksei Darafeyeu
Browse files

migrates core-lib-azure to 0.0.44

parent 73ab2b66
No related branches found
No related tags found
1 merge request!20add app-resource-id in app properties
Pipeline #16453 failed
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<os-core-common.version>0.3.12</os-core-common.version> <os-core-common.version>0.3.16</os-core-common.version>
<tomcat_embed_core_version>9.0.37</tomcat_embed_core_version> <tomcat_embed_core_version>9.0.37</tomcat_embed_core_version>
</properties> </properties>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>partition</artifactId> <artifactId>partition</artifactId>
<groupId>org.opengroup.osdu</groupId> <groupId>org.opengroup.osdu</groupId>
...@@ -15,14 +16,53 @@ ...@@ -15,14 +16,53 @@
<packaging>jar</packaging> <packaging>jar</packaging>
<properties> <properties>
<osdu.partition-core.version>1.0.0</osdu.partition-core.version>
<osdu.corelibazure.version>0.0.44</osdu.corelibazure.version>
<osdu.oscorecommon.version>0.3.16</osdu.oscorecommon.version>
<azure.version>2.3.5</azure.version> <azure.version>2.3.5</azure.version>
<junit.version>4.12</junit.version>
<mockito.version>2.25.0</mockito.version>
<powermock.version>2.0.2</powermock.version>
<nimbus-jose-jwt>7.9</nimbus-jose-jwt>
<jwks-rsa>0.12.0</jwks-rsa>
</properties> </properties>
<dependencyManagement>
<dependencies>
<!-- Inherit managed dependencies from core-lib-azure -->
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-azure</artifactId>
<version>${osdu.corelibazure.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies> <dependencies>
<!-- OSDU dependencies -->
<dependency> <dependency>
<groupId>com.microsoft.azure</groupId> <groupId>org.opengroup.osdu</groupId>
<artifactId>azure-active-directory-spring-boot-starter</artifactId> <artifactId>partition-core</artifactId>
<version>${azure.version}</version> <version>${osdu.partition-core.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-azure</artifactId>
<version>${osdu.corelibazure.version}</version>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<exclusions>
<exclusion>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId> <artifactId>spring-boot-starter-security</artifactId>
...@@ -41,134 +81,71 @@ ...@@ -41,134 +81,71 @@
<groupId>org.springframework.security</groupId> <groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-client</artifactId> <artifactId>spring-security-oauth2-client</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-security-keyvault-secrets</artifactId>
<version>4.2.0</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.security</groupId> <groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-jose</artifactId> <artifactId>spring-security-oauth2-jose</artifactId>
</dependency> </dependency>
<!-- Azure dependencies -->
<dependency> <dependency>
<groupId>com.auth0</groupId> <groupId>com.microsoft.azure</groupId>
<artifactId>jwks-rsa</artifactId> <artifactId>azure-spring-boot-metrics-starter</artifactId>
<version>0.12.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.azure</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>azure-core-http-netty</artifactId> <artifactId>spring-boot-starter-log4j2</artifactId>
<version>1.5.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.microsoft.azure</groupId> <groupId>com.microsoft.azure</groupId>
<artifactId>msal4j</artifactId> <artifactId>azure-storage</artifactId>
<version>0.5.0-preview</version> <version>8.6.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.nimbusds</groupId> <groupId>com.microsoft.azure</groupId>
<artifactId>nimbus-jose-jwt</artifactId> <artifactId>azure-active-directory-spring-boot-starter</artifactId>
<version>7.9</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.opengroup.osdu</groupId> <groupId>com.microsoft.azure</groupId>
<artifactId>core-lib-azure</artifactId> <artifactId>msal4j</artifactId>
<version>0.0.39</version>
<exclusions>
<exclusion>
<groupId>com.nimbusds</groupId>
<artifactId>nimbus-jose-jwt</artifactId>
</exclusion>
<exclusion>
<groupId>com.microsoft.azure</groupId>
<artifactId>msal4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
</exclusion>
<exclusion>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-spring-boot-starter</artifactId>
</exclusion>
<exclusion>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-spring-boot-metrics-starter</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</exclusion>
<exclusion>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-logging-log4j2</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<!-- Other dependencies -->
<dependency> <dependency>
<groupId>org.opengroup.osdu</groupId> <groupId>com.auth0</groupId>
<artifactId>os-core-common</artifactId> <artifactId>jwks-rsa</artifactId>
<version>${os-core-common.version}</version> <version>${jwks-rsa}</version>
<exclusions>
<exclusion>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.opengroup.osdu</groupId> <groupId>com.nimbusds</groupId>
<artifactId>partition-core</artifactId> <artifactId>nimbus-jose-jwt</artifactId>
<version>1.0.0</version> <version>${nimbus-jose-jwt}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
</dependency> </dependency>
<!-- <!-- Test dependencies -->
Override the spring-boot version of these dependencies to the ones
required by the azure-core library. This needs to be done for each
app that depends on this library
-->
<dependency>
<groupId>io.projectreactor.netty</groupId>
<artifactId>reactor-netty</artifactId>
<version>0.9.10.RELEASE</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.3.8.RELEASE</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-storage</artifactId>
<version>8.6.5</version>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>4.12</version> <version>${junit.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-core</artifactId>
<version>2.25.0</version> <version>${mockito.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.powermock</groupId> <groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId> <artifactId>powermock-api-mockito2</artifactId>
<version>2.0.2</version> <version>${powermock.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.powermock</groupId> <groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId> <artifactId>powermock-module-junit4</artifactId>
<version>2.0.2</version> <version>${powermock.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
...@@ -191,30 +168,6 @@ ...@@ -191,30 +168,6 @@
<artifactId>spring-security-test</artifactId> <artifactId>spring-security-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- App Insights dependencies -->
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-spring-boot-starter</artifactId>
<version>2.6.1</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-spring-boot-metrics-starter</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<version>2.3.1.RELEASE</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-logging-log4j2</artifactId>
<version>2.6.1</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -55,12 +55,6 @@ public class AADSecurityConfigTest { ...@@ -55,12 +55,6 @@ public class AADSecurityConfigTest {
} }
@Test @Test
@Ignore
// temporary disabled because it is failed on build machine, is not reproducible locally
// from logs: 'Server returned HTTP response code: 400 for URL: http://169.254.169.254/... '
// IP is Azure Instance Metadata Service, why it is reached is not clear from logs (trimmed)
// tried locally to set breakpoint, disable network and logout from azure, I can't reproduce
// don't have time for more investigations now
public void testOptions() throws Exception { public void testOptions() throws Exception {
mockMvc.perform(options("/swagger")) mockMvc.perform(options("/swagger"))
.andExpect(status().is2xxSuccessful()); .andExpect(status().is2xxSuccessful());
......
...@@ -17,43 +17,57 @@ package org.opengroup.osdu.partition.provider.azure.security; ...@@ -17,43 +17,57 @@ package org.opengroup.osdu.partition.provider.azure.security;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import static org.mockito.Mockito.mock;
import static org.powermock.api.mockito.PowerMockito.mockStatic;
import static org.powermock.api.mockito.PowerMockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@RunWith(PowerMockRunner.class) import com.microsoft.azure.spring.autoconfigure.aad.AADAppRoleStatelessAuthenticationFilter;
import com.microsoft.azure.spring.autoconfigure.aad.UserPrincipalManager;
@RunWith(SpringRunner.class)
@PrepareForTest(SecurityContextHolder.class) @PrepareForTest(SecurityContextHolder.class)
@SpringBootTest(classes = {WhoamiController.class, AADSecurityConfig.class,
AADAppRoleStatelessAuthenticationFilter.class})
@WebAppConfiguration
public class WhoamiControllerTest { public class WhoamiControllerTest {
private MockMvc mockMvc; private MockMvc mockMvc;
@Autowired
private WebApplicationContext context;
@MockBean
private UserPrincipalManager userPrincipalManager;
@Before @Before
public void setup() { public void setup() {
mockMvc = MockMvcBuilders.standaloneSetup(WhoamiController.class).build(); mockMvc = MockMvcBuilders.webAppContextSetup(context).build();
} }
@Test @Test
public void whoami() throws Exception { public void whoami() throws Exception {
mockStatic(SecurityContextHolder.class); Authentication authentication = Mockito.mock(Authentication.class);
SecurityContext securityContext = Mockito.mock(SecurityContext.class);
SecurityContext securityContext = mock(SecurityContext.class); Mockito.when(securityContext.getAuthentication()).thenReturn(authentication);
when(securityContext.getAuthentication()).thenReturn(mock(Authentication.class)); SecurityContextHolder.setContext(securityContext);
when(SecurityContextHolder.getContext()).thenReturn(securityContext);
mockMvc.perform(post("/whoami") mockMvc.perform(post("/whoami")
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON)) .accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()); .andExpect(status().isOk());
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment