Running the sample test cases

You can use sample web application or the command line to test the Sample application on the deployed SOA Policy Gateway Basic Runtime Sample. Six command line test variations can be run on the sample application.

To deploy the Basic Sample Runtime, see Deploying the basic runtime sample pattern.

Running the sample web application test case

To run the web application test case:
  1. Find the hostname of the deployed WSRR environment by opening the deployed Virtual System Instance. To find the hostname, expand the Virtual machines section and select the virtual machine for the WSRR Standalone Server to see the virtual machine details. In the Hardware and network section, the hostname is the Network interface 0 value.
  2. Open the URL in a Web browser: http://<wssrHostName>:9080/SoaPolicyTester
  3. The following options are available:
    • Standard Request - Sends a findInventory request to the store service. The context ID is Silver. The consumer ID is CEO. A successful result displays the text Part: SKU10 Price: 401.73.
    • Routing Policy Test - Same as Standard Request, but with Context ID of Gold. The request is routed to an alternate endpoint running the service. A successful result returns Part: GOLDSKU10 Price: 401.73.
    • Validation Policy Test - Sends a request with an invalid payload. The validation policy requires DataPower® to validate the request and reject those messages that are invalid. A successful result is a response message from DataPower "Internal Error (from client)".
    • REST Gold - Send request to the SKU RESTful service with Consumer ID CEO and Context ID Gold. Gold requests are subjected to a policy permitting only 5 messages in 90 seconds. A successful request displays the result Part: SKU33 Price: 136.43.
    • REST Silver - Same as Rest GOLD, but with Silver Context ID. Silver requests are allowed a separate 3 requests in 90 seconds. A successful request displays the result Part: SKU33 Price: 136.43.
    • User ID - The User ID option has two possible values; Full Content or Redacted Content. Each option results in requests originating from different users. The sample utilises an XACML policy, which allows only Managers to see the price. The value of Price in the response message is redacted unless Full Content is selected. A successful result for requests when Redacted Content is selected contains Price: 0.0. The RESTful service does not support redaction. The user selected has no effect.
  4. Open the WSRR console and explore the service and policies. For more information, see Connecting to WSRR - Business Space.

The sample can also be exercised by using the command line. This is the only way to send traffic that uses the Anonymous SLA

Demonstrating XACML Permit/Deny with the Redaction scenario by using the command line

The following request XML can be sent to the DataPower StoreAddLTPA Service:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:stor="http://company.ibm.com/store">
  <soapenv:Header>
    <store:ConsumerIdentifier xmlns:store="http://store.com">CEO</store:ConsumerIdentifier>
    <store:ContextIdentifier xmlns:store="http://store.com">silver</store:ContextIdentifier>
  </soapenv:Header>
  <soapenv:Body>
  <stor:findInventory>
    <findInventoryReq>
      <sku>SKU10</sku>
    </findInventoryReq>
  </stor:findInventory>
  </soapenv:Body>
</soapenv:Envelope>
Assuming that the example request XML is contained in a file named silver.xml, enter the following curl command:
curl -k --data-bin @./silver.xml -H "Content-Type: text/xml" 
-u ConsumerX:passw0rd http://<yourDataPowerHostName>:62005/Store/Store
In this example, ConsumerX is a Manager so the full price information is visible in the response:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<KD4NS:KD4SoapHeaderV2
xmlns:KD4NS="http://www.ibm.com/KD4Soap">AFIAAgAkZmExODgzNTQtY2Q1ZC0z
YjU0LWEyMzItZGM3MmEzNWY0MTAzACRmYWVjYjA1Mi1jMWUxLTMyODEtOWY3Ni0wY2IxN
mRhMDc4MjkAAw==</KD4NS:KD4SoapHeaderV2>
</soapenv:Header>
<soapenv:Body>
  <b:findInventoryResponse xmlns:a="http://company.ibm.com/" 
     xmlns:b="http://company.ibm.com/store">
  <findInventoryRes>
<sku>SKU10</sku>
<price>461.73</price>
<inventory>460</inventory>
<msrp>923.46</msrp>
<supplierID>IBM</supplierID>
</findInventoryRes>
</b:findInventoryResponse>
</soapenv:Body></soapenv:Envelope>

Running the Redaction scenario by using the command line

ConsumerA is not a manager so sees a different response. Enter the curl command:
curl -k --data-bin @./silver.xml -H "Content-Type: text/xml" 
-u ConsumerA:passw0rd http://<yourDataPowerHostName>:62005/Store/Store
Notice that the response has the price redacted. The price is displayed as 0.0:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header><KD4NS:KD4SoapHeaderV2
xmlns:KD4NS="http://www.ibm.com/KD4Soap">AFIAAgAkZmExODgzNTQtY2Q1ZC0zYjU0L
WEyMzItZGM3MmEzNWY0MTAzACRmYWVjYjA1Mi1jMWUxLTMyODEtOWY3Ni0wY2IxNm
RhMDc4MjkAAw==</KD4NS:KD4SoapHeaderV2>
</soapenv:Header>
<soapenv:Body>
<b:findInventoryResponse xmlns:a="http://company.ibm.com/"
xmlns:b="http://company.ibm.com/store">
<findInventoryRes>
<sku>SKU10</sku>
<price>0.0</price>
<inventory>460</inventory>
<msrp>923.46</msrp>
<supplierID>IBM</supplierID>
</findInventoryRes>
</b:findInventoryResponse>
</soapenv:Body></soapenv:Envelope>

