Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Payplug/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public static function generateJWT($client_id = '', $client_secret = '')
return array();
}

$response['httpResponse']['expires_date'] = time() + $response['httpResponse']['expires_in'];
$response['httpResponse']['expires_date'] = time() + $response['httpResponse']['expires_in'] - 30;

return $response;
} catch (Exception $e) {
Expand Down
28 changes: 14 additions & 14 deletions tests/unit_tests/AuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,21 @@ protected function setUpTwice()

public function testGetKeysByLogin()
{
$email = 'test@fakemail.com';
$password = 'passwordIsOverrated';
$response = array(
'secret_keys' => array(
'test' => 'sk_test_everythingIsUnderControl',
'live' => 'sk_live_allYourBasesAreBelongToUs',
$email = 'test@example.com';
$password = 'password_example';
$expected_response = array(
'httpResponse' => array(
'secret_keys' => array(
'test' => 'test_key_example',
'live' => 'live_key_example',
)
),
'httpStatus' => 201,
);
$this->_requestMock
->expects($this->once())
->method('exec')
->will($this->returnValue(json_encode($response)));
->will($this->returnValue(json_encode($expected_response['httpResponse'])));

$this->_requestMock
->expects($this->any())
Expand All @@ -64,10 +67,7 @@ public function testGetKeysByLogin()
}));

$authentication = Authentication::getKeysByLogin($email, $password);

$this->assertEquals(201, $authentication['httpStatus']);
$this->assertEquals('sk_test_everythingIsUnderControl', $authentication['httpResponse']['secret_keys']['test']);
$this->assertEquals('sk_live_allYourBasesAreBelongToUs', $authentication['httpResponse']['secret_keys']['live']);
$this->assertSame($expected_response, $authentication);
}

public function testGetAccount()
Expand Down Expand Up @@ -189,7 +189,7 @@ public function testGetPermissionsWithoutSecretKey()
public function testPublishableKeys()
{
$response = array(
'publishable_key' => 'pk_test_everythingIsUnderControl'
'publishable_key' => 'test_pk_example'
);

$this->_requestMock
Expand All @@ -211,7 +211,7 @@ public function testPublishableKeys()
$publishable_keys = Authentication::getPublishableKeys($this->_configuration);

$this->assertEquals(200, $publishable_keys['httpStatus']);
$this->assertEquals('pk_test_everythingIsUnderControl', $publishable_keys['httpResponse']['publishable_key']);
$this->assertEquals('test_pk_example', $publishable_keys['httpResponse']['publishable_key']);
}

/**
Expand Down Expand Up @@ -336,7 +336,7 @@ public function testGenerateJWTWhenSuccessResponse()
'expires_in' => 300,
'scope' => 'sandbox',
'token_type' => 'bearer',
'expires_date' => time() + 300
'expires_date' => time() + 270
);

$this->_requestMock
Expand Down
Loading