parent
9e710c2f92
commit
9b06fc8f33
@ -96,6 +96,7 @@ jobs:
|
||||
CMOCKA_XML_FILE: "%g-test-results.xml"
|
||||
CMOCKA_MESSAGE_OUTPUT: "xml"
|
||||
AZURE_ENABLE_STATIC_ANALYSIS: 1
|
||||
AZURE_KEYVAULT_AVOID_THROTTLED: 1
|
||||
|
||||
steps:
|
||||
- checkout: self
|
||||
|
||||
@ -19,7 +19,6 @@
|
||||
|
||||
#include <azure/core.hpp>
|
||||
#include <azure/identity.hpp>
|
||||
#include <azure/keyvault/common/sha.hpp>
|
||||
#include <azure/keyvault/key_vault_keys.hpp>
|
||||
|
||||
#include <chrono>
|
||||
@ -60,13 +59,15 @@ int main()
|
||||
|
||||
CryptographyClient ecCryptoClient(cloudEcKey.Id(), credential);
|
||||
|
||||
// digestBase64 simulates some text data that has been hashed using the SHA256 algorithm
|
||||
uint8_t const dataSource[]
|
||||
= "This is some sample data which we will use to demonstrate sign and verify";
|
||||
std::vector<uint8_t> data(std::begin(dataSource), std::end(dataSource));
|
||||
|
||||
// digestRaw simulates some text data that has been hashed using the SHA256 algorithm
|
||||
// and then base 64 encoded. It is not relevant for the sample how to create the SHA256
|
||||
// hashed digest.
|
||||
// Example input data source for the digest:
|
||||
// "This is some sample data which we will use to demonstrate sign and verify"
|
||||
std::string digestBase64 = "DU9EdhpwhJqnGnieD0qKYEz6e8QPKlOVpYZZro+XtI8=";
|
||||
std::vector<uint8_t> digest = Azure::Core::Convert::Base64Decode(digestBase64);
|
||||
std::vector<uint8_t> digest
|
||||
= Azure::Core::Convert::Base64Decode("DU9EdhpwhJqnGnieD0qKYEz6e8QPKlOVpYZZro");
|
||||
|
||||
// Sign and Verify from digest
|
||||
SignResult rsaSignResult = rsaCryptoClient.Sign(SignatureAlgorithm::RS256, digest);
|
||||
|
||||
@ -19,7 +19,6 @@
|
||||
|
||||
#include <azure/core.hpp>
|
||||
#include <azure/identity.hpp>
|
||||
#include <azure/keyvault/common/sha.hpp>
|
||||
#include <azure/keyvault/key_vault_keys.hpp>
|
||||
|
||||
#include <chrono>
|
||||
|
||||
@ -13,21 +13,29 @@
|
||||
#include <azure/identity/client_secret_credential.hpp>
|
||||
#include <azure/keyvault/key_vault_keys.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
namespace Azure { namespace Security { namespace KeyVault { namespace Keys { namespace Test {
|
||||
|
||||
class KeyVaultClientTest : public ::testing::TestWithParam<int> {
|
||||
private:
|
||||
std::string GetEnv(const std::string& name)
|
||||
std::string GetEnv(const std::string& name, std::string const& defaultValue = std::string())
|
||||
{
|
||||
const char* ret = std::getenv(name.data());
|
||||
if (!ret)
|
||||
{
|
||||
if (defaultValue.size() > 0)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
throw std::runtime_error(
|
||||
name + " is required to run the tests but not set as an environment variable.");
|
||||
}
|
||||
|
||||
return std::string(ret);
|
||||
}
|
||||
|
||||
@ -48,6 +56,18 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys { nam
|
||||
|
||||
m_keyVaultUrl = GetEnv("AZURE_KEYVAULT_URL");
|
||||
m_keyVaultHsmUrl = GetEnv("AZURE_KEYVAULT_HSM_URL");
|
||||
|
||||
// When running live tests, service can return 429 error response if the client is sending
|
||||
// multiple requests per second. This can happen if the network is fast and tests are running
|
||||
// without any delay between them.
|
||||
auto avoidTestThrottled = GetEnv("AZURE_KEYVAULT_AVOID_THROTTLED", "0");
|
||||
|
||||
if (avoidTestThrottled != "0")
|
||||
{
|
||||
std::cout << "- Wait to avoid server throttled..." << std::endl;
|
||||
// 10 sec should be enough to prevent from 429 error
|
||||
std::this_thread::sleep_for(std::chrono::seconds(10));
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@ -34,7 +34,8 @@ stages:
|
||||
parameters:
|
||||
ServiceDirectory: keyvault
|
||||
CtestRegex: "azure-security-keyvault.*-unittest"
|
||||
LiveTestCtestRegex: "azure-security-keyvault.*-livetest"
|
||||
LiveTestCtestRegex: "Remote"
|
||||
LiveTestTimeoutInMinutes: 120
|
||||
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources)
|
||||
Artifacts:
|
||||
- Name: azure-security-keyvault-common
|
||||
|
||||
Loading…
Reference in New Issue
Block a user