6
6
namespace Magento \Analytics \Api ;
7
7
8
8
use Magento \Framework \UrlInterface ;
9
+ use Magento \Framework \Webapi \Rest \Request ;
9
10
use Magento \TestFramework \TestCase \WebapiAbstract ;
10
11
11
12
/**
@@ -47,15 +48,28 @@ public function testGetAll()
47
48
48
49
$ serviceInfo = [
49
50
'rest ' => [
50
- 'resourcePath ' => self ::RESOURCE_PATH ,
51
- 'httpMethod ' => \ Magento \ Framework \ Webapi \ Rest \ Request::HTTP_METHOD_GET ,
51
+ 'resourcePath ' => static ::RESOURCE_PATH ,
52
+ 'httpMethod ' => Request::HTTP_METHOD_GET ,
52
53
],
53
54
'soap ' => [
54
- 'service ' => self ::SERVICE_NAME ,
55
+ 'service ' => static ::SERVICE_NAME ,
55
56
'serviceVersion ' => self ::SERVICE_VERSION ,
56
- 'operation ' => self ::SERVICE_NAME . 'Get ' ,
57
+ 'operation ' => static ::SERVICE_NAME . 'Get ' ,
57
58
],
58
59
];
60
+ if (!$ this ->isTestBaseUrlSecure ()) {
61
+ try {
62
+ $ this ->_webApiCall ($ serviceInfo );
63
+ } catch (\Exception $ e ) {
64
+ $ this ->assertEquals (
65
+ '{"message":"Operation allowed only in HTTPS"} ' ,
66
+ $ e ->getMessage ()
67
+ );
68
+ return ;
69
+ }
70
+ $ this ->fail ("Exception 'Operation allowed only in HTTPS' should be thrown " );
71
+ }
72
+
59
73
$ response = $ this ->_webApiCall ($ serviceInfo );
60
74
$ this ->assertEquals (2 , count ($ response ));
61
75
$ this ->assertEquals (base64_encode ($ fileInfo ->getInitializationVector ()), $ response ['initialization_vector ' ]);
@@ -66,4 +80,12 @@ public function testGetAll()
66
80
$ response ['url ' ]
67
81
);
68
82
}
83
+
84
+ /**
85
+ * @return bool
86
+ */
87
+ private function isTestBaseUrlSecure ()
88
+ {
89
+ return strpos ('https:// ' , TESTS_BASE_URL ) !== false ;
90
+ }
69
91
}
0 commit comments