Upd swagger lib + rollback context building (#30)

This commit is contained in:
Egor Cherniak 2022-04-12 16:50:40 +03:00 committed by GitHub
parent 78b4dac4f1
commit e64a2d8d72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 17 deletions

View File

@ -43,7 +43,7 @@
<dependency>
<groupId>dev.vality</groupId>
<artifactId>swag-anapi-v2</artifactId>
<version>1.66-f571365-server</version>
<version>1.68-bb14531-server</version>
</dependency>
<dependency>
<groupId>dev.vality</groupId>

View File

@ -10,7 +10,6 @@ import dev.vality.bouncer.decisions.Context;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.thrift.TDeserializer;
import org.apache.thrift.TSerializer;
import org.springframework.stereotype.Component;
@ -28,29 +27,26 @@ public class BouncerContextFactory {
@SneakyThrows
public Context buildContext(AnapiBouncerContext bouncerContext) {
var contextFragment = orgManagerService.getUserAuthContext(
keycloakService.getAccessToken().getSubject());
var fragment = new ContextFragment();
var deserializer = new TDeserializer();
deserializer.deserialize(fragment, contextFragment.getContent());
enrichContextFragment(bouncerContext, fragment);
log.debug("Received user fragment from orgManager: {}", fragment.getUser());
var contextFragment = buildContextFragment(bouncerContext);
var serializer = new TSerializer();
contextFragment = new dev.vality.bouncer.ctx.ContextFragment()
var fragment = new dev.vality.bouncer.ctx.ContextFragment()
.setType(ContextFragmentType.v1_thrift_binary)
.setContent(serializer.serialize(fragment));
.setContent(serializer.serialize(contextFragment));
var userFragment = orgManagerService.getUserAuthContext(
keycloakService.getAccessToken().getSubject());
var context = new Context();
context.putToFragments(bouncerProperties.getContextFragmentId(), contextFragment);
context.putToFragments(bouncerProperties.getContextFragmentId(), fragment);
context.putToFragments("user", userFragment);
return context;
}
private void enrichContextFragment(AnapiBouncerContext bouncerContext, ContextFragment fragment) {
private ContextFragment buildContextFragment(AnapiBouncerContext bouncerContext) {
var env = buildEnvironment();
var contextAnalyticsApi = buildAnapiContext(bouncerContext);
var contextReports = buildReportContext(bouncerContext);
fragment.setAuth(buildAuth())
ContextFragment fragment = new ContextFragment();
return fragment
.setAuth(buildAuth())
.setEnv(env)
.setAnapi(contextAnalyticsApi)
.setReports(contextReports);

View File

@ -45,7 +45,6 @@ class StatPaymentToPaymentSearchResultConverterTest {
() -> assertEquals(magistaPayment.getExternalId(), result.getExternalID()),
() -> assertEquals(magistaPayment.getFee(), result.getFee()),
() -> assertEquals(PaymentFlow.TypeEnum.PAYMENTFLOWINSTANT, result.getFlow().getType()),
() -> assertNull(result.getGeoLocationInfo()),
() -> assertEquals(magistaPayment.getStatusChangedAt(), result.getStatusChangedAt().toString()),
() -> assertEquals(magistaPayment.getId(), result.getId()),
() -> assertEquals(magistaPayment.getInvoiceId(), result.getInvoiceID()),