Skip to content
Extraits de code Groupes Projets
Valider 9211e140 rédigé par sgiehl's avatar sgiehl
Parcourir les fichiers

added test for http authentication

parent de0a258d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
<?php
if (isset($_SERVER['PHP_AUTH_USER']) && $_SERVER['PHP_AUTH_USER'] == 'test' && $_SERVER['PHP_AUTH_PW'] == 'test') {
echo 'Authentication successful';
exit;
} else {
header('WWW-Authenticate: Basic realm="TestAuth"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authentication required';
exit;
}
\ No newline at end of file
......@@ -116,6 +116,57 @@ class HttpTest extends \PHPUnit_Framework_TestCase
$this->assertTrue(in_array($result['headers']['Content-Type'], array('application/zip', 'application/x-zip-compressed')));
}
/**
* @dataProvider getMethodsToTest
*/
public function testHttpAuthentication($method)
{
$result = Http::sendHttpRequestBy(
$method,
Fixture::getRootUrl() . 'tests/PHPUnit/Integration/Http/HttpAuthentication.php',
30,
$userAgent = null,
$destinationPath = null,
$file = null,
$followDepth = 0,
$acceptLanguage = false,
$acceptInvalidSslCertificate = false,
$byteRange = false,
$getExtendedInfo = true,
$httpMethod = 'GET',
$httpUsername = 'test',
$httpPassword = 'test'
);
$this->assertEquals('Authentication successful', $result['data']);
$this->assertEquals(200, $result['status']);
}
/**
* @dataProvider getMethodsToTest
*/
public function testHttpAuthenticationInvalid($method)
{
$result = Http::sendHttpRequestBy(
$method,
Fixture::getRootUrl() . 'tests/PHPUnit/Integration/Http/HttpAuthentication.php',
30,
$userAgent = null,
$destinationPath = null,
$file = null,
$followDepth = 0,
$acceptLanguage = false,
$acceptInvalidSslCertificate = false,
$byteRange = false,
$getExtendedInfo = true,
$httpMethod = 'GET',
$httpUsername = '',
$httpPassword = ''
);
$this->assertEquals(401, $result['status']);
}
/**
* @dataProvider getMethodsToTest
*/
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter