File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
main/java/org/hypertrace/core/grpcutils/context
test/java/org/hypertrace/core/grpcutils/context Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,12 @@ public class RequestContext {
3333 public static final Context .Key <RequestContext > CURRENT = Context .key ("request_context" );
3434 private static final JwtParser JWT_PARSER = new JwtParser ();
3535
36+ public RequestContext () {}
37+
38+ public RequestContext (RequestContext otherContext ) {
39+ this .headers .putAll (otherContext .headers );
40+ }
41+
3642 public static RequestContext forTenantId (String tenantId ) {
3743 return new RequestContext ()
3844 .put (RequestContextConstants .TENANT_ID_HEADER_KEY , tenantId )
Original file line number Diff line number Diff line change @@ -49,6 +49,15 @@ void testGetRequestHeaders() {
4949 requestHeaders );
5050 }
5151
52+ @ Test
53+ void testCopyConstructor () {
54+ RequestContext originalContext = new RequestContext ();
55+ originalContext .put (RequestContextConstants .AUTHORIZATION_HEADER , TEST_AUTH_HEADER );
56+ originalContext .put ("x-some-tenant-header" , "v1" );
57+
58+ assertEquals (originalContext , new RequestContext (originalContext ));
59+ }
60+
5261 @ Test
5362 void testCreateForTenantId () {
5463 RequestContext requestContext = RequestContext .forTenantId (TENANT_ID );
You can’t perform that action at this time.
0 commit comments