Forum Discussion

arutz's avatar
arutz
New Contributor
10 years ago

changing preferences from groovy script / "connection failed"-assertion

Hello everyone,

 

I am having trouble with setting up the certificate / store that is used when sending a SOAP-Request to a HTTPS endpoint that requires SSL-client authentification. I have no problem setting up the preferences to call the endpoint with a valid certificate, but i would like to send a second request with an invalid certificate to demonstrate that the connection fails. So maybe someone can answer me these following questions:

 

  • Is there a way to set up the used certificate for single SOAP-Requests? I was thinking something along the lines of this: http://forum.soapui.org/viewtopic.php?f=1&t=25294 but for changing preferences -> SSL settings -> Keystore / Password.
  • Is there a way to assert that the connection gets refused in the case of an invalid certificate? I.e. an assertion for a SSL-Handshake exception?

I am using Ready! API 1.2.1.

 

Kind regards 

 

Achim

  • Just for those with a similar problem:

    • Changing the SSL-Config via Groovy-Script:
    import com.eviware.soapui.settings.SSLSettings
    import com.eviware.soapui.SoapUI
    SoapUI.settings.setString( SSLSettings.KEYSTORE, keystore_location )
    SoapUI.settings.setString( SSLSettings.KEYSTORE_PASSWORD, keystore_password )
    •  Asserting the connection fails with a SSL Handshake Exception (also via Groovy-Script):
    try {
        def connection_fails = this.context.getCurrentStep();
        def retrieval = connection_fails.getTestCase().getTestStepByName("test_step_that_should_fail");
        def com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStepResult runner = retrieval.run(testRunner,context);
        log.info(runner.getStatus())
        assert(!runner.hasResponse() && runner.messages[0].indexOf("SSLHandshakeException",0) != -1)
    } catch (Exception e) {
    	log.info(e)
    	log.error("error: ", e)
    }

     

  • arutz's avatar
    arutz
    New Contributor

    Just for those with a similar problem:

    • Changing the SSL-Config via Groovy-Script:
    import com.eviware.soapui.settings.SSLSettings
    import com.eviware.soapui.SoapUI
    SoapUI.settings.setString( SSLSettings.KEYSTORE, keystore_location )
    SoapUI.settings.setString( SSLSettings.KEYSTORE_PASSWORD, keystore_password )
    •  Asserting the connection fails with a SSL Handshake Exception (also via Groovy-Script):
    try {
        def connection_fails = this.context.getCurrentStep();
        def retrieval = connection_fails.getTestCase().getTestStepByName("test_step_that_should_fail");
        def com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStepResult runner = retrieval.run(testRunner,context);
        log.info(runner.getStatus())
        assert(!runner.hasResponse() && runner.messages[0].indexOf("SSLHandshakeException",0) != -1)
    } catch (Exception e) {
    	log.info(e)
    	log.error("error: ", e)
    }