File tree Expand file tree Collapse file tree 6 files changed +57
-17
lines changed
Checkout/view/frontend/web/js/model
api-functional/testsuite/Magento/Quote/Api
js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model Expand file tree Collapse file tree 6 files changed +57
-17
lines changed Original file line number Diff line number Diff line change 1
1
/**
2
- * Copyright © Magento, Inc. All rights reserved.
3
- * See COPYING.txt for license details .
2
+ * Copyright 2015 Adobe
3
+ * All Rights Reserved .
4
4
*/
5
5
6
6
/**
@@ -24,7 +24,13 @@ define([
24
24
messageContainer = messageContainer || globalMessageList ;
25
25
26
26
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 ) ;
28
34
} else {
29
35
try {
30
36
error = JSON . parse ( response . responseText ) ;
Original file line number Diff line number Diff line change 37
37
<plugin name =" validate_design_config"
38
38
type =" Magento\Theme\Plugin\DesignProcessorFacade" />
39
39
</type >
40
+ <type name =" Magento\Framework\App\ActionInterface" >
41
+ <plugin name =" designLoader" type =" Magento\Theme\Plugin\LoadDesignPlugin" />
42
+ </type >
40
43
</config >
Original file line number Diff line number Diff line change 106
106
<argument name =" scope" xsi : type =" const" >Magento\Store\Model\ScopeInterface::SCOPE_STORE</argument >
107
107
</arguments >
108
108
</virtualType >
109
- <type name =" Magento\Framework\App\ActionInterface" >
110
- <plugin name =" designLoader" type =" Magento\Theme\Plugin\LoadDesignPlugin" />
111
- </type >
112
109
<type name =" Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory" >
113
110
<arguments >
114
111
<argument name =" collections" xsi : type =" array" >
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" ?>
2
2
<!--
3
3
/**
4
- * Copyright © Magento, Inc. All rights reserved.
5
- * See COPYING.txt for license details .
4
+ * Copyright 2015 Adobe
5
+ * All Rights Reserved .
6
6
*/
7
7
-->
8
8
<config xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
35
35
<argument name =" filePath" xsi : type =" string" >css/critical.css</argument >
36
36
</arguments >
37
37
</type >
38
+ <type name =" Magento\Framework\App\ActionInterface" >
39
+ <plugin name =" designLoader" type =" Magento\Theme\Plugin\LoadDesignPlugin" />
40
+ </type >
38
41
</config >
Original file line number Diff line number Diff line change 1
1
<?php
2
2
/**
3
- * Copyright © Magento, Inc. All rights reserved.
4
- * See COPYING.txt for license details .
3
+ * Copyright 2016 Adobe
4
+ * All Rights Reserved .
5
5
*/
6
6
namespace Magento \Quote \Api ;
7
7
11
11
12
12
class GuestShipmentEstimationTest extends WebapiAbstract
13
13
{
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/ ' ;
17
17
18
18
/**
19
19
* @var ObjectManager
@@ -25,6 +25,33 @@ protected function setUp(): void
25
25
$ this ->objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
26
26
}
27
27
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
+
28
55
/**
29
56
* @magentoApiDataFixture Magento/SalesRule/_files/cart_rule_free_shipping.php
30
57
* @magentoApiDataFixture Magento/Sales/_files/quote.php
Original file line number Diff line number Diff line change 1
1
/**
2
- * Copyright © Magento, Inc. All rights reserved.
3
- * See COPYING.txt for license details .
2
+ * Copyright 2018 Adobe
3
+ * All Rights Reserved .
4
4
*/
5
5
6
6
/*eslint max-nested-callbacks: 0*/
@@ -62,13 +62,17 @@ define([
62
62
it ( 'check on failed status' , function ( ) {
63
63
var messageContainer = jasmine . createSpyObj ( 'globalMessageList' , [ 'addErrorMessage' ] ) ;
64
64
65
+ let messageObject = {
66
+ message : 'You are not authorized to access this resource.'
67
+ } ;
68
+
65
69
spyOn ( model , 'redirectTo' ) . and . callFake ( function ( ) { } ) ;
66
70
model . process ( {
67
71
status : 401 ,
68
72
responseText : ''
69
73
} , messageContainer ) ;
70
- expect ( mocks [ 'mage/url' ] . build )
71
- . toHaveBeenCalled ( ) ;
74
+ expect ( messageContainer . addErrorMessage )
75
+ . toHaveBeenCalledWith ( messageObject ) ;
72
76
} ) ;
73
77
} ) ;
74
78
} ) ;
You can’t perform that action at this time.
0 commit comments