Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
mofobo-bit committed Mar 30, 2022
1 parent c170332 commit e098a68
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import ch.admin.bag.covidcertificate.gateway.client.IdentityAuthorizationClient;
import ch.admin.bag.covidcertificate.gateway.client.internal.FunctionAuthorizationClient;
import ch.admin.bag.covidcertificate.gateway.error.RestError;
import ch.admin.bag.covidcertificate.gateway.features.authorization.model.Function;
import ch.admin.bag.covidcertificate.gateway.service.dto.incoming.DtoWithAuthorization;
import ch.admin.bag.covidcertificate.gateway.service.dto.incoming.IdentityDto;
Expand All @@ -19,6 +20,7 @@

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
Expand Down Expand Up @@ -73,7 +75,7 @@ void verifiesOtp__ifNotInAllowedList() throws InvalidBearerTokenException {
this.setCnNameInContext("not-in-allowed");

when(bearerTokenValidationService.validateOtpAndGetAuthData(any(String.class), any(String.class)))
.thenReturn(new UserAuthorizationData(any(String.class), any(String.class), Collections.emptyList()));
.thenReturn(new UserAuthorizationData("dsd", "sdsd", Collections.emptyList()));

assertDoesNotThrow(() -> authorizationService.validateAndGetId(dtoWithAuthorization, ipAddress, Function.CREATE_VACCINE_CERTIFICATE));
verify(bearerTokenValidationService, times(1)).validateOtpAndGetAuthData(this.dtoWithAuthorization.getOtp(), ipAddress);
Expand All @@ -87,7 +89,7 @@ void checksOtp__ifIdentityDtoIsNullAndInAllowedList() throws InvalidBearerTokenE
var otherDtoWithAuth = this.getDtoWithAuthorization(true, false);

when(bearerTokenValidationService.validateOtpAndGetAuthData(any(String.class), any(String.class)))
.thenReturn(new UserAuthorizationData(any(String.class), any(String.class), Collections.emptyList()));
.thenReturn(new UserAuthorizationData("dsdsd", "dsd", Collections.emptyList()));

assertDoesNotThrow(() -> authorizationService.validateAndGetId(otherDtoWithAuth, ipAddress, Function.CREATE_VACCINE_CERTIFICATE));
verify(identityAuthorizationClient, never()).fetchUserAndGetAuthData(any(), any());
Expand Down

0 comments on commit e098a68

Please sign in to comment.