Skip to content

Commit

Permalink
[#375] Switch to mocks for Functional StatusReportTest (#389)
Browse files Browse the repository at this point in the history
* [#375] Switch to mocks for Functional StatusReportTest

* [#375] Switch to mocks for Functional StatusReportTest.

Co-authored-by: Arlina Espinoza <[email protected]>
  • Loading branch information
shadcn and arlina-espinoza authored Apr 6, 2020
1 parent 5f1cd2c commit 22c76fc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/modules/apigee_mock_api_client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,9 @@ For convenience, helper methods have been added to `ApigeeMockApiClientHelperTra

See [ApigeeMockApiClientHelperTrait](tests/src/Traits/ApigeeMockApiClientHelperTrait.php) for a full list of helper
methods and documentation on usage.

Notes:

- This module is not currently compatible with `apigee_edge_test` or `apigee_edge_debug`, as they decorate the
SDK connector client, and this module replaces one of the arguments (injected services). Refactored tests should not
enable those modules.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"access_token": "yeJhbGciOiJSUzI1NiJ9.eyJqdGkiOiIxNWE0ZDlmNS0xNWEyLTQ3NzYtYjg1My0zZTMxZDBjMmI5MGYiLCJzdWIiOiJmMjgzZGZlOC1mMDJhLTRkNmEtYWMyZC0zMGI1ZDQ5ZGZmNjEiLCJzY29wZSI6WyJzY2ltLmVtYWlscy5yZWFkIiwic2NpbS5tZSIsIm9wZW5pZCIsInBhc3N3b3JkLndyaXRlIiwiYXBwcm92YWxzLm1lIiwic2NpbS5pZHMucmVhZCIsIm9hdXRoLmFwcHJvdmFscyJdLCJjbGllbnRfaWQiOiJlZGdlY2xpIiwiY2lkIjoiZWRnZWNsaSIsImF6cCI6ImVkZ2VjbGkiLCJncmFudF90eXBlIjoicGFzc3dvcmQiLCJ1c2VyX2lkIjoiZjI4M2RmZTgtZjAyYS00ZDZhLWFjMmQtMzBiNWQ0OWRmZjYxIiwib3JpZ2luIjoidXNlcmdyaWQiLCJ1c2VyX25hbWUiOiJh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xNTg4MzY4MTgxLCJjaWQiOiJlZGdlY2xpIiwiY2xpZW50X2lkIjoiZWRnZWNsaSIsImlzcyI6Imh0dHBzOi8vbG9naW4uYXBpZ2VlLmNvbSIsInppZCI6InVhYSIsImdyYW50X3R5cGUiOiJwYXNzd29yZCIsInVzZXJfbmFtZSI6ImFybGluYS5lc3Bpbm96YUBnbWFpbC5jb20iLCJvcmlnaW4iOiJ1c2VyZ3JpZCIsInVzZXJfaWQiOiJmMjgzZGZlOC1mMDJhLTRkNmEtYWMyZC0zMGI1ZDQ5ZGZmNjEiLCJhbCI6MCwicmV2X3NpZyI6Ijg5ZWU3YzFlIiwiYXVkIjpbImVkZ2VjbGkiLCJzY2ltLmVtYWlscyIsInNjaW0iLCJvcGVuaWQiLCJwYXNzd29yZCIsImFwcHJvdmFscyIsInNjaW0uaWRzIiwib2F1dGgiXX0.Jee1t2nIM8tuBPsJ41fGrIYzXnU0KLncI7oQsUbu3xirRjcvkTHq_K4jSOTAWxmj1L_URfgAWhZ9If8VWMm3ERPxGZdjb_P32xYL_wfIMK3SqNQlBMsg9dUFFM2O-i2PuciJ9IvZnPCWCM3nr5t202TYFrq5VueQOeZ_WW-R2wl_uxh4kFBjf3fD0Q_4Oy5kmDvZSMQRYWPJFIRAUEHCTpHWIuuWoRp4dLrzM2n6c75Bk0jR4Kr6WDOj03AAvllCn_-UT6JXsrfBEI8QP-qfboq0_ZqdT17rtwjFc9CvoZUHeIYjp_BOTNDFBuSpqv8qwGmTQOmMAVfjyzEpI_7M7x",
"expires_in": 43199,
"scope": "scim.emails.read scim.me openid password.write approvals.me scim.ids.read oauth.approvals",
"jti": "17a4d9f5-15a2-4776-b853-3e31d0c2b90i"
}
13 changes: 13 additions & 0 deletions tests/src/Functional/StatusReportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,22 @@ class StatusReportTest extends ApigeeEdgeFunctionalTestBase {

const CANNOT_CONNECT_LONG = 'Cannot connect to Apigee Edge server. You have either given wrong credential details or the Apigee Edge server is unreachable. Visit the Apigee Edge general settings page to get more information.';

/**
* {@inheritdoc}
*/
protected static $mock_api_client_ready = TRUE;

/**
* Tests invalid credentials.
*/
public function testInvalidCredentials() {
$orgName = $this->sdkConnector->getOrganization();

$this->drupalLogin($this->rootUser);
$status_report_path = Url::fromRoute('system.status');

// Ensure that pre-defined credentials are correctly set.
$this->stack->queueMockResponse(['org' => ['org_name' => $orgName]]);
$this->drupalGet($status_report_path);
$this->assertSession()->pageTextNotContains(self::CANNOT_CONNECT_SHORT);

Expand Down Expand Up @@ -82,6 +90,7 @@ public function testInvalidCredentials() {
$key->save();
$this->setKey('private_file');

$this->stack->queueMockResponse(['org' => ['org_name' => $orgName]]);
$this->drupalGet($status_report_path);
$this->assertSession()->pageTextNotContains(self::CANNOT_CONNECT_SHORT);

Expand All @@ -95,6 +104,7 @@ public function testInvalidCredentials() {
]));
$key->save();

$this->stack->queueMockResponse(['get_not_found' => ['status_code' => 401]]);
$this->drupalGet($status_report_path);
$this->assertSession()->pageTextContains(self::CANNOT_CONNECT_LONG);

Expand All @@ -117,6 +127,8 @@ public function testInvalidCredentials() {

$this->setKey('private_file_oauth');

$this->stack->queueMockResponse('access_token');
$this->stack->queueMockResponse(['org' => ['org_name' => $orgName]]);
$this->drupalGet($status_report_path);
$this->assertSession()->pageTextNotContains(self::CANNOT_CONNECT_SHORT);

Expand All @@ -130,6 +142,7 @@ public function testInvalidCredentials() {
]));
$key->save();

$this->stack->queueMockResponse('get_not_found');
$this->drupalGet($status_report_path);
$this->assertSession()->pageTextContains(self::CANNOT_CONNECT_LONG);

Expand Down

0 comments on commit 22c76fc

Please sign in to comment.