-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add component ID to API key identifier #3615
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -30,6 +30,7 @@ | |||||
import org.wso2.carbon.apimgt.common.gateway.dto.JWTConfigurationDto; | ||||||
import org.wso2.choreo.connect.enforcer.common.CacheProvider; | ||||||
import org.wso2.choreo.connect.enforcer.commons.model.APIConfig; | ||||||
import org.wso2.choreo.connect.enforcer.commons.model.ChoreoComponentInfo; | ||||||
import org.wso2.choreo.connect.enforcer.commons.model.RequestContext; | ||||||
import org.wso2.choreo.connect.enforcer.config.ConfigHolder; | ||||||
import org.wso2.choreo.connect.enforcer.config.EnforcerConfig; | ||||||
|
@@ -68,9 +69,13 @@ public void setup() { | |||||
public void retrieveTokenFromRequestCtxTest_invalidKey() { | ||||||
|
||||||
RequestContext.Builder requestContextBuilder = new RequestContext.Builder("/api-key"); | ||||||
ChoreoComponentInfo choreoComponentInfo = new ChoreoComponentInfo(); | ||||||
choreoComponentInfo.setComponentID("component_id"); | ||||||
requestContextBuilder.matchedAPI(new APIConfig.Builder("Petstore") | ||||||
.basePath("/test") | ||||||
.uuid("6003a3b7-af0f-4fb3-853e-a6562b2345f2") | ||||||
.apiType("REST") | ||||||
.choreoComponentInfo(choreoComponentInfo) | ||||||
.build()); | ||||||
Map<String, String> headersMap = new HashMap<>(); | ||||||
headersMap.put("choreo-api-key", | ||||||
|
@@ -97,9 +102,13 @@ public void retrieveTokenFromRequestCtxTest_cached_validKey() throws APISecurity | |||||
PowerMockito.when(CacheProvider.getGatewayAPIKeyJWTCache()).thenReturn(gatewayAPIKeyJWTCache); | ||||||
PowerMockito.when(gatewayAPIKeyJWTCache.getIfPresent(Mockito.anyString())).thenReturn(mockJWT); | ||||||
|
||||||
ChoreoComponentInfo choreoComponentInfo = new ChoreoComponentInfo(); | ||||||
choreoComponentInfo.setComponentID("component_id"); | ||||||
RequestContext.Builder requestContextBuilder = new RequestContext.Builder("/api-key"); | ||||||
requestContextBuilder.matchedAPI(new APIConfig.Builder("Petstore") | ||||||
.basePath("/test") | ||||||
.uuid("6003a3b7-af0f-4fb3-853e-a6562b2345f2") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not a uuid4 string
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not used in the tests. Will remove these in a separate PR |
||||||
.choreoComponentInfo(choreoComponentInfo) | ||||||
.apiType("REST") | ||||||
.build()); | ||||||
Map<String, String> headersMap = new HashMap<>(); | ||||||
|
@@ -128,10 +137,14 @@ public void retrieveTokenFromRequestCtxTest_validKey() throws APISecurityExcepti | |||||
PowerMockito.when(CacheProvider.getGatewayAPIKeyJWTCache()).thenReturn(gatewayAPIKeyJWTCache); | ||||||
PowerMockito.when(gatewayAPIKeyJWTCache.getIfPresent(Mockito.anyString())).thenReturn(null); | ||||||
|
||||||
ChoreoComponentInfo choreoComponentInfo = new ChoreoComponentInfo(); | ||||||
choreoComponentInfo.setComponentID("component_id"); | ||||||
RequestContext.Builder requestContextBuilder = new RequestContext.Builder("/api-key"); | ||||||
requestContextBuilder.matchedAPI(new APIConfig.Builder("Petstore") | ||||||
.basePath("/test") | ||||||
.uuid("6003a3b7-af0f-4fb3-853e-a6562b2345f2") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
.apiType("REST") | ||||||
.choreoComponentInfo(choreoComponentInfo) | ||||||
.build()); | ||||||
Map<String, String> headersMap = new HashMap<>(); | ||||||
headersMap.put("choreo-api-key", | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.