Include a batch of naughty strings to see what happens to Firefly.

This commit is contained in:
James Cole
2017-01-16 20:10:47 +01:00
parent 1e69a54972
commit 77f889aba6
3 changed files with 520 additions and 12 deletions

View File

@@ -84,16 +84,6 @@ abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
];
}
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
public function setUp()
{
parent::setUp();
}
/**
* @return User
*/
@@ -104,6 +94,33 @@ abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
return $user;
}
/**
* @return array
*/
public function naughtyStringProvider()
{
$path = realpath(__DIR__ . '/../resources/tests/blns.base64.json');
$content = file_get_contents($path);
$array = json_decode($content);
$return = [];
foreach ($array as $entry) {
$return[] = [base64_decode($entry)];
}
return $return;
}
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
public function setUp()
{
parent::setUp();
}
/**
* @return User
*/

View File

@@ -85,7 +85,7 @@ class SingleControllerTest extends TestCase
}
/**
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::store
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::store
*/
public function testStore()
{
@@ -99,13 +99,36 @@ class SingleControllerTest extends TestCase
'source_account_id' => 1,
'destination_account_name' => 'Some destination',
'date' => '2016-01-01',
'description' => 'Some description',
'description' => 'Test descr',
];
$this->call('post', route('transactions.store', ['withdrawal']), $data);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::store
* @dataProvider naughtyStringProvider
*/
public function testStoreNaughty(string $description)
{
$this->session(['transactions.create.url' => 'http://localhost']);
$this->be($this->user());
$data = [
'what' => 'withdrawal',
'amount' => '10',
'amount_currency_id_amount' => 1,
'source_account_id' => 1,
'destination_account_name' => 'Some destination',
'date' => '2016-01-01',
'description' => $description,
];
$response = $this->call('post', route('transactions.store', ['withdrawal']), $data);
$this->assertNotEquals($response->getStatusCode(), 500);
}
/**
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::update
*/