Skip to content

Commit 3f7fe82

Browse files
committed
MQE-1600: MFTF Vault integration
- Downgrade vault php version to be compatible to php 7.0
1 parent 36c5865 commit 3f7fe82

File tree

4 files changed

+66
-20
lines changed

4 files changed

+66
-20
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
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",

composer.lock

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/VaultStorage.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig;
1010
use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException;
1111
use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil;
12-
use Vault\AuthenticationStrategies\TokenAuthenticationStrategy;
1312
use Vault\Client;
1413
use 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) {
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
}

0 commit comments

Comments
 (0)