Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public class RequestContext {
public static final Context.Key<RequestContext> CURRENT = Context.key("request_context");
private static final JwtParser JWT_PARSER = new JwtParser();

public RequestContext() {}

public RequestContext(RequestContext otherContext) {
this.headers.putAll(otherContext.headers);
}

public static RequestContext forTenantId(String tenantId) {
return new RequestContext()
.put(RequestContextConstants.TENANT_ID_HEADER_KEY, tenantId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ void testGetRequestHeaders() {
requestHeaders);
}

@Test
void testCopyConstructor() {
RequestContext originalContext = new RequestContext();
originalContext.put(RequestContextConstants.AUTHORIZATION_HEADER, TEST_AUTH_HEADER);
originalContext.put("x-some-tenant-header", "v1");

assertEquals(originalContext, new RequestContext(originalContext));
}

@Test
void testCreateForTenantId() {
RequestContext requestContext = RequestContext.forTenantId(TENANT_ID);
Expand Down
Loading