Make use of GetDataDependencyFilepath and JoinPath to build paths which will
work across operating systems. The previous implementation doesn't work correctly on Windows. PiperOrigin-RevId: 296251590 Change-Id: Iac5ad8dbf78d06969a51b9476f66e0b8affdaaa4
This commit is contained in:
parent
95436d6125
commit
1fa03ff291
|
@ -428,6 +428,7 @@ tf_cc_test(
|
||||||
"//tensorflow/core:test_main",
|
"//tensorflow/core:test_main",
|
||||||
"//tensorflow/core/platform:base64",
|
"//tensorflow/core/platform:base64",
|
||||||
"//tensorflow/core/platform:path",
|
"//tensorflow/core/platform:path",
|
||||||
|
"//tensorflow/core/platform:resource_loader",
|
||||||
"//tensorflow/core/platform:scanner",
|
"//tensorflow/core/platform:scanner",
|
||||||
"@boringssl//:crypto",
|
"@boringssl//:crypto",
|
||||||
],
|
],
|
||||||
|
|
|
@ -25,13 +25,16 @@ limitations under the License.
|
||||||
#include "tensorflow/core/platform/cloud/http_request_fake.h"
|
#include "tensorflow/core/platform/cloud/http_request_fake.h"
|
||||||
#include "tensorflow/core/platform/env.h"
|
#include "tensorflow/core/platform/env.h"
|
||||||
#include "tensorflow/core/platform/path.h"
|
#include "tensorflow/core/platform/path.h"
|
||||||
|
#include "tensorflow/core/platform/resource_loader.h"
|
||||||
#include "tensorflow/core/platform/scanner.h"
|
#include "tensorflow/core/platform/scanner.h"
|
||||||
#include "tensorflow/core/platform/test.h"
|
#include "tensorflow/core/platform/test.h"
|
||||||
|
|
||||||
namespace tensorflow {
|
namespace tensorflow {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr char kTestData[] = "core/platform/cloud/testdata/";
|
string TestData() {
|
||||||
|
return io::JoinPath("tensorflow", "core", "platform", "cloud", "testdata");
|
||||||
|
}
|
||||||
|
|
||||||
constexpr char kTokenJson[] = R"(
|
constexpr char kTokenJson[] = R"(
|
||||||
{
|
{
|
||||||
|
@ -92,9 +95,8 @@ TEST(OAuthClientTest, GetTokenFromRefreshTokenJson) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(OAuthClientTest, GetTokenFromServiceAccountJson) {
|
TEST(OAuthClientTest, GetTokenFromServiceAccountJson) {
|
||||||
std::ifstream credentials(
|
std::ifstream credentials(GetDataDependencyFilepath(
|
||||||
io::JoinPath(io::JoinPath(testing::TensorFlowSrcRoot(), kTestData),
|
io::JoinPath(TestData(), "service_account_credentials.json")));
|
||||||
"service_account_credentials.json"));
|
|
||||||
ASSERT_TRUE(credentials.is_open());
|
ASSERT_TRUE(credentials.is_open());
|
||||||
Json::Value json;
|
Json::Value json;
|
||||||
Json::Reader reader;
|
Json::Reader reader;
|
||||||
|
@ -135,9 +137,8 @@ TEST(OAuthClientTest, GetTokenFromServiceAccountJson) {
|
||||||
// Check that 'signature' signs 'header_dot_claim'.
|
// Check that 'signature' signs 'header_dot_claim'.
|
||||||
|
|
||||||
// Read the serialized public key.
|
// Read the serialized public key.
|
||||||
std::ifstream public_key_stream(
|
std::ifstream public_key_stream(GetDataDependencyFilepath(
|
||||||
io::JoinPath(io::JoinPath(testing::TensorFlowSrcRoot(), kTestData),
|
io::JoinPath(TestData(), "service_account_public_key.txt")));
|
||||||
"service_account_public_key.txt"));
|
|
||||||
string public_key_serialized(
|
string public_key_serialized(
|
||||||
(std::istreambuf_iterator<char>(public_key_stream)),
|
(std::istreambuf_iterator<char>(public_key_stream)),
|
||||||
(std::istreambuf_iterator<char>()));
|
(std::istreambuf_iterator<char>()));
|
||||||
|
|
Loading…
Reference in New Issue