mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Improve Company Gateway validation
This commit is contained in:
parent
c061046247
commit
b5a8c60db5
@ -34,7 +34,7 @@ class StoreCompanyGatewayRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
$rules = [
|
||||
'gateway_key' => 'required',
|
||||
'gateway_key' => 'required|alpha_num',
|
||||
'fees_and_limits' => new ValidCompanyGatewayFeesAndLimitsRule(),
|
||||
];
|
||||
|
||||
@ -45,9 +45,8 @@ class StoreCompanyGatewayRequest extends Request
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
$gateway = Gateway::where('key', $input['gateway_key'])->first();
|
||||
|
||||
if($gateway);
|
||||
if($gateway = Gateway::where('key', $input['gateway_key'])->first())
|
||||
{
|
||||
|
||||
$default_gateway_fields = json_decode($gateway->fields);
|
||||
|
@ -45,6 +45,43 @@ class CompanyGatewayApiTest extends TestCase
|
||||
Model::reguard();
|
||||
}
|
||||
|
||||
public function testCompanyGatewayEndPointsWithIncorrectFields()
|
||||
{
|
||||
$data = [
|
||||
'config' => 'random config',
|
||||
'gateway_key' => '',
|
||||
];
|
||||
|
||||
/* POST */
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->post('/api/v1/company_gateways', $data);
|
||||
|
||||
$response->assertStatus(302);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function testCompanyGatewayEndPointsWithInvalidFields()
|
||||
{
|
||||
$data = [
|
||||
'config' => 'random config',
|
||||
'gateway_key' => '$#%^&*(',
|
||||
];
|
||||
|
||||
/* POST */
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->post('/api/v1/company_gateways', $data);
|
||||
|
||||
$response->assertStatus(302);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function testCompanyGatewayEndPoints()
|
||||
{
|
||||
$data = [
|
||||
|
Loading…
x
Reference in New Issue
Block a user