Skip to content

Commit

Permalink
MDL-77990 enrol_lti: test covering the response header parsing
Browse files Browse the repository at this point in the history
Makes sure the http_client shim properly returns the correct, final
http headers, not intermediate headers such as 302, 100 etc.
  • Loading branch information
snake committed May 5, 2023
1 parent 176a323 commit 159a131
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion enrol/lti/tests/local/ltiadvantage/lib/http_client_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @coversDefaultClass \enrol_lti\local\ltiadvantage\lib\http_client
*/
class http_client_test extends \basic_testcase {
class http_client_test extends \advanced_testcase {

/**
* Verify the http_client delegates to curl during a "GET" request.
Expand Down Expand Up @@ -116,4 +116,17 @@ public function unsupported_methods_provider() {
'delete' => ['DELETE'],
];
}

/**
* Verify that the response headers are properly read from curl, and exclude things like redirect headers, or 100-continues.
* @covers ::request
*/
public function test_header_parsing(): void {
$testurl = $this->getExternalTestFileUrl('/test_redir.php');
$client = new http_client(new \curl());
$response = $client->request('POST', "$testurl?redir=1",
['headers' => ['Expect' => '100-continue'], 'body' => 'foo']);
$headers = $response->getHeaders();
$this->assertEquals('200 OK', reset($headers));
}
}

0 comments on commit 159a131

Please sign in to comment.