Commit 87aed2f4 authored by Rostislav Vatolin [SLB]'s avatar Rostislav Vatolin [SLB]
Browse files

update PartitionServiceEventGridClient

parent 2fde7344
Pipeline #29892 passed with stages
in 9 minutes and 54 seconds
...@@ -193,8 +193,9 @@ public class PartitionServiceEventGridClient { ...@@ -193,8 +193,9 @@ public class PartitionServiceEventGridClient {
* @return PartitionServiceClient * @return PartitionServiceClient
*/ */
private IPartitionProvider getServiceClient() { private IPartitionProvider getServiceClient() {
this.headers.put(DpsHeaders.AUTHORIZATION, "Bearer " + this.tokenService.getAuthorizationToken()); DpsHeaders newHeaders = DpsHeaders.createFromMap(headers.getHeaders());
return this.partitionFactory.create(headers); newHeaders.put(DpsHeaders.AUTHORIZATION, "Bearer " + tokenService.getAuthorizationToken());
return partitionFactory.create(newHeaders);
} }
} }
...@@ -25,6 +25,7 @@ import org.opengroup.osdu.azure.util.AzureServicePrincipleTokenService; ...@@ -25,6 +25,7 @@ import org.opengroup.osdu.azure.util.AzureServicePrincipleTokenService;
import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.partition.IPartitionFactory; import org.opengroup.osdu.core.common.partition.IPartitionFactory;
import org.opengroup.osdu.core.common.partition.IPartitionProvider;
import org.opengroup.osdu.core.common.partition.PartitionException; import org.opengroup.osdu.core.common.partition.PartitionException;
import org.opengroup.osdu.core.common.partition.PartitionInfo; import org.opengroup.osdu.core.common.partition.PartitionInfo;
import org.opengroup.osdu.core.common.partition.Property; import org.opengroup.osdu.core.common.partition.Property;
...@@ -32,9 +33,16 @@ import org.opengroup.osdu.core.common.partition.Property; ...@@ -32,9 +33,16 @@ import org.opengroup.osdu.core.common.partition.Property;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class PartitionServiceEventGridClientTest { public class PartitionServiceEventGridClientTest {
...@@ -118,4 +126,14 @@ public class PartitionServiceEventGridClientTest { ...@@ -118,4 +126,14 @@ public class PartitionServiceEventGridClientTest {
AppException exception = assertThrows(AppException.class, () -> partitionServiceClientSpy.getEventGridTopicInPartition("tenant1", "recordschangedtopic")); AppException exception = assertThrows(AppException.class, () -> partitionServiceClientSpy.getEventGridTopicInPartition("tenant1", "recordschangedtopic"));
assertEquals(500, exception.getError().getCode()); assertEquals(500, exception.getError().getCode());
} }
@Test
public void shouldNotModifyDpsHeaders() throws PartitionException {
when(tokenService.getAuthorizationToken()).thenReturn("token");
when(partitionFactory.create(any(DpsHeaders.class))).thenReturn(mock(IPartitionProvider.class));
sut.getPartitionInfo("test");
verify(headers, never()).put(DpsHeaders.AUTHORIZATION, "Bearer token");
}
} }
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