Skip to content

Commit 6e45a85

Browse files
committed
+1 test
1 parent c3a7393 commit 6e45a85

File tree

3 files changed

+194
-11
lines changed

3 files changed

+194
-11
lines changed

ext/soap/tests/wss/T07.phpt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
SOAP CLIENT WSS: SOAP 1.1 / WSS 1.0 SHA1 with user defined function echo
2+
SOAP CLIENT WSS: SOAP 1.1 / WSS 1.0 SHA1 with user defined function and without binsectoken echo
33
--EXTENSIONS--
44
soap
55
--INI--
@@ -16,7 +16,6 @@ $client = new LocalSoapClient(__DIR__.DIRECTORY_SEPARATOR."wss-test.wsdl");
1616

1717
$client->__setWSS(array(
1818
"random_id" => false,
19-
"x509_binsectoken" => "TEST CERTIFICATE",
2019
"signfunc" => "__wss_test_signfunc"
2120
));
2221

@@ -30,7 +29,6 @@ $client->testFunction(array(
3029
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://localhost/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
3130
%w<SOAP-ENV:Header>
3231
%w<wsse:Security SOAP-ENV:mustUnderstand="1">
33-
%w<wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" wsu:Id="TokenID-1">VEVTVCBDRVJUSUZJQ0FURQ==</wsse:BinarySecurityToken>
3432
%w<ds:Signature>
3533
%w<ds:SignedInfo>
3634
%w<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
@@ -44,11 +42,6 @@ $client->testFunction(array(
4442
%w</ds:Reference>
4543
%w</ds:SignedInfo>
4644
%w<ds:SignatureValue>VEVTVCBTSUdOQVRVUkU=</ds:SignatureValue>
47-
%w<ds:KeyInfo>
48-
%w<wsse:SecurityTokenReference>
49-
%w<wsse:Reference URI="#TokenID-1" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
50-
%w</wsse:SecurityTokenReference>
51-
%w</ds:KeyInfo>
5245
%w</ds:Signature>
5346
%w</wsse:Security>
5447
%w</SOAP-ENV:Header>

ext/soap/tests/wss/T08.phpt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
SOAP CLIENT WSS: SOAP 1.1 / WSS 1.0 SHA1 with user defined class echo
2+
SOAP CLIENT WSS: SOAP 1.1 / WSS 1.0 SHA1 with user defined class and invalid signature echo
33
--EXTENSIONS--
44
soap
55
--INI--
@@ -10,7 +10,7 @@ include __DIR__.DIRECTORY_SEPARATOR."wss-test.inc";
1010

1111
class __wssTestSignClass {
1212
public function sign($data) {
13-
return "TEST SIGNATURE";
13+
return null;
1414
}
1515
}
1616

@@ -30,6 +30,7 @@ $client->testFunction(array(
3030
));
3131
?>
3232
--EXPECTF--
33+
Warning: SoapClient::__call(): "signfunc" should return a string, null given in %s on line 21
3334
<?xml version="1.0" encoding="UTF-8"?>
3435
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://localhost/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
3536
%w<SOAP-ENV:Header>
@@ -47,7 +48,7 @@ $client->testFunction(array(
4748
%w<ds:DigestValue>OaQiUDsEKrCjytgTUqF4CLsB9jo=</ds:DigestValue>
4849
%w</ds:Reference>
4950
%w</ds:SignedInfo>
50-
%w<ds:SignatureValue>VEVTVCBTSUdOQVRVUkU=</ds:SignatureValue>
51+
%w<ds:SignatureValue/>
5152
%w<ds:KeyInfo>
5253
%w<wsse:SecurityTokenReference>
5354
%w<wsse:Reference URI="#TokenID-1" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>

ext/soap/tests/wss/T09.phpt

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
--TEST--
2+
SOAP CLIENT WSS: Type and value error handling
3+
--EXTENSIONS--
4+
soap
5+
--INI--
6+
soap.wsdl_cache_enabled=0
7+
--FILE--
8+
<?php
9+
include __DIR__.DIRECTORY_SEPARATOR."wss-test.inc";
10+
11+
$client = new LocalSoapClient(__DIR__.DIRECTORY_SEPARATOR."wss-test.wsdl");
12+
13+
try {
14+
$client->__setWSS(false);
15+
} catch (TypeError $e) {
16+
var_dump($e->getMessage());
17+
}
18+
19+
try {
20+
$client->__setWSS(array(
21+
"signfunc" => "__fail_me"
22+
));
23+
} catch (TypeError $e) {
24+
var_dump($e->getMessage());
25+
}
26+
27+
try {
28+
$client->__setWSS(array(
29+
"signfunc" => function($data) {
30+
return $data;
31+
},
32+
"x509_binsectoken" => false
33+
));
34+
} catch (TypeError $e) {
35+
var_dump($e->getMessage());
36+
}
37+
38+
try {
39+
$client->__setWSS(array(
40+
"signfunc" => function($data) {
41+
return $data;
42+
},
43+
"x509_binsectoken" => null,
44+
"digest_method" => false,
45+
));
46+
} catch (TypeError $e) {
47+
var_dump($e->getMessage());
48+
}
49+
50+
try {
51+
$client->__setWSS(array(
52+
"signfunc" => function($data) {
53+
return $data;
54+
},
55+
"x509_binsectoken" => null,
56+
"digest_method" => 999,
57+
));
58+
} catch (ValueError $e) {
59+
var_dump($e->getMessage());
60+
}
61+
62+
try {
63+
$client->__setWSS(array(
64+
"signfunc" => function($data) {
65+
return $data;
66+
},
67+
"x509_binsectoken" => null,
68+
"digest_method" => SOAP_WSS_DIGEST_METHOD_SHA256,
69+
"add_timestamp" => null
70+
));
71+
} catch (TypeError $e) {
72+
var_dump($e->getMessage());
73+
}
74+
75+
try {
76+
$client->__setWSS(array(
77+
"signfunc" => function($data) {
78+
return $data;
79+
},
80+
"x509_binsectoken" => null,
81+
"digest_method" => SOAP_WSS_DIGEST_METHOD_SHA256,
82+
"add_timestamp" => true,
83+
"timestamp_expires" => null
84+
));
85+
} catch (TypeError $e) {
86+
var_dump($e->getMessage());
87+
}
88+
89+
try {
90+
$client->__setWSS(array(
91+
"signfunc" => function($data) {
92+
return $data;
93+
},
94+
"x509_binsectoken" => null,
95+
"digest_method" => SOAP_WSS_DIGEST_METHOD_SHA256,
96+
"add_timestamp" => true,
97+
"timestamp_expires" => -1
98+
));
99+
} catch (ValueError $e) {
100+
var_dump($e->getMessage());
101+
}
102+
103+
try {
104+
$client->__setWSS(array(
105+
"signfunc" => function($data) {
106+
return $data;
107+
},
108+
"x509_binsectoken" => null,
109+
"digest_method" => SOAP_WSS_DIGEST_METHOD_SHA256,
110+
"add_timestamp" => true,
111+
"timestamp_expires" => 120,
112+
"random_id" => null
113+
));
114+
} catch (TypeError $e) {
115+
var_dump($e->getMessage());
116+
}
117+
118+
try {
119+
$client->__setWSS(array(
120+
"signfunc" => function($data) {
121+
return $data;
122+
},
123+
"x509_binsectoken" => null,
124+
"digest_method" => SOAP_WSS_DIGEST_METHOD_SHA256,
125+
"add_timestamp" => true,
126+
"timestamp_expires" => 120,
127+
"random_id" => true
128+
));
129+
} catch (TypeError $e) {
130+
var_dump($e->getMessage());
131+
}
132+
133+
try {
134+
$client->__setWSS(array(
135+
"signfunc" => function($data) {
136+
return $data;
137+
},
138+
"x509_binsectoken" => null,
139+
"digest_method" => SOAP_WSS_DIGEST_METHOD_SHA256,
140+
"add_timestamp" => true,
141+
"timestamp_expires" => 120,
142+
"random_id" => true,
143+
"wss_version" => null
144+
));
145+
} catch (TypeError $e) {
146+
var_dump($e->getMessage());
147+
}
148+
149+
try {
150+
$client->__setWSS(array(
151+
"signfunc" => function($data) {
152+
return $data;
153+
},
154+
"x509_binsectoken" => null,
155+
"digest_method" => SOAP_WSS_DIGEST_METHOD_SHA256,
156+
"add_timestamp" => true,
157+
"timestamp_expires" => 120,
158+
"random_id" => true,
159+
"wss_version" => 999
160+
));
161+
} catch (ValueError $e) {
162+
var_dump($e->getMessage());
163+
}
164+
165+
var_dump($client->__setWSS(array(
166+
"signfunc" => function($data) {
167+
return $data;
168+
},
169+
"x509_binsectoken" => null,
170+
"digest_method" => SOAP_WSS_DIGEST_METHOD_SHA256,
171+
"add_timestamp" => true,
172+
"timestamp_expires" => 120,
173+
"random_id" => true,
174+
"wss_version" => SOAP_WSS_VERSION_1_1
175+
)));
176+
?>
177+
--EXPECTF--
178+
string(81) "SoapClient::__setWSS(): Argument #1 ($options) must be of type ?array, bool given"
179+
string(112) "__setWSS(): "signfunc" must be a valid callback or null, function "__fail_me" not found or invalid function name"
180+
string(73) "__setWSS(): "x509_binsectoken" must be of type string or null, bool given"
181+
string(59) "__setWSS(): "digest_method" must be of type int, bool given"
182+
string(52) "__setWSS(): invalid "digest_method" value, 999 given"
183+
string(60) "__setWSS(): "add_timestamp" must be of type bool, null given"
184+
string(63) "__setWSS(): "timestamp_expires" must be of type int, null given"
185+
string(55) "__setWSS(): invalid "timestamp_expires" value, -1 given"
186+
string(56) "__setWSS(): "random_id" must be of type bool, null given"
187+
string(57) "__setWSS(): "wss_version" must be of type int, null given"
188+
string(50) "__setWSS(): invalid "wss_version" value, 999 given"
189+
bool(true)

0 commit comments

Comments
 (0)