Skip to content

Commit 22c76fc

Browse files
[#375] Switch to mocks for Functional StatusReportTest (#389)
* [#375] Switch to mocks for Functional StatusReportTest * [#375] Switch to mocks for Functional StatusReportTest. Co-authored-by: Arlina Espinoza <[email protected]>
1 parent 5f1cd2c commit 22c76fc

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

tests/modules/apigee_mock_api_client/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,9 @@ For convenience, helper methods have been added to `ApigeeMockApiClientHelperTra
116116

117117
See [ApigeeMockApiClientHelperTrait](tests/src/Traits/ApigeeMockApiClientHelperTrait.php) for a full list of helper
118118
methods and documentation on usage.
119+
120+
Notes:
121+
122+
- This module is not currently compatible with `apigee_edge_test` or `apigee_edge_debug`, as they decorate the
123+
SDK connector client, and this module replaces one of the arguments (injected services). Refactored tests should not
124+
enable those modules.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"access_token": "yeJhbGciOiJSUzI1NiJ9.eyJqdGkiOiIxNWE0ZDlmNS0xNWEyLTQ3NzYtYjg1My0zZTMxZDBjMmI5MGYiLCJzdWIiOiJmMjgzZGZlOC1mMDJhLTRkNmEtYWMyZC0zMGI1ZDQ5ZGZmNjEiLCJzY29wZSI6WyJzY2ltLmVtYWlscy5yZWFkIiwic2NpbS5tZSIsIm9wZW5pZCIsInBhc3N3b3JkLndyaXRlIiwiYXBwcm92YWxzLm1lIiwic2NpbS5pZHMucmVhZCIsIm9hdXRoLmFwcHJvdmFscyJdLCJjbGllbnRfaWQiOiJlZGdlY2xpIiwiY2lkIjoiZWRnZWNsaSIsImF6cCI6ImVkZ2VjbGkiLCJncmFudF90eXBlIjoicGFzc3dvcmQiLCJ1c2VyX2lkIjoiZjI4M2RmZTgtZjAyYS00ZDZhLWFjMmQtMzBiNWQ0OWRmZjYxIiwib3JpZ2luIjoidXNlcmdyaWQiLCJ1c2VyX25hb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E4MSwiZXhwIjoxNTg4MzY4MTgxLCJjaWQiOiJlZGdlY2xpIiwiY2xpZW50X2lkIjoiZWRnZWNsaSIsImlzcyI6Imh0dHBzOi8vbG9naW4uYXBpZ2VlLmNvbSIsInppZCI6InVhYSIsImdyYW50X3R5cGUiOiJwYXNzd29yZCIsInVzZXJfbmFtZSI6ImFybGluYS5lc3Bpbm96YUBnbWFpbC5jb20iLCJvcmlnaW4iOiJ1c2VyZ3JpZCIsInVzZXJfaWQiOiJmMjgzZGZlOC1mMDJhLTRkNmEtYWMyZC0zMGI1ZDQ5ZGZmNjEiLCJhbCI6MCwicmV2X3NpZyI6Ijg5ZWU3YzFlIiwiYXVkIjpbImVkZ2VjbGkiLCJzY2ltLmVtYWlscyIsInNjaW0iLCJvcGVuaWQiLCJwYXNzd29yZCIsImFwcHJvdmFscyIsInNjaW0uaWRzIiwib2F1dGgiXX0.Jee1t2nIM8tuBPsJ41fGrIYzXnU0KLncI7oQsUbu3xirRjcvkTHq_K4jSOTAWxmj1L_URfgAWhZ9If8VWMm3ERPxGZdjb_P32xYL_wfIMK3SqNQlBMsg9dUFFM2O-i2PuciJ9IvZnPCWCM3nr5t202TYFrq5VueQOeZ_WW-R2wl_uxh4kFBjf3fD0Q_4Oy5kmDvZSMQRYWPJFIRAUEHCTpHWIuuWoRp4dLrzM2n6c75Bk0jR4Kr6WDOj03AAvllCn_-UT6JXsrfBEI8QP-qfboq0_ZqdT17rtwjFc9CvoZUHeIYjp_BOTNDFBuSpqv8qwGmTQOmMAVfjyzEpI_7M7x",
5+
"expires_in": 43199,
6+
"scope": "scim.emails.read scim.me openid password.write approvals.me scim.ids.read oauth.approvals",
7+
"jti": "17a4d9f5-15a2-4776-b853-3e31d0c2b90i"
8+
}

tests/src/Functional/StatusReportTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,22 @@ class StatusReportTest extends ApigeeEdgeFunctionalTestBase {
4141

4242
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.';
4343

44+
/**
45+
* {@inheritdoc}
46+
*/
47+
protected static $mock_api_client_ready = TRUE;
48+
4449
/**
4550
* Tests invalid credentials.
4651
*/
4752
public function testInvalidCredentials() {
53+
$orgName = $this->sdkConnector->getOrganization();
54+
4855
$this->drupalLogin($this->rootUser);
4956
$status_report_path = Url::fromRoute('system.status');
5057

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

@@ -82,6 +90,7 @@ public function testInvalidCredentials() {
8290
$key->save();
8391
$this->setKey('private_file');
8492

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

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

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

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

118128
$this->setKey('private_file_oauth');
119129

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

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

145+
$this->stack->queueMockResponse('get_not_found');
133146
$this->drupalGet($status_report_path);
134147
$this->assertSession()->pageTextContains(self::CANNOT_CONNECT_LONG);
135148

0 commit comments

Comments
 (0)