@@ -132,6 +132,55 @@ public function it_should_call_our_callback_if_the_request_is_valid()
132
132
});
133
133
}
134
134
135
+ /**
136
+ * @test
137
+ */
138
+ public function it_should_prefix_the_configuration_keys_if_a_prefix_is_supplied ()
139
+ {
140
+ $ id = (string ) Uuid::uuid4 ();
141
+
142
+ $ this ->configurations ->shouldReceive ('get ' )
143
+ ->with ('prefix-signed-requests.headers.signature ' )
144
+ ->andReturn ('signature ' );
145
+
146
+ $ this ->configurations ->shouldReceive ('get ' )
147
+ ->with ('prefix-signed-requests.headers.algorithm ' )
148
+ ->andReturn ('algorithm ' );
149
+
150
+ $ this ->configurations ->shouldReceive ('get ' )
151
+ ->with ('prefix-signed-requests.key ' )
152
+ ->andReturn ('key ' );
153
+
154
+ $ this ->configurations ->shouldReceive ('get ' )
155
+ ->with ('prefix-signed-requests.request-replay.allow ' )
156
+ ->andReturn (true );
157
+
158
+ $ this ->configurations ->shouldReceive ('get ' )
159
+ ->with ('prefix-signed-requests.cache-prefix ' )
160
+ ->andReturn ('prefix ' );
161
+ $ this ->configurations ->shouldReceive ('get ' )
162
+ ->with ('prefix-signed-requests.request-replay.tolerance ' )
163
+ ->andReturn (60 );
164
+
165
+ $ query = [];
166
+ $ request = [];
167
+ $ attributes = [];
168
+ $ cookies = [];
169
+ $ files = [];
170
+ $ server = [
171
+ 'HTTP_X-SIGNED-ID ' => $ id ,
172
+ 'HTTP_ALGORITHM ' => 'sha256 '
173
+ ];
174
+
175
+ $ request = new Request ($ query , $ request , $ attributes , $ cookies , $ files , $ server , 'a ' );
176
+ $ request ->headers ->set ('signature ' , (string ) new Signature (new Payload ($ request ), 'sha256 ' , 'key ' ));
177
+
178
+ $ this ->middleware ->handle ($ request , function () {
179
+ // This should be called.
180
+ $ this ->assertTrue (true );
181
+ }, 'prefix ' );
182
+ }
183
+
135
184
/**
136
185
* @test
137
186
* @expectedException \SoapBox\SignedRequests\Exceptions\ExpiredRequestException
0 commit comments