Testing the routing policy by using the command line

For the routing policy attached to the gold SLA to be enforced, the context ID and consumer ID must be matched. In this case, the SLA for Gold Customers has the context ID of Gold, and the consuming service version has the consumer ID of CEO. Here is the content of a sample request (you can see that the context ID and consumer ID match as required):

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:stor="http://company.ibm.com/store">
<soapenv:Header>
  <store:ConsumerIdentifier xmlns:store="http://store.com">CEO</store:ConsumerIdentifier>
  <store:ContextIdentifier xmlns:store="http://store.com">Gold</store:ContextIdentifier>
</soapenv:Header><soapenv:Body>
<stor:findInventory><findInventoryReq>
  <sku>SKU10</sku>
  </findInventoryReq>
</stor:findInventory>
</soapenv:Body></soapenv:Envelope>
Assuming that the example request XML is contained in a file named gold.xml, enter the following curl command:
curl -k --data-bin @./gold.xml -H "Content-Type: text/xml" 
-u ConsumerX:passw0rd http://<yourDataPowerHostName>:62005/Store/Store
The response is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
  <KD4NS:KD4SoapHeaderV2
  xmlns:KD4NS="http://www.ibm.com/KD4Soap">AFIAAgAkZmExODgzNTQtY2Q1ZC0zYjU0L
  WEyMzItZGM3MmEzNWY0MTAzACRmYWVjYjA1Mi1jMWUxLTMyODEtOWY3Ni0wY2IxNm
  RhMDc4MjkAAw==</KD4NS:KD4SoapHeaderV2>
</soapenv:Header><soapenv:Body>
<b:findInventoryResponse xmlns:a="http://company.ibm.com/"
xmlns:b="http://company.ibm.com/store">
<findInventoryRes>
  <sku>GOLDSKU10</sku>
  <price>461.73</price>
  <inventory>460</inventory>
  <msrp>923.46</msrp>
  <supplierID>IBM</supplierID>
</findInventoryRes></b:findInventoryResponse>
</soapenv:Body>
</soapenv:Envelope>
Note the return response has a GOLDSKU for the SKU value, indicating that the gold endpoint was used.

Testing the validation of the schema by using the command line

The validation policy checks the schema of the request against the Store.wsdl and its associated Company.xsd.
The following XML, badvalid.xml, shows a request that is invalid because the body contains an element named <skubad> when it should be <sku>:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:stor="http://company.ibm.com/store">
<soapenv:Header>
<store:ConsumerIdentifier xmlns:store="http://store.com">CEO</store:ConsumerIdentifier>
<store:ContextIdentifier xmlns:store="http://store.com">silver</store:ContextIdentifier>
</soapenv:Header>
<soapenv:Body>
<stor:findInventory>
<findInventoryReq>
<skubad>SKU10</skubad>
</findInventoryReq>
</stor:findInventory>
</soapenv:Body></soapenv:Envelope>

If you enter the following curl request:
curl -k --data-bin @./badvalid.xml -H "Content-Type: text/xml" 
-u ConsumerX:passw0rd
http://<yourDataPowerHostName>:62005/Store/Store
The following error is displayed:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<env:Fault><faultcode>env:Client</faultcode>
<faultstring>Internal Error (from client)</faultstring>
</env:Fault>
</env:Body>
</env:Envelope>

Testing rejection in the mediation policy by using the command line

