Skip to content

Commit

Permalink
changes the test so that just \n line ending is supported
Browse files Browse the repository at this point in the history
otherwise the test will be skipped
also some other reformats
  • Loading branch information
TheFRedFox committed May 27, 2016
1 parent bedc932 commit ef802cd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
37 changes: 21 additions & 16 deletions tests/TestCase/Network/Http/Auth/OauthTest.php
Expand Up @@ -222,21 +222,22 @@ public function testHmacSigning()
*
* @return void
*/
public function testRsaSigning() {
public function testRsaSigning()
{
$request = new Request();
$request->url('http://photos.example.net/photos')
->body([
'file' => 'vacaction.jpg',
'size' => 'original'
]);
$private_key_path = TEST_APP . DS . 'config' . DS . 'key.pem';
$privateKeyPath = TEST_APP . DS . 'config' . DS . 'key.pem';

$options = [
'method' => 'RSA-SHA1',
'consumerKey' => 'dpf43f3p2l4k3l03',
'nonce' => '13917289812797014437',
'timestamp' => '1196666512',
'private_key_file' => $private_key_path,
'privateKeyFile' => $privateKeyPath
];
$auth = new Oauth();
$auth->authentication($request, $options);
Expand All @@ -257,23 +258,24 @@ public function testRsaSigning() {
*
* @return void
*/
public function testRsaSigningWithPassphraseString() {
public function testRsaSigningWithPassphraseString()
{
$request = new Request();
$request->url('http://photos.example.net/photos')
->body([
'file' => 'vacaction.jpg',
'size' => 'original'
]);
$private_key_path = TEST_APP . DS . 'config' . DS . 'key_with_passphrase.pem';
$privateKeyPath = TEST_APP . DS . 'config' . DS . 'key_with_passphrase.pem';
$passphrase = 'fancy-cakephp-passphrase';

$options = [
'method' => 'RSA-SHA1',
'consumerKey' => 'dpf43f3p2l4k3l03',
'nonce' => '13917289812797014437',
'timestamp' => '1196666512',
'private_key_file' => $private_key_path,
'private_key_passphrase' => $passphrase,
'privateKeyFile' => $privateKeyPath,
'privateKeyPassphrase' => $passphrase,
];
$auth = new Oauth();
$auth->authentication($request, $options);
Expand All @@ -294,28 +296,31 @@ public function testRsaSigningWithPassphraseString() {
*
* @return void
*/
public function testRsaSigningWithPassphraseFile() {
public function testRsaSigningWithPassphraseFile()
{
$request = new Request();
$request->url('http://photos.example.net/photos')
->body([
'file' => 'vacaction.jpg',
'size' => 'original'
]);
$private_key_path = TEST_APP . DS . 'config' . DS . 'key_with_passphrase.pem';
$privateKeyPath = TEST_APP . DS . 'config' . DS . 'key_with_passphrase.pem';

if (PHP_EOL != "\n") {
$this->markTestSkipped('Just the line ending ("\n") is supported. You can run the test again e.g. on a linux system.');
return;
}

if(PHP_EOL == "\n") $passphrase_path = TEST_APP . DS . 'config' . DS . 'key_passphrase_lf';
else if(PHP_EOL == "\r\n") $passphrase_path = TEST_APP . DS . 'config' . DS . 'key_passphrase_crlf';
else if(PHP_EOL == "\r") $passphrase_path = TEST_APP . DS . 'config' . DS . 'key_passphrase_cr';
else { $this->markTestSkipped('The file for the key passphrase could not be loaded as PHP_EOL could not be recognized.'); return; }
$passphrase = fopen($passphrase_path, 'r');
$passphrasePath = TEST_APP . DS . 'config' . DS . 'key_passphrase_lf';
$passphrase = fopen($passphrasePath, 'r');

$options = [
'method' => 'RSA-SHA1',
'consumerKey' => 'dpf43f3p2l4k3l03',
'nonce' => '13917289812797014437',
'timestamp' => '1196666512',
'private_key_file' => $private_key_path,
'private_key_passphrase' => $passphrase,
'privateKeyFile' => $privateKeyPath,
'privateKeyPassphrase' => $passphrase,
];
$auth = new Oauth();
$auth->authentication($request, $options);
Expand Down
1 change: 0 additions & 1 deletion tests/test_app/config/key_passphrase_cr

This file was deleted.

1 change: 0 additions & 1 deletion tests/test_app/config/key_passphrase_crlf

This file was deleted.

0 comments on commit ef802cd

Please sign in to comment.