mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-30 20:44:33 -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()
|
public function rules()
|
||||||
{
|
{
|
||||||
$rules = [
|
$rules = [
|
||||||
'gateway_key' => 'required',
|
'gateway_key' => 'required|alpha_num',
|
||||||
'fees_and_limits' => new ValidCompanyGatewayFeesAndLimitsRule(),
|
'fees_and_limits' => new ValidCompanyGatewayFeesAndLimitsRule(),
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -45,9 +45,8 @@ class StoreCompanyGatewayRequest extends Request
|
|||||||
{
|
{
|
||||||
$input = $this->all();
|
$input = $this->all();
|
||||||
|
|
||||||
$gateway = Gateway::where('key', $input['gateway_key'])->first();
|
|
||||||
|
if($gateway = Gateway::where('key', $input['gateway_key'])->first())
|
||||||
if($gateway);
|
|
||||||
{
|
{
|
||||||
|
|
||||||
$default_gateway_fields = json_decode($gateway->fields);
|
$default_gateway_fields = json_decode($gateway->fields);
|
||||||
|
@ -45,6 +45,43 @@ class CompanyGatewayApiTest extends TestCase
|
|||||||
Model::reguard();
|
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()
|
public function testCompanyGatewayEndPoints()
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user