@PostMapping(value = "v1/stub/sendPip", consumes = "application/json", produces = "application/json")
    public void sendPipRequest(@RequestBody StubRequest request) {
        final Optional<EidSession> result = sessionRepo.findById(request.getSessionId());
        if (!result.isPresent()) {
            throw new ClientException("Could not find session");
        }

        final EidSession session = result.get();
        final String status = request.getStatus();
        if (!"success".equals(status)) {
            confirmService.sendError(session.getReturnUrl(), session.getConfirmId(), session.getConfirmSecret(), status);
        } else {
            final Confirmation confirm = new Confirmation(
                request.getPolymorph(), DocumentType.fromValue(request.getDocumentType()), request.getSequenceNo()
            );
            confirmService.sendAssertion(session.getReturnUrl(), session.getConfirmId(), session.getConfirmSecret(),
                PolymorphType.PIP, confirm);
        }
    }
@Test
    public void testStub() {
        EidSession session = new EidSession();
        session.setReturnUrl("http://localhost");
        session.setId("id");
        session.setConfirmId("confirmId");
        session.setConfirmSecret("secret");
        Mockito.when(sessionRepo.findById("id")).thenReturn(Optional.of(session));

        StubRequest request = new StubRequest();
        request.setDocumentType("NL-Rijbewijs");
        request.setPolymorph(Base64.decode("eHl6"));
        request.setSequenceNo("SSSSSSSSSSSSS");
        request.setSessionId("id");
        request.setStatus("success");

        controller.sendPipRequest(request);
        Mockito.verify(confirmService).sendAssertion(
            Mockito.eq("http://localhost"), Mockito.eq("confirmId"), Mockito.eq("secret"),
            Mockito.eq(PolymorphType.PIP), Mockito.eq(
                new Confirmation(Base64.decode("eHl6"),  DocumentType.DL, "SSSSSSSSSSSSS")
            )
        );
    }