Skip to content

Commit 2d352e9

Browse files
committed
Added additional signature tests
1 parent ef7e8a0 commit 2d352e9

File tree

1 file changed

+46
-10
lines changed

1 file changed

+46
-10
lines changed

test/Client/SignatureTest.php

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ public function hmacSignatureProvider() {
5656
* @param $params
5757
* @param $secret
5858
*/
59-
public function testSignature($sig, $params, $secret)
59+
public function testSignature($algo, $sig, $params, $secret)
6060
{
6161
//a signature is created from a set of parameters and a secret
62-
$signature = new Signature($params, $secret, 'md5hash');
62+
$signature = new Signature($params, $secret, $algo);
6363

6464
//the parameters should ne be changed
6565
$this->assertEquals($params, $signature->getParams());
@@ -75,7 +75,7 @@ public function testSignature($sig, $params, $secret)
7575

7676
//signature can validate a string signature, or a set of params that includes a signature
7777
$this->assertTrue($signature->check($sig));
78-
if(isset($params['sig'])){
78+
if (isset($params['sig'])) {
7979
$this->assertTrue($signature->check($params));
8080
}
8181
}
@@ -84,7 +84,43 @@ public function signatures()
8484
{
8585
return array(
8686
//inbound
87-
array('d2e7b1dc968737c5998ad624e02f90b7', array(
87+
array('md5hash', 'd2e7b1dc968737c5998ad624e02f90b7', array(
88+
'message-timestamp' => '2013-11-21 15:27:30',
89+
'messageId' => '020000001B0FE827',
90+
'msisdn' => '14843472194',
91+
'text' => 'Test again',
92+
'timestamp' => '1385047698',
93+
'to' => '13239877404',
94+
'type' => 'text'
95+
),'my_secret_key_for_testing'),
96+
array('md5', 'DDEBD46008C2D4E93CCE578A332A52D5', array(
97+
'message-timestamp' => '2013-11-21 15:27:30',
98+
'messageId' => '020000001B0FE827',
99+
'msisdn' => '14843472194',
100+
'text' => 'Test again',
101+
'timestamp' => '1385047698',
102+
'to' => '13239877404',
103+
'type' => 'text'
104+
),'my_secret_key_for_testing'),
105+
array('sha1', '27D0D05C2876C7CB1720DBCDBA4D492E1E55C09A', array(
106+
'message-timestamp' => '2013-11-21 15:27:30',
107+
'messageId' => '020000001B0FE827',
108+
'msisdn' => '14843472194',
109+
'text' => 'Test again',
110+
'timestamp' => '1385047698',
111+
'to' => '13239877404',
112+
'type' => 'text'
113+
),'my_secret_key_for_testing'),
114+
array('sha256', 'DDB8397C2B90AAC7F3882D306475C9A5058C92322EEF43C92B298B6E0FC0D330', array(
115+
'message-timestamp' => '2013-11-21 15:27:30',
116+
'messageId' => '020000001B0FE827',
117+
'msisdn' => '14843472194',
118+
'text' => 'Test again',
119+
'timestamp' => '1385047698',
120+
'to' => '13239877404',
121+
'type' => 'text'
122+
),'my_secret_key_for_testing'),
123+
array('sha512', 'E0D3C650F8C9D1A5C174D10DDDBFB003E561F59B265616208B0487C5D819481CD3C311D59CF6165ECD1139622D5BA3A256C0D763AC4A9AD9144B5A426B94FE82', array(
88124
'message-timestamp' => '2013-11-21 15:27:30',
89125
'messageId' => '020000001B0FE827',
90126
'msisdn' => '14843472194',
@@ -94,7 +130,7 @@ public function signatures()
94130
'type' => 'text'
95131
),'my_secret_key_for_testing'),
96132
//is sig is passed, it should be ignored
97-
array('d2e7b1dc968737c5998ad624e02f90b7', array(
133+
array('md5hash', 'd2e7b1dc968737c5998ad624e02f90b7', array(
98134
'message-timestamp' => '2013-11-21 15:27:30',
99135
'messageId' => '020000001B0FE827',
100136
'msisdn' => '14843472194',
@@ -105,7 +141,7 @@ public function signatures()
105141
'sig' => 'd2e7b1dc968737c5998ad624e02f90b7'
106142
), 'my_secret_key_for_testing'),
107143
//is sig is passed, it should be ignored
108-
array('f0bfad43bd90cf1ea1f1525c18ba4dab', array(
144+
array('md5hash', 'f0bfad43bd90cf1ea1f1525c18ba4dab', array(
109145
'message-timestamp' => '2013-11-21 17:31:42',
110146
'messageId' => '030000002A264B8B',
111147
'msisdn' => '14843472194',
@@ -115,7 +151,7 @@ public function signatures()
115151
'type' => 'text',
116152
'sig' => 'f0bfad43bd90cf1ea1f1525c18ba4dab'
117153
), ''),
118-
array('83c052a82906ec7c116e16f6d92f7eee', array(
154+
array('md5hash', '83c052a82906ec7c116e16f6d92f7eee', array(
119155
'message-timestamp' => '2013-11-21 17:37:31',
120156
'messageId' => '030000002A267DBB',
121157
'msisdn' => '14843472194',
@@ -126,7 +162,7 @@ public function signatures()
126162
'sig' => '83c052a82906ec7c116e16f6d92f7eee'
127163
), 'my_secret_key_for_testing'),
128164

129-
array('ff933bf31c79ab3fc6a38d100191c48f', array(
165+
array('md5hash', 'ff933bf31c79ab3fc6a38d100191c48f', array(
130166
'keyword' => 'TESTINGS',
131167
'message-timestamp' => '2017-04-04 23:05:22',
132168
'messageId' => '0C00000027217D5B',
@@ -139,7 +175,7 @@ public function signatures()
139175
'type' => 'text',
140176
), 'my_secret_key_for_testing'),
141177

142-
array('e06d9763e3fd0b9c31beb5fc2fcb011c', array(
178+
array('md5hash', 'e06d9763e3fd0b9c31beb5fc2fcb011c', array(
143179
'keyword' => 'TEST',
144180
'message-timestamp' => '2017-04-04 22:57:47',
145181
'messageId' => '0B00000042AC53BD',
@@ -153,7 +189,7 @@ public function signatures()
153189
), 'my_secret_key_for_testing'),
154190

155191
//outbound
156-
array('17f5e3b22f778ec73464c01d180e9d0f', array(
192+
array('md5hash', '17f5e3b22f778ec73464c01d180e9d0f', array(
157193
'api_key' => 'not_a_key',
158194
'from' => '12192259404',
159195
'text' => '14843472194',

0 commit comments

Comments
 (0)