Skip to content

Commit 383ba31

Browse files
committed
Merge branch 'ACP2E-3541' of https://github.com/adobe-commerce-tier-4/magento2ce into ACP2E-3541-1
2 parents 6e93518 + fc9fecc commit 383ba31

File tree

6 files changed

+57
-17
lines changed

6 files changed

+57
-17
lines changed

app/code/Magento/Checkout/view/frontend/web/js/model/error-processor.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* Copyright © Magento, Inc. All rights reserved.
3-
* See COPYING.txt for license details.
2+
* Copyright 2015 Adobe
3+
* All Rights Reserved.
44
*/
55

66
/**
@@ -24,7 +24,13 @@ define([
2424
messageContainer = messageContainer || globalMessageList;
2525

2626
if (response.status == 401) { //eslint-disable-line eqeqeq
27-
this.redirectTo(url.build('customer/account/login/'));
27+
error = {
28+
message: $t('You are not authorized to access this resource.')
29+
};
30+
messageContainer.addErrorMessage(error);
31+
setTimeout(() => {
32+
this.redirectTo(url.build('customer/account/login/'));
33+
}, 2000);
2834
} else {
2935
try {
3036
error = JSON.parse(response.responseText);

app/code/Magento/Theme/etc/adminhtml/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,7 @@
3737
<plugin name="validate_design_config"
3838
type="Magento\Theme\Plugin\DesignProcessorFacade"/>
3939
</type>
40+
<type name="Magento\Framework\App\ActionInterface">
41+
<plugin name="designLoader" type="Magento\Theme\Plugin\LoadDesignPlugin"/>
42+
</type>
4043
</config>

app/code/Magento/Theme/etc/di.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@
106106
<argument name="scope" xsi:type="const">Magento\Store\Model\ScopeInterface::SCOPE_STORE</argument>
107107
</arguments>
108108
</virtualType>
109-
<type name="Magento\Framework\App\ActionInterface">
110-
<plugin name="designLoader" type="Magento\Theme\Plugin\LoadDesignPlugin"/>
111-
</type>
112109
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
113110
<arguments>
114111
<argument name="collections" xsi:type="array">

app/code/Magento/Theme/etc/frontend/di.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0"?>
22
<!--
33
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
4+
* Copyright 2015 Adobe
5+
* All Rights Reserved.
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -35,4 +35,7 @@
3535
<argument name="filePath" xsi:type="string">css/critical.css</argument>
3636
</arguments>
3737
</type>
38+
<type name="Magento\Framework\App\ActionInterface">
39+
<plugin name="designLoader" type="Magento\Theme\Plugin\LoadDesignPlugin"/>
40+
</type>
3841
</config>

dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShipmentEstimationTest.php

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2016 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento\Quote\Api;
77

@@ -11,9 +11,9 @@
1111

1212
class GuestShipmentEstimationTest extends WebapiAbstract
1313
{
14-
const SERVICE_VERSION = 'V1';
15-
const SERVICE_NAME = 'quoteGuestShipmentEstimationV1';
16-
const RESOURCE_PATH = '/V1/guest-carts/';
14+
public const SERVICE_VERSION = 'V1';
15+
public const SERVICE_NAME = 'quoteGuestShipmentEstimationV1';
16+
public const RESOURCE_PATH = '/V1/guest-carts/';
1717

1818
/**
1919
* @var ObjectManager
@@ -25,6 +25,33 @@ protected function setUp(): void
2525
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
2626
}
2727

28+
/**
29+
* @return void
30+
*/
31+
public function testNotAuthorized(): void
32+
{
33+
$this->_markTestAsRestOnly();
34+
$serviceInfo = [
35+
'rest' => [
36+
'resourcePath' => '/V1/carts/mine/estimate-shipping-methods',
37+
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST,
38+
'token' => null,
39+
]
40+
];
41+
42+
$requestData = [
43+
'address' => [
44+
'country_id' => "US",
45+
'postcode' => null,
46+
'region' => null,
47+
'region_id' => null
48+
],
49+
];
50+
51+
$this->expectExceptionMessage("The consumer isn't authorized to access %resources.");
52+
$this->_webApiCall($serviceInfo, $requestData);
53+
}
54+
2855
/**
2956
* @magentoApiDataFixture Magento/SalesRule/_files/cart_rule_free_shipping.php
3057
* @magentoApiDataFixture Magento/Sales/_files/quote.php

dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/error-processor.test.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* Copyright © Magento, Inc. All rights reserved.
3-
* See COPYING.txt for license details.
2+
* Copyright 2018 Adobe
3+
* All Rights Reserved.
44
*/
55

66
/*eslint max-nested-callbacks: 0*/
@@ -62,13 +62,17 @@ define([
6262
it('check on failed status', function () {
6363
var messageContainer = jasmine.createSpyObj('globalMessageList', ['addErrorMessage']);
6464

65+
let messageObject = {
66+
message: 'You are not authorized to access this resource.'
67+
};
68+
6569
spyOn(model, 'redirectTo').and.callFake(function () {});
6670
model.process({
6771
status: 401,
6872
responseText: ''
6973
}, messageContainer);
70-
expect(mocks['mage/url'].build)
71-
.toHaveBeenCalled();
74+
expect(messageContainer.addErrorMessage)
75+
.toHaveBeenCalledWith(messageObject);
7276
});
7377
});
7478
});

0 commit comments

Comments
 (0)