use of se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket in project webcert by sklintyg.
the class SignaturServiceImplTest method serverSignatureSuccess.
@Test
public void serverSignatureSuccess() throws IOException {
when(mockUtkastRepository.findOne(INTYG_ID)).thenReturn(completedUtkast);
when(mockUtkastRepository.save(any(Utkast.class))).thenReturn(completedUtkast);
// Do the call
SignaturTicket signatureTicket = intygSignatureService.serverSignature(INTYG_ID, completedUtkast.getVersion());
verify(intygService).storeIntyg(completedUtkast);
verify(notificationService).sendNotificationForDraftSigned(any(Utkast.class));
// Assert pdl log
verify(logService).logSignIntyg(any(LogRequest.class));
assertNotNull(signatureTicket);
assertNotNull(completedUtkast.getSignatur());
assertEquals(UtkastStatus.SIGNED, completedUtkast.getStatus());
}
use of se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket in project webcert by sklintyg.
the class SignaturServiceImplTest method getSignatureHashReturnsTicket.
@Test
public void getSignatureHashReturnsTicket() throws ModuleNotFoundException, ModuleException {
when(mockUtkastRepository.findOne(INTYG_ID)).thenReturn(completedUtkast);
SignaturTicket ticket = intygSignatureService.createDraftHash(INTYG_ID, completedUtkast.getVersion());
assertEquals(INTYG_ID, ticket.getIntygsId());
assertEquals(completedUtkast.getVersion(), ticket.getVersion());
assertEquals(SignaturTicket.Status.BEARBETAR, ticket.getStatus());
}
use of se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket in project webcert by sklintyg.
the class SignaturServiceImplTest method abortClientSignIfHsaIdOnSigDoesNotMatchSession.
@Test(expected = WebCertServiceException.class)
public void abortClientSignIfHsaIdOnSigDoesNotMatchSession() throws IOException {
when(mockUtkastRepository.findOne(INTYG_ID)).thenReturn(completedUtkast);
user = createWebCertUser(true);
user.setAuthenticationMethod(AuthenticationMethod.SITHS);
when(webcertUserService.getUser()).thenReturn(user);
SignaturTicket ticket = intygSignatureService.createDraftHash(INTYG_ID, completedUtkast.getVersion());
String signature = buildSignature();
intygSignatureService.clientSignature(ticket.getId(), signature);
}
use of se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket in project webcert by sklintyg.
the class SignaturServiceImplTest method clientSignatureFailsIfIntygWasModified.
@Test(expected = WebCertServiceException.class)
public void clientSignatureFailsIfIntygWasModified() throws IOException {
when(mockUtkastRepository.findOne(INTYG_ID)).thenReturn(completedUtkast);
SignaturTicket ticket = intygSignatureService.createDraftHash(INTYG_ID, completedUtkast.getVersion());
completedUtkast.setModel("{}");
String signature = buildSignature();
intygSignatureService.clientSignature(ticket.getId(), signature);
}
use of se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket in project webcert by sklintyg.
the class SignaturServiceImplTest method abortClientSignIfPersonIdOnSigDoesNotMatchSession.
@Test(expected = WebCertServiceException.class)
public void abortClientSignIfPersonIdOnSigDoesNotMatchSession() throws IOException {
Role role = AUTHORITIES_RESOLVER.getRole(AuthoritiesConstants.ROLE_PRIVATLAKARE);
user = createWebCertUser(true);
user.setAuthenticationMethod(AuthenticationMethod.NET_ID);
user.setRoles(AuthoritiesResolverUtil.toMap(role));
user.setPrivatLakareAvtalGodkand(true);
user.setPersonId(PERSON_ID);
when(mockUtkastRepository.findOne(INTYG_ID)).thenReturn(completedUtkast);
when(webcertUserService.getUser()).thenReturn(user);
SignaturTicket ticket = intygSignatureService.createDraftHash(INTYG_ID, completedUtkast.getVersion());
String signature = buildSignature();
intygSignatureService.clientSignature(ticket.getId(), signature);
}
Aggregations