Search in sources :

Example 21 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext in project spring-security by spring-projects.

the class DelegatingAuthenticationEntryPointContextTests method testDefaultAEP.

@Test
@DirtiesContext
public void testDefaultAEP() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRemoteAddr("192.168.1.10");
    daep.commence(request, null, null);
    verify(defaultAEP).commence(request, null, null);
    verify(firstAEP, never()).commence(any(HttpServletRequest.class), any(HttpServletResponse.class), any(AuthenticationException.class));
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) AuthenticationException(org.springframework.security.core.AuthenticationException) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) HttpServletResponse(javax.servlet.http.HttpServletResponse) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 22 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext in project cas by apereo.

the class WsFederationHelperTests method verifyValidateSignatureBadKey.

@Test
@DirtiesContext
public void verifyValidateSignatureBadKey() throws Exception {
    final List<Credential> signingWallet = new ArrayList<>();
    final WsFederationConfiguration cfg = new WsFederationConfiguration();
    cfg.setSigningCertificateResources(ctx.getResource("classpath:bad-signing.crt"));
    signingWallet.addAll(cfg.getSigningCertificates());
    final String wresult = testTokens.get(GOOD_TOKEN);
    final Assertion assertion = wsFederationHelper.parseTokenFromString(wresult, wsFedConfig);
    wsFedConfig.getSigningCertificates().clear();
    wsFedConfig.getSigningCertificates().addAll(signingWallet);
    final boolean result = wsFederationHelper.validateSignature(assertion, wsFedConfig);
    assertFalse("testValidateSignatureModifiedKey() - False", result);
}
Also used : Credential(org.opensaml.security.credential.Credential) WsFederationCredential(org.apereo.cas.support.wsfederation.authentication.principal.WsFederationCredential) ArrayList(java.util.ArrayList) Assertion(org.opensaml.saml.saml1.core.Assertion) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 23 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext in project opennms by OpenNMS.

the class NamespaceHandlerTest method testRegistrationListenerBeanDefinition.

@Test
@DirtiesContext
public void testRegistrationListenerBeanDefinition() {
    assertNotNull(m_helloListListener);
    MyProvider myProvider = new MyProvider();
    int expected = m_helloListListener.getTotalProviders() + 1;
    Registration registration = m_defaultServiceRegistry.register(myProvider, Hello.class);
    assertEquals(expected, m_helloListListener.getTotalProviders());
    expected = m_helloListListener.getTotalProviders() - 1;
    registration.unregister();
    assertEquals(expected, m_helloListListener.getTotalProviders());
}
Also used : MyProvider(org.opennms.core.soa.support.MyProvider) Registration(org.opennms.core.soa.Registration) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 24 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext in project opennms by OpenNMS.

the class TrapHandlerITCase method testV2EnterpriseIdAndGenericAndSpecificAndMatchWithVarbinds.

@Test
@DirtiesContext
public void testV2EnterpriseIdAndGenericAndSpecificAndMatchWithVarbinds() throws Exception {
    SnmpValueFactory valueFactory = SnmpUtils.getValueFactory();
    LinkedHashMap<String, SnmpValue> varbinds = new LinkedHashMap<String, SnmpValue>();
    varbinds.put(".1.3.6.1.4.1.11.2.14.11.1.7.2.1.4.2404", valueFactory.getInt32(3));
    varbinds.put(".1.3.6.1.4.1.11.2.14.11.1.7.2.1.5.2404", valueFactory.getInt32(2));
    varbinds.put(".1.3.6.1.4.1.11.2.14.11.1.7.2.1.6.2404", valueFactory.getInt32(5));
    varbinds.put(".1.3.6.1.4.1.11.2.14.11.1.7.3.0.2404", valueFactory.getOctetString("http://a.b.c.d/cgi/fDetail?index=2404".getBytes()));
    anticipateAndSend(false, true, "uei.opennms.org/vendor/HP/traps/hpicfFaultFinderTrap", "v2c", ".1.3.6.1.4.1.11.2.14.12.1", 6, 5, varbinds);
}
Also used : SnmpValueFactory(org.opennms.netmgt.snmp.SnmpValueFactory) SnmpValue(org.opennms.netmgt.snmp.SnmpValue) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 25 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext in project opennms by OpenNMS.

the class TrapHandlerITCase method testV1TrapOIDWildCardMatch.

@Test
@DirtiesContext
public void testV1TrapOIDWildCardMatch() throws Exception {
    SnmpValueFactory valueFactory = SnmpUtils.getValueFactory();
    LinkedHashMap<String, SnmpValue> varbinds = new LinkedHashMap<String, SnmpValue>();
    varbinds.put(".1.3.6.1.4.1.32473.42.42.42", valueFactory.getInt32(42));
    anticipateAndSend(false, true, "uei.opennms.org/IANA/Example/traps/exampleEnterpriseTrap", "v1", ".1.3.6.1.4.1.32473.42", 6, 5, varbinds);
}
Also used : SnmpValueFactory(org.opennms.netmgt.snmp.SnmpValueFactory) SnmpValue(org.opennms.netmgt.snmp.SnmpValue) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Aggregations

DirtiesContext (org.springframework.test.annotation.DirtiesContext)78 Test (org.junit.Test)76 Exchange (org.apache.camel.Exchange)20 Event (org.opennms.netmgt.xml.event.Event)19 Processor (org.apache.camel.Processor)11 DroolsCorrelationEngine (org.opennms.netmgt.correlation.drools.DroolsCorrelationEngine)10 IOException (java.io.IOException)9 NCSComponent (org.opennms.netmgt.model.ncs.NCSComponent)9 Ignore (org.junit.Ignore)7 LinkedHashMap (java.util.LinkedHashMap)5 CommonBindyTest (org.apache.camel.dataformat.bindy.CommonBindyTest)5 FactHandle (org.kie.api.runtime.rule.FactHandle)5 SnmpValue (org.opennms.netmgt.snmp.SnmpValue)5 SnmpValueFactory (org.opennms.netmgt.snmp.SnmpValueFactory)5 BigDecimal (java.math.BigDecimal)3 Registration (org.opennms.core.soa.Registration)3 MyProvider (org.opennms.core.soa.support.MyProvider)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2