1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.teststeps.assertions;
14
15 import java.util.Vector;
16
17 import com.eviware.soapui.config.RequestAssertionConfig;
18 import com.eviware.soapui.impl.wsdl.submit.WsdlMessageExchange;
19 import com.eviware.soapui.impl.wsdl.teststeps.WsdlMessageAssertion;
20 import com.eviware.soapui.model.iface.SubmitContext;
21 import com.eviware.soapui.model.testsuite.Assertable;
22 import com.eviware.soapui.model.testsuite.AssertionError;
23 import com.eviware.soapui.model.testsuite.AssertionException;
24 import com.eviware.soapui.model.testsuite.RequestAssertion;
25 import com.eviware.soapui.model.testsuite.ResponseAssertion;
26
27 /***
28 * Assertion for verifiying that WS-Security processing was ok
29 *
30 * @author Ole.Matzura
31 */
32
33 public class WSSStatusAssertion extends WsdlMessageAssertion implements ResponseAssertion, RequestAssertion
34 {
35 public static final String ID = "WSS Status Assertion";
36
37 /***
38 * Constructor for our assertion.
39 *
40 * @param assertionConfig
41 * @param modelItem
42 */
43 public WSSStatusAssertion( RequestAssertionConfig assertionConfig, Assertable modelItem )
44 {
45 super( assertionConfig, modelItem, false, false, false, true );
46 }
47
48 /***
49 * @see com.eviware.soapui.impl.wsdl.teststeps.WsdlMessageAssertion#internalAssertRequest(com.eviware.soapui.impl.wsdl.submit.WsdlMessageExchange,
50 * com.eviware.soapui.model.iface.SubmitContext)
51 */
52 protected String internalAssertRequest( WsdlMessageExchange messageExchange, SubmitContext context )
53 throws AssertionException
54 {
55 Vector result = messageExchange.getRequestWssResult();
56
57 if( result == null || result.isEmpty() )
58 throw new AssertionException( new AssertionError( "Missing WS-Security results" ));
59
60 for( int c = 0; c < result.size(); c++ )
61 {
62 if( result.get( c ) instanceof Exception )
63 {
64 throw new AssertionException( new AssertionError( "WS-Security validation failed: " + result.get( c )));
65 }
66 }
67
68 return "WS-Security status OK";
69 }
70
71 /***
72 * @see com.eviware.soapui.impl.wsdl.teststeps.WsdlMessageAssertion#internalAssertResponse(com.eviware.soapui.impl.wsdl.submit.WsdlMessageExchange,
73 * com.eviware.soapui.model.iface.SubmitContext)
74 */
75 protected String internalAssertResponse( WsdlMessageExchange messageExchange, SubmitContext context )
76 throws AssertionException
77 {
78 Vector result = messageExchange.getResponseWssResult();
79
80 if( result == null || result.isEmpty() )
81 throw new AssertionException( new AssertionError( "Missing WS-Security results" ));
82
83 for( int c = 0; c < result.size(); c++ )
84 {
85 if( result.get( c ) instanceof Exception )
86 {
87 throw new AssertionException( new AssertionError( "WS-Security validation failed: " + result.get( c )));
88 }
89 }
90
91 return "WS-Security status OK";
92 }
93 }