unit test for InstanceProfileCredentialsProvider
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -23,11 +23,11 @@
|
||||
#include <string>
|
||||
#include "CredentialsProvider.h"
|
||||
#include "Credentials.h"
|
||||
#include "../src/EcsMetadataFetcher.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class EcsMetadataFetcher;
|
||||
class ALIBABACLOUD_CORE_EXPORT InstanceProfileCredentialsProvider : public CredentialsProvider
|
||||
class ALIBABACLOUD_CORE_EXPORT InstanceProfileCredentialsProvider : public CredentialsProvider, public EcsMetadataFetcher
|
||||
{
|
||||
public:
|
||||
InstanceProfileCredentialsProvider(const std::string &roleName, int durationSeconds = 3600);
|
||||
@@ -35,7 +35,9 @@ namespace AlibabaCloud
|
||||
|
||||
std::string roleName()const;
|
||||
virtual Credentials getCredentials() override;
|
||||
|
||||
using EcsMetadataFetcher::roleName;
|
||||
using EcsMetadataFetcher::setRoleName;
|
||||
using EcsMetadataFetcher::getMetadata;
|
||||
private:
|
||||
void loadCredentials();
|
||||
bool checkExpiry()const;
|
||||
@@ -44,7 +46,6 @@ namespace AlibabaCloud
|
||||
Credentials cachedCredentials_;
|
||||
int durationSeconds_;
|
||||
std::chrono::system_clock::time_point expiry_;
|
||||
EcsMetadataFetcher *fetcher_;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user