One of the mediation policies included in the sample tests rejection after the message count runs 5 times in 90 seconds. Run the following command 6 times:
curl -k --data-bin @./silver.xml -H "Content-Type: text/xml" -u ConsumerX:passw0rd
http://<yourDataPowerHostName>:62005/Store/Store
The sample request is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<KD4NS:KD4SoapHeaderV2
xmlns:KD4NS="http://www.ibm.com/KD4Soap">AFIAAgAkZmExODgzNTQtY2Q1ZC0z
YjU0LWEyMzItZGM3MmEzNWY0MTAzACRmYWVjYjA1Mi1jMWUxLTMyODEtOWY3Ni0wY2IxN
mRhMDc4MjkAAw==</KD4NS:KD4SoapHeaderV2>
</soapenv:Header>
<soapenv:Body>
<b:findInventoryResponse xmlns:a="http://company.ibm.com/"
xmlns:b="http://company.ibm.com/store">
<findInventoryRes>
In this case, ConsumerX is a Manager, therefore, the full price information is displayed as for the first five runs:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<KD4NS:KD4SoapHeaderV2
xmlns:KD4NS="http://www.ibm.com/KD4Soap">AFIAAgAkZmExODgzNTQtY2Q1ZC0z
YjU0LWEyMzItZGM3MmEzNWY0MTAzACRmYWVjYjA1Mi1jMWUxLTMyODEtOWY3Ni0wY2IxN
mRhMDc4MjkAAw==</KD4NS:KD4SoapHeaderV2>
</soapenv:Header>
<soapenv:Body>
<b:findInventoryResponse xmlns:a="http://company.ibm.com/"
xmlns:b="http://company.ibm.com/store">
<findInventoryRes>
<sku>SKU10</sku>
<price>461.73</price>
<inventory>460</inventory>
<msrp>923.46</msrp>
<supplierID>IBM</supplierID>
</findInventoryRes></b:findInventoryResponse>
</soapenv:Body>
</soapenv:Envelope>
On the sixth run the following error occurs:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<env:Fault>
<faultcode>env:Client</faultcode>
<faultstring>Rejected (from client)</faultstring>
</env:Fault>
</env:Body>
</env:Envelope>
Note: You might see this error sooner if you run other tests within the 90-second interval.

Testing notification in the mediation policy by using the command line

The notify policy is attached to the anonymous SLA. This is enforced when a request comes in from a consumer who does not have an SLA in place. In this sample, the only consumer that has SLAs in place is CEO, so a request containing the consumer ID set to anything else causes the policy on the anonymous SLA to be enforced. In this case ConsumerX is a Manager, so the full price information is displayed:

To test this functionality by using the command line, create a file named anon.xml that contains the following xml:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:stor="http://company.ibm.com/store">
<soapenv:Header>
  <store:ConsumerIdentifier xmlns:store="http://store.com">ABC</store:ConsumerIdentifier>
  <store:ContextIdentifier xmlns:store="http://store.com">Gold</store:ContextIdentifier>
</soapenv:Header><soapenv:Body>
<stor:findInventory><findInventoryReq>
  <sku>SKU10</sku>
  </findInventoryReq>
</stor:findInventory>
</soapenv:Body></soapenv:Envelope>
Then enter the following command:
curl -k --data-bin @./anon.xml -H "Content-Type: text/xml" 
-u ConsumerX:passw0rd http://<yourDataPowerHostName>:62005/Store/Store
The following message is output in the default log of the domain:
Notify action triggered ('operation_38_2_sla1-1-filter_1-notify') from source policy (
   'LogEveryTime_287d0790-83d9-11e1-a255-9187e20cddb0_05aec6ec-3674-4165-85de-a0f7be48a938'
Note: Logging must be set to notice to see this message. If it is not, click the Troubleshooting icon in the DataPower Web Console. In the Logging section, change the Log level value to notice and click Set Log Level. To find the log, return to the Control Panel and click the View Logs icon.

Testing the RESTful service by using the command line

You can also access the RESTful interface from the command line by using curl. As with the web client, a ContextID of Gold permits 5 messages per 90 seconds and Silver only 2 messages.

To test this functionality by using the command line, create a file named restRequest.xml that contains the following xml:

<?xml version="1.0" encoding="UTF-8"?>
<a:WarehouseSKUPost xmlns:a="http://company.ibm.com/">
   <postRequest>
      <sku>SKU33</sku>
      <purchaseCost>136.43</purchaseCost>
      <inventory>429</inventory>
      <msrp>272.86</msrp>
      <returns>0</returns>
   </postRequest>
</a:WarehouseSKUPost>

Then enter the following command to test with contextID Gold:

curl -k --data-bin @./restRequest.xml -H "Content-Type: text/xml" -H "consumerID:CEO" -H "contextID:Gold"  http://<yourDataPowerHostName>:62006/WarehouseSKU

To test with the silver contextID use the same command, but replace Gold with Silver.

A successful response is:

<?xml version="1.0" encoding="UTF-8"?>
<a:WarehouseSKUGet xmlns:a="http://company.ibm.com/">
<getRequest>
<sku>SKU33</sku>
<purchaseCost>136.43</purchaseCost>
<inventory>429</inventory>
<msrp>272.86</msrp>
<returns>0</returns>
<supplierID>ABB</supplierID>
<purchaseID/>
</getRequest>
</a:WarehouseSKUGet>
After the threshold has been breached you receive the following message:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><env:Fault><faultcode>env:Client</faultcode><faultstring>Rejected (from client)</faultstring></env:Fault></env:Body></env:Envelope>

To exercise the anonymous SLA for the RESTful service, which simply has a notify policy attached, use any ContextID and ConsumerID other than those registered. The notify appears in the DataPower log as described earlier for the Web Services example.


Concept Concept

Feedback

Timestamp icon Last updated: Thursday, 3 July 2014
http://publib.boulder.ibm.com/infocenter/prodconn/v1r0m0/topic/com.ibm.scenarios.soawdpwsrr25.doc/topics/csoa2_sample_run.htm