use of io.helidon.security.SecurityLevel in project helidon by oracle.
the class TimeValidatorTest method initClass.
@BeforeAll
public static void initClass() {
validator = TimeValidator.create();
EndpointConfig ep = mock(EndpointConfig.class);
TimeValidator.TimeOfDay tod = mock(TimeValidator.TimeOfDay.class);
when(tod.from()).thenReturn("08:15:00");
when(tod.to()).thenReturn("12:00");
annotations.add(tod);
TimeValidator.TimeOfDay tod2 = mock(TimeValidator.TimeOfDay.class);
when(tod2.from()).thenReturn("12:30:00");
when(tod2.to()).thenReturn("17:30");
annotations.add(tod2);
SecurityLevel appSecurityLevel = mock(SecurityLevel.class);
SecurityLevel classSecurityLevel = mock(SecurityLevel.class);
List<SecurityLevel> securityLevels = new ArrayList<>();
securityLevels.add(appSecurityLevel);
securityLevels.add(classSecurityLevel);
when(ep.securityLevels()).thenReturn(securityLevels);
when(classSecurityLevel.filterAnnotations(TimeValidator.TimeOfDay.class, EndpointConfig.AnnotationScope.CLASS)).thenReturn(List.of(tod, tod2));
TimeValidator.DaysOfWeek dow = mock(TimeValidator.DaysOfWeek.class);
when(dow.value()).thenReturn(new DayOfWeek[] { DayOfWeek.MONDAY, DayOfWeek.TUESDAY, DayOfWeek.WEDNESDAY, DayOfWeek.THURSDAY, DayOfWeek.FRIDAY });
annotations.add(dow);
when(classSecurityLevel.filterAnnotations(TimeValidator.DaysOfWeek.class, EndpointConfig.AnnotationScope.CLASS)).thenReturn(List.of(dow));
timeConfig = validator.fromAnnotations(ep);
}
Aggregations