Skip to content

Commit c76be61

Browse files
committed
fix rebase errors.
1 parent cb495c5 commit c76be61

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

auth/src/main/java/feast/auth/authorization/HttpAuthorizationProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.slf4j.LoggerFactory;
2828
import org.springframework.cache.annotation.Cacheable;
2929
import org.springframework.security.core.Authentication;
30+
import org.springframework.security.oauth2.jwt.Jwt;
3031

3132
/**
3233
* HTTPAuthorizationProvider uses an external HTTP service for authorizing requests. Please see

auth/src/test/java/feast/auth/authorization/HttpAuthorizationProviderCachingTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,26 +90,30 @@ public void testCheckAccessToProjectShouldReadFromCacheWhenAvailable() throws Ex
9090
Jwt jwt = Mockito.mock(Jwt.class);
9191
Map<String, Object> claims = new HashMap<>();
9292
claims.put("email", "test@test.com");
93+
doReturn(jwt).when(auth).getCredentials();
9394
doReturn(jwt).when(auth).getPrincipal();
9495
doReturn(claims).when(jwt).getClaims();
96+
doReturn("test_token").when(jwt).getTokenValue();
9597
AuthorizationResult authResult = new AuthorizationResult();
9698
authResult.setAllowed(true);
97-
doReturn(authResult).when(api).checkAccessPost(any(CheckAccessRequest.class));
99+
doReturn(authResult)
100+
.when(api)
101+
.checkAccessPost(any(CheckAccessRequest.class), any(String.class));
98102

99103
// Should save the result in cache
100104
provider.checkAccessToProject("test", auth);
101105
// Should read from cache
102106
provider.checkAccessToProject("test", auth);
103-
verify(api, times(1)).checkAccessPost(any(CheckAccessRequest.class));
107+
verify(api, times(1)).checkAccessPost(any(CheckAccessRequest.class), any(String.class));
104108

105109
// cache ttl is set to 1 second for testing.
106110
Thread.sleep(1100);
107111

108112
// Should make an invocation to external service
109113
provider.checkAccessToProject("test", auth);
110-
verify(api, times(2)).checkAccessPost(any(CheckAccessRequest.class));
114+
verify(api, times(2)).checkAccessPost(any(CheckAccessRequest.class), any(String.class));
111115
// Should read from cache
112116
provider.checkAccessToProject("test", auth);
113-
verify(api, times(2)).checkAccessPost(any(CheckAccessRequest.class));
117+
verify(api, times(2)).checkAccessPost(any(CheckAccessRequest.class), any(String.class));
114118
}
115119
}

0 commit comments

Comments
 (0)