Skip to content
Snippets Groups Projects
Commit f3162704 authored by Alok Joshi's avatar Alok Joshi
Browse files

fix test

parent 7cdba932
No related branches found
No related tags found
1 merge request!553Add cache for entitlements authorize mechanism
Pipeline #304831 failed
......@@ -21,13 +21,13 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.opengroup.osdu.core.common.cache.ICache;
import org.opengroup.osdu.core.common.model.entitlements.AuthorizationResponse;
import org.opengroup.osdu.core.common.model.entitlements.GroupInfo;
import org.opengroup.osdu.core.common.model.entitlements.Groups;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.provider.interfaces.IAuthorizationService;
import org.opengroup.osdu.notification.cache.GroupVmCache;
import org.opengroup.osdu.notification.di.RequestInfoExt;
import org.opengroup.osdu.notification.provider.interfaces.IPubsubRequestBodyExtractor;
import org.opengroup.osdu.notification.provider.interfaces.IServiceAccountValidator;
......@@ -35,6 +35,7 @@ import org.opengroup.osdu.notification.utils.Config;
import org.powermock.modules.junit4.PowerMockRunner;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -76,8 +77,8 @@ public class AuthorizationFilterTest {
@Mock
private IPubsubRequestBodyExtractor extractor;
@Mock
private GroupVmCache groupVmCache;
@Autowired
private ICache<String, Groups> cache;
@InjectMocks
private AuthorizationFilter sut;
......@@ -165,7 +166,7 @@ public class AuthorizationFilterTest {
groups.setGroups(groupInfos);
groups.setDesId("desid");
groups.setMemberEmail("memberEmail");
when(this.groupVmCache.get("8Z2MjQ==")).thenReturn(groups);
when(this.cache.get("8Z2MjQ==")).thenReturn(groups);
assertTrue(this.sut.hasAnyPermission(ROLE1, ROLE2));
verify(authorizationService, never()).authorizeAny(any(DpsHeaders.class), any(String[].class));
}
......
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