File tree Expand file tree Collapse file tree 6 files changed +59
-19
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 +59
-19
lines changed Original file line number Diff line number Diff line change 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,11 @@ 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+ this . redirectTo ( url . build ( 'customer/account/login/' ) , 2000 ) ;
2832 } else {
2933 try {
3034 error = JSON . parse ( response . responseText ) ;
@@ -40,8 +44,10 @@ define([
4044 /**
4145 * Method to redirect by requested URL.
4246 */
43- redirectTo : function ( redirectUrl ) {
44- window . location . replace ( redirectUrl ) ;
47+ redirectTo : function ( redirectUrl , delay = 0 ) {
48+ setTimeout ( ( ) => {
49+ window . location . replace ( redirectUrl ) ;
50+ } , delay ) ;
4551 }
4652 } ;
4753} ) ;
Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change 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" >
Original file line number Diff line number Diff line change 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"
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 >
Original file line number Diff line number Diff line change 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 */
66namespace Magento \Quote \Api ;
77
1111
1212class 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
Original file line number Diff line number Diff line change 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 } ) ;
You can’t perform that action at this time.
0 commit comments