File tree 2 files changed +15
-0
lines changed
main/java/org/hypertrace/core/grpcutils/context
test/java/org/hypertrace/core/grpcutils/context
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,12 @@ public class RequestContext {
33
33
public static final Context .Key <RequestContext > CURRENT = Context .key ("request_context" );
34
34
private static final JwtParser JWT_PARSER = new JwtParser ();
35
35
36
+ public RequestContext () {}
37
+
38
+ public RequestContext (RequestContext otherContext ) {
39
+ this .headers .putAll (otherContext .headers );
40
+ }
41
+
36
42
public static RequestContext forTenantId (String tenantId ) {
37
43
return new RequestContext ()
38
44
.put (RequestContextConstants .TENANT_ID_HEADER_KEY , tenantId )
Original file line number Diff line number Diff line change @@ -49,6 +49,15 @@ void testGetRequestHeaders() {
49
49
requestHeaders );
50
50
}
51
51
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
+
52
61
@ Test
53
62
void testCreateForTenantId () {
54
63
RequestContext requestContext = RequestContext .forTenantId (TENANT_ID );
You can’t perform that action at this time.
0 commit comments