add unit test case for ecsmetadata and fix other ut
This commit is contained in:
@@ -22,13 +22,6 @@
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
|
||||
namespace
|
||||
{
|
||||
const int DEFAULT_TIMEOUT_IN_MILLISECONDS = 5000;
|
||||
const char* const METADATA_SERVICE_HOST = "100.100.100.200";
|
||||
const char* const URL_IN_ECS_METADATA = "/latest/meta-data/ram/security-credentials/";
|
||||
}
|
||||
|
||||
EcsMetadataFetcher::EcsMetadataFetcher()
|
||||
{
|
||||
}
|
||||
@@ -47,13 +40,13 @@ void EcsMetadataFetcher::setRoleName(const std::string & roleName)
|
||||
roleName_ = roleName;
|
||||
}
|
||||
|
||||
std::string EcsMetadataFetcher::getMetadata()
|
||||
std::string EcsMetadataFetcher::getMetadata(const std::string host, const std::string in_path)
|
||||
{
|
||||
std::stringstream path;
|
||||
path << URL_IN_ECS_METADATA << roleName_;
|
||||
path << in_path << roleName_;
|
||||
|
||||
Url credentialUrl;
|
||||
credentialUrl.setHost(METADATA_SERVICE_HOST);
|
||||
credentialUrl.setHost(host);
|
||||
credentialUrl.setPath(path.str());
|
||||
|
||||
auto client = std::make_shared<CurlHttpClient>();
|
||||
|
||||
@@ -19,6 +19,12 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace {
|
||||
const int DEFAULT_TIMEOUT_IN_MILLISECONDS = 5000;
|
||||
const char* const METADATA_SERVICE_HOST = "100.100.100.200";
|
||||
const char* const URL_IN_ECS_METADATA = "/latest/meta-data/ram/security-credentials/";
|
||||
}
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class EcsMetadataFetcher
|
||||
@@ -29,8 +35,7 @@ namespace AlibabaCloud
|
||||
|
||||
std::string roleName()const;
|
||||
void setRoleName(const std::string & roleName);
|
||||
|
||||
std::string getMetadata();
|
||||
std::string getMetadata(const std::string host = METADATA_SERVICE_HOST, const std::string path = URL_IN_ECS_METADATA);
|
||||
private:
|
||||
std::string roleName_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user