Skip to content

Commit 981ad32

Browse files
bl4desvera
authored andcommitted
LYNX-364: Extend GraphQL StoreConfig for Customer Token Lifetime Configuration (#213)
* LYNX-364: Extend GraphQL StoreConfig for Customer Token Lifetime Configuration * LYNX-364: WebAPI tests * LYNX-364: WebAPI tests fix * LYNX-364: WebAPI test for unauthorized customer; refactoring * LYNX-364: update comment * LYNX-364: update comment * LYNX-364Create new IntegrationGraphQl module * LYNX-364: Restore deleted file * LYNX-364: Remove unnecessary authorization check * LYNX-364: Fix static tests * LYNX-364: Fix Static Tests * LYNX-364: CR changes * LYNX-364: CR refactoring * LYNX-364: CR refactoring
1 parent 98cdea0 commit 981ad32

File tree

8 files changed

+216
-0
lines changed

8 files changed

+216
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Magento_IntegrationGraphQl module
2+
3+
This module provides GraphQl resolvers for Integartion module.
4+
5+
## Installation
6+
7+
Before installing this module, note that the Magento_IntegrationGraphQl is dependent on the following modules:
8+
9+
- `Magento_GraphQl`
10+
- `Magento_Integration`
11+
12+
For information about a module installation in Magento 2, see [Enable or disable modules](https://experienceleague.adobe.com/docs/commerce-operations/installation-guide/tutorials/manage-modules.html).
13+
14+
## Extensibility
15+
16+
Extension developers can interact with the Magento_IntegrationGraphQl module. For more information about the Magento extension mechanism, see [Magento plugins](https://developer.adobe.com/commerce/php/development/components/plugins/).
17+
18+
[The Magento dependency injection mechanism](https://developer.adobe.com/commerce/php/development/components/dependency-injection/) enables you to override the functionality of the Magento_IntegrationGraphQl module.
19+
20+
## Additional information
21+
22+
You can get more information about [GraphQl In Magento 2](https://developer.adobe.com/commerce/webapi/graphql/).
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "magento/module-integration-graph-ql",
3+
"description": "N/A",
4+
"type": "magento2-module",
5+
"require": {
6+
"php": "~8.1.0||~8.2.0||~8.3.0",
7+
"magento/framework": "*",
8+
"magento/module-integration": "*"
9+
},
10+
"license": [
11+
"OSL-3.0",
12+
"AFL-3.0"
13+
],
14+
"autoload": {
15+
"files": [
16+
"registration.php"
17+
],
18+
"psr-4": {
19+
"Magento\\IntegrationGraphQl\\": ""
20+
}
21+
}
22+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/************************************************************************
4+
*
5+
* Copyright 2024 Adobe
6+
* All Rights Reserved.
7+
*
8+
* NOTICE: All information contained herein is, and remains
9+
* the property of Adobe and its suppliers, if any. The intellectual
10+
* and technical concepts contained herein are proprietary to Adobe
11+
* and its suppliers and are protected by all applicable intellectual
12+
* property laws, including trade secret and copyright laws.
13+
* Dissemination of this information or reproduction of this material
14+
* is strictly forbidden unless prior written permission is obtained
15+
* from Adobe.
16+
* ************************************************************************
17+
*/
18+
-->
19+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
20+
<type name="Magento\StoreGraphQl\Model\Resolver\Store\StoreConfigDataProvider">
21+
<arguments>
22+
<argument name="extendedConfigData" xsi:type="array">
23+
<item name="customer_access_token_lifetime" xsi:type="string">oauth/access_token_lifetime/customer</item>
24+
</argument>
25+
</arguments>
26+
</type>
27+
</config>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/************************************************************************
4+
*
5+
* Copyright 2024 Adobe
6+
* All Rights Reserved.
7+
*
8+
* NOTICE: All information contained herein is, and remains
9+
* the property of Adobe and its suppliers, if any. The intellectual
10+
* and technical concepts contained herein are proprietary to Adobe
11+
* and its suppliers and are protected by all applicable intellectual
12+
* property laws, including trade secret and copyright laws.
13+
* Dissemination of this information or reproduction of this material
14+
* is strictly forbidden unless prior written permission is obtained
15+
* from Adobe.
16+
* ************************************************************************
17+
*/
18+
-->
19+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
20+
<module name="Magento_IntegrationGraphQl" >
21+
</module>
22+
</config>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# ADOBE CONFIDENTIAL
2+
# ___________________
3+
#
4+
# Copyright 2024 Adobe
5+
# All Rights Reserved.
6+
#
7+
# NOTICE: All information contained herein is, and remains
8+
# the property of Adobe and its suppliers, if any. The intellectual
9+
# and technical concepts contained herein are proprietary to Adobe
10+
# and its suppliers and are protected by all applicable intellectual
11+
# property laws, including trade secret and copyright laws.
12+
# Dissemination of this information or reproduction of this material
13+
# is strictly forbidden unless prior written permission is obtained
14+
# from Adobe.
15+
16+
type StoreConfig {
17+
customer_access_token_lifetime: Float @doc(description: "Customer access token lifetime.")
18+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*
6+
* NOTICE: All information contained herein is, and remains
7+
* the property of Adobe and its suppliers, if any. The intellectual
8+
* and technical concepts contained herein are proprietary to Adobe
9+
* and its suppliers and are protected by all applicable intellectual
10+
* property laws, including trade secret and copyright laws.
11+
* Dissemination of this information or reproduction of this material
12+
* is strictly forbidden unless prior written permission is obtained from
13+
* Adobe.
14+
*/
15+
declare(strict_types=1);
16+
17+
use Magento\Framework\Component\ComponentRegistrar;
18+
19+
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_IntegrationGraphQl', __DIR__);

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@
206206
"magento/module-indexer": "*",
207207
"magento/module-instant-purchase": "*",
208208
"magento/module-integration": "*",
209+
"magento/module-integration-graph-ql": "*",
209210
"magento/module-layered-navigation": "*",
210211
"magento/module-login-as-customer": "*",
211212
"magento/module-login-as-customer-admin-ui": "*",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*
6+
* NOTICE: All information contained herein is, and remains
7+
* the property of Adobe and its suppliers, if any. The intellectual
8+
* and technical concepts contained herein are proprietary to Adobe
9+
* and its suppliers and are protected by all applicable intellectual
10+
* property laws, including trade secret and copyright laws.
11+
* Dissemination of this information or reproduction of this material
12+
* is strictly forbidden unless prior written permission is obtained from
13+
* Adobe.
14+
*/
15+
declare(strict_types=1);
16+
17+
namespace Magento\GraphQl\IntegrationGraphQl;
18+
19+
use Magento\TestFramework\TestCase\GraphQlAbstract;
20+
use Magento\TestFramework\Fixture\Config;
21+
22+
/**
23+
* Class for Store Config Customer Access Token Lifetime settings
24+
*/
25+
class CustomerAccessTokenLifetimeResolverTest extends GraphQlAbstract
26+
{
27+
#[
28+
Config('oauth/access_token_lifetime/customer', '2')
29+
]
30+
public function testGetCustomerAccessTokenLifetimeAsString()
31+
{
32+
$this->assertEquals(
33+
$this->graphQlQuery($this->getQuery()),
34+
[
35+
'storeConfig' => [
36+
"customer_access_token_lifetime" => 2
37+
]
38+
]
39+
);
40+
}
41+
42+
#[
43+
Config('oauth/access_token_lifetime/customer', 2.5)
44+
]
45+
public function testGetCustomerAccessTokenLifetimeAsFloat()
46+
{
47+
$this->assertEquals(
48+
$this->graphQlQuery($this->getQuery()),
49+
[
50+
'storeConfig' => [
51+
"customer_access_token_lifetime" => 2.5
52+
]
53+
]
54+
);
55+
}
56+
57+
#[
58+
Config('oauth/access_token_lifetime/customer', null)
59+
]
60+
public function testGetCustomerAccessTokenLifetimeNull()
61+
{
62+
$this->assertEquals(
63+
$this->graphQlQuery($this->getQuery()),
64+
[
65+
'storeConfig' => [
66+
"customer_access_token_lifetime" => null
67+
]
68+
]
69+
);
70+
}
71+
72+
/**
73+
* @return string
74+
*/
75+
private function getQuery(): string
76+
{
77+
return <<<QUERY
78+
{
79+
storeConfig {
80+
customer_access_token_lifetime
81+
}
82+
}
83+
QUERY;
84+
}
85+
}

0 commit comments

Comments
 (0)