UnapprovedServicesAndRolePlugin extends AbstractFullstopPlugin { @Override public boolean supports(final CloudTrailEvent event) { final CloudTrailEventData cloudTrailEventData = event.getEventData(); final String eventSource = cloudTrailEventData.getEventSource(); return eventSource.equals(EVENT_SOURCE) && (unapprovedServicesAndRoleProperties.getEventNames().contains(cloudTrailEventData.getEventName())) && !isPerformedByAdmin(cloudTrailEventData) && (policyTemplatesProvider.getPolicyTemplateNames().contains(getRoleName(event))); } @Autowired  UnapprovedServicesAndRolePlugin(final PolicyProvider policyProvider,
                                           final ViolationSink violationSink,
                                           final PolicyTemplatesProvider policyTemplatesProvider,
                                           final UnapprovedServicesAndRoleProperties unapprovedServicesAndRoleProperties); @Override boolean supports(final CloudTrailEvent event); @Override void processEvent(final CloudTrailEvent event);  }
@Test public void testSupports() throws Exception { when(policyTemplatesProviderMock.getPolicyTemplateNames()).thenReturn( newArrayList( "mint-worker-b17-AppServerRole-W5WX8WewafwO2MEWZ")); final boolean result = plugin.supports(event); assertThat(result).isTrue(); verify(policyTemplatesProviderMock).getPolicyTemplateNames(); }
@Test public void testSupportsAdminEvent() throws Exception { assertThat(plugin.supports(adminEvent)).isFalse(); }
@Test public void testSupportsNewStyleAdminEvent() throws Exception { assertThat(plugin.supports(newAdminEvent)).isFalse(); }