File tree Expand file tree Collapse file tree 4 files changed +66
-20
lines changed
src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage Expand file tree Collapse file tree 4 files changed +66
-20
lines changed Original file line number Diff line number Diff line change 1414 "allure-framework/allure-codeception" : " ~1.3.0" ,
1515 "codeception/codeception" : " ~2.3.4 || ~2.4.0 " ,
1616 "consolidation/robo" : " ^1.0.0" ,
17- "csharpru/vault-php" : " ^3.6 " ,
17+ "csharpru/vault-php" : " ~3.5.3 " ,
1818 "csharpru/vault-php-guzzle6-transport" : " ^2.0" ,
1919 "flow/jsonpath" : " >0.2" ,
2020 "fzaninotto/faker" : " ^1.6" ,
Original file line number Diff line number Diff line change 99use Magento \FunctionalTestingFramework \Config \MftfApplicationConfig ;
1010use Magento \FunctionalTestingFramework \Exceptions \TestFrameworkException ;
1111use Magento \FunctionalTestingFramework \Util \Logger \LoggingUtil ;
12- use Vault \AuthenticationStrategies \TokenAuthenticationStrategy ;
1312use Vault \Client ;
1413use VaultTransports \Guzzle6Transport ;
1514
@@ -111,7 +110,7 @@ private function authenticated()
111110 try {
112111 // Authenticating using token auth backend
113112 $ authenticated = $ this ->client
114- ->setAuthenticationStrategy (new TokenAuthenticationStrategy ($ this ->token ))
113+ ->setAuthenticationStrategy (new VaultTokenAuthStrategy ($ this ->token ))
115114 ->authenticate ();
116115
117116 if ($ authenticated ) {
Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Copyright © Magento, Inc. All rights reserved.
4+ * See COPYING.txt for license details.
5+ */
6+
7+ namespace Magento \FunctionalTestingFramework \DataGenerator \Handlers \SecretStorage ;
8+
9+ use Magento \FunctionalTestingFramework \Exceptions \TestFrameworkException ;
10+ use Vault \AuthenticationStrategies \AbstractAuthenticationStrategy ;
11+ use Vault \ResponseModels \Auth ;
12+
13+ /**
14+ * Class VaultTokenAuthStrategy
15+ */
16+ class VaultTokenAuthStrategy extends AbstractAuthenticationStrategy
17+ {
18+ /**
19+ * @var string
20+ */
21+ protected $ token ;
22+
23+ /**
24+ * VaultTokenAuthStrategy constructor
25+ *
26+ * @param string $token
27+ */
28+ public function __construct ($ token )
29+ {
30+ $ this ->token = $ token ;
31+ }
32+
33+ /**
34+ * Returns auth for further interactions with Vault
35+ *
36+ * @return Auth
37+ * @throws TestFrameworkException
38+ */
39+ public function authenticate ()
40+ {
41+ try {
42+ return new Auth (['clientToken ' => $ this ->token ]);
43+ } catch (\Exception $ e ) {
44+ throw new TestFrameworkException ("Cannot authenticate Vault token. " );
45+ }
46+ }
47+ }
You can’t perform that action at this time.
0 commit comments