Skip to content

Commit

Permalink
Merge pull request #739 from scalecube/fix-bug-with-not-properly-prop…
Browse files Browse the repository at this point in the history
…ageting-context

Fixed bug with not preserving existing context
  • Loading branch information
artem-v authored May 14, 2020
2 parents 6378464 + 0bed53a commit 324f8c9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private Context newPrincipalContext(Object authData, Context context) {
return context;
}
Object value = principalMapper.map(authData);
return Context.of(Authenticator.AUTH_CONTEXT_KEY, value);
return context.put(Authenticator.AUTH_CONTEXT_KEY, value);
}

public Object service() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,10 @@ void testAuthMethodWhenThereIsContextAndNoAuthenticator() throws Exception {
StepVerifier.create(
Mono.deferWithContext(context -> serviceMethodInvoker.invokeOne(message))
.subscriberContext(
context -> context.put(Authenticator.AUTH_CONTEXT_KEY, AUTH_DATA)))
context ->
context
.put(Authenticator.AUTH_CONTEXT_KEY, AUTH_DATA)
.put("NON_AUTH_CONTEXT", "test")))
.verifyComplete();
}

Expand Down Expand Up @@ -377,7 +380,10 @@ void testAuthMethodWhenNoContextButThereIsAuthenticator() throws Exception {
StepVerifier.create(
Mono.deferWithContext(context -> serviceMethodInvoker.invokeOne(message))
.subscriberContext(
context -> context.put(Authenticator.AUTH_CONTEXT_KEY, AUTH_DATA)))
context ->
context
.put(Authenticator.AUTH_CONTEXT_KEY, AUTH_DATA)
.put("NON_AUTH_CONTEXT", "test")))
.verifyComplete();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public Flux<String> throwException3(Flux<String> request) {
@Override
public Mono<Void> helloAuthContext() {
return Mono.deferWithContext(
context -> Mono.fromRunnable(() -> context.get(Authenticator.AUTH_CONTEXT_KEY)));
context ->
Mono.fromRunnable(() -> context.get(Authenticator.AUTH_CONTEXT_KEY))
.then(Mono.fromRunnable(() -> context.get("NON_AUTH_CONTEXT"))));
}
}

0 comments on commit 324f8c9

Please sign in to comment.