Skip to content

Commit 1851fdd

Browse files
committed
AC-1619: Integration access tokens do not work as Bearer tokens
- Stabilizing tests
1 parent 12b02ed commit 1851fdd

File tree

6 files changed

+13
-16
lines changed

6 files changed

+13
-16
lines changed

app/code/Magento/Webapi/Model/Authorization/AuthorizationConfig.php renamed to app/code/Magento/Integration/Model/Config/AuthorizationConfig.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
declare(strict_types=1);
88

9-
namespace Magento\Webapi\Model\Authorization;
9+
namespace Magento\Integration\Model\Config;
1010

1111
use Magento\Framework\App\Config\ScopeConfigInterface;
1212
use Magento\Store\Model\ScopeInterface;
@@ -19,7 +19,7 @@ class AuthorizationConfig
1919
/**
2020
* XML Path for Enable Integration as Bearer
2121
*/
22-
const CONFIG_PATH_INTEGRATION_BEARER = 'webapi/authorization/enable_integration_as_bearer';
22+
const CONFIG_PATH_INTEGRATION_BEARER = 'oauth/consumer/enable_integration_as_bearer';
2323

2424
/**
2525
* @var ScopeConfigInterface

app/code/Magento/Integration/Model/OpaqueToken/Reader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
use Magento\Integration\Api\Exception\UserTokenException;
1414
use Magento\Integration\Api\IntegrationServiceInterface;
1515
use Magento\Integration\Api\UserTokenReaderInterface;
16+
use Magento\Integration\Model\Config\AuthorizationConfig;
1617
use Magento\Integration\Model\CustomUserContext;
1718
use Magento\Integration\Model\Oauth\Token;
1819
use Magento\Integration\Model\Oauth\TokenFactory;
1920
use Magento\Integration\Helper\Oauth\Data as OauthHelper;
20-
use Magento\Webapi\Model\Authorization\AuthorizationConfig;
2121

2222
/**
2323
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -147,6 +147,6 @@ private function getUserId(Token $tokenModel): int
147147
throw new UserTokenException('Invalid token found');
148148
}
149149

150-
return $userId;
150+
return (int)$userId;
151151
}
152152
}

app/code/Magento/Webapi/Test/Unit/Model/Authorization/AuthorizationConfigTest.php renamed to app/code/Magento/Integration/Test/Unit/Model/Config/AuthorizationConfigTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
declare(strict_types=1);
88

9-
namespace Magento\Webapi\Test\Unit\Model\Authorization;
9+
namespace Magento\Integration\Test\Unit\Model\Config\Authorization;
1010

1111
use Magento\Framework\App\Config\ScopeConfigInterface;
12-
use Magento\Webapi\Model\Authorization\AuthorizationConfig;
12+
use Magento\Integration\Model\Config\AuthorizationConfig;
1313
use PHPUnit\Framework\MockObject\MockObject;
1414
use PHPUnit\Framework\TestCase;
1515

@@ -34,7 +34,7 @@ protected function setUp(): void
3434
public function testEnabled()
3535
{
3636
$this->scopeConfig->method('isSetFlag')
37-
->with('webapi/authorization/enable_integration_as_bearer')
37+
->with('oauth/consumer/enable_integration_as_bearer')
3838
->willReturn(true);
3939

4040
self::assertTrue($this->config->isIntegrationAsBearerEnabled());
@@ -43,7 +43,7 @@ public function testEnabled()
4343
public function testDisabled()
4444
{
4545
$this->scopeConfig->method('isSetFlag')
46-
->with('webapi/authorization/enable_integration_as_bearer')
46+
->with('oauth/consumer/enable_integration_as_bearer')
4747
->willReturn(false);
4848

4949
self::assertFalse($this->config->isIntegrationAsBearerEnabled());

app/code/Magento/Integration/etc/adminhtml/system.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@
5454
<comment>Timeout for OAuth consumer credentials Post request within X seconds.</comment>
5555
<validate>required-entry validate-zero-or-greater validate-number</validate>
5656
</field>
57+
<field id="enable_integration_as_bearer" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
58+
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
59+
<label>Allow OAuth Access Tokens to be used as standalone Bearer tokens</label>
60+
</field>
5761
</group>
5862
<group id="authentication_lock" translate="label" type="text" sortOrder="400" showInDefault="1">
5963
<label>Authentication Locks</label>

app/code/Magento/Webapi/etc/adminhtml/system.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@
2020
<comment>If empty, UTF-8 will be used.</comment>
2121
</field>
2222
</group>
23-
<group id="authorization" translate="label" type="text" sortOrder="15" showInDefault="1" showInWebsite="1" showInStore="1">
24-
<label>Web Api Authentication</label>
25-
<field id="enable_integration_as_bearer" translate="label" type="select" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1">
26-
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
27-
<label>Enable Input Limits</label>
28-
</field>
29-
</group>
3023
</section>
3124
</system>
3225
</config>

dev/tests/api-functional/testsuite/Magento/Integration/Model/IntegrationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function testIntegrationAsBearerTokenDefault()
9090
/**
9191
* Test Integration access token can be used as Bearer token when explicitly enabled
9292
*
93-
* @magentoConfigFixture default_store webapi/authorization/enable_integration_as_bearer 1
93+
* @magentoConfigFixture default_store oauth/consumer/enable_integration_as_bearer 1
9494
* @doesNotPerformAssertions
9595
*/
9696
public function testIntegrationAsBearerTokenEnabled()

0 commit comments

Comments
 (0)