mirror of https://github.com/grpc/grpc-node.git
Update google-auth-library in interop tests
This commit is contained in:
parent
cb0792818c
commit
aff61540bc
|
|
@ -22,7 +22,7 @@ var fs = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var grpc = require('../any_grpc').client;
|
var grpc = require('../any_grpc').client;
|
||||||
var protoLoader = require('../../packages/proto-loader');
|
var protoLoader = require('../../packages/proto-loader');
|
||||||
var GoogleAuth = require('google-auth-library');
|
var GoogleAuth = require('google-auth-library').GoogleAuth;
|
||||||
|
|
||||||
var protoPackage = protoLoader.loadSync(
|
var protoPackage = protoLoader.loadSync(
|
||||||
'src/proto/grpc/testing/test.proto',
|
'src/proto/grpc/testing/test.proto',
|
||||||
|
|
@ -463,17 +463,14 @@ function oauth2Test(client, done, extra) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function perRpcAuthTest(client, done, extra) {
|
function perRpcAuthTest(client, done, extra) {
|
||||||
(new GoogleAuth()).getApplicationDefault(function(err, credential) {
|
const auth = new GoogleAuth({scopes: extra.oauth_scope});
|
||||||
|
auth.getClient().then(authClient => {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
var arg = {
|
var arg = {
|
||||||
fill_username: true,
|
fill_username: true,
|
||||||
fill_oauth_scope: true
|
fill_oauth_scope: true
|
||||||
};
|
};
|
||||||
var scope = extra.oauth_scope;
|
var creds = grpc.credentials.createFromGoogleCredential(authClient);
|
||||||
if (credential.createScopedRequired() && scope) {
|
|
||||||
credential = credential.createScoped(scope);
|
|
||||||
}
|
|
||||||
var creds = grpc.credentials.createFromGoogleCredential(credential);
|
|
||||||
client.unaryCall(arg, {credentials: creds}, function(err, resp) {
|
client.unaryCall(arg, {credentials: creds}, function(err, resp) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
assert.strictEqual(resp.username, SERVICE_ACCOUNT_EMAIL);
|
assert.strictEqual(resp.username, SERVICE_ACCOUNT_EMAIL);
|
||||||
|
|
@ -482,41 +479,31 @@ function perRpcAuthTest(client, done, extra) {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}, error => {
|
||||||
|
assert.fail(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getApplicationCreds(scope, callback) {
|
function getApplicationCreds(scope, callback) {
|
||||||
(new GoogleAuth()).getApplicationDefault(function(err, credential) {
|
const auth = new GoogleAuth({scopes: scope});
|
||||||
if (err) {
|
auth.getClient().then(client => {
|
||||||
callback(err);
|
callback(grpc.credentials.createFromGoogleCredential(client));
|
||||||
return;
|
}, (error) => {
|
||||||
}
|
assert.fail(error);
|
||||||
if (credential.createScopedRequired() && scope) {
|
|
||||||
credential = credential.createScoped(scope);
|
|
||||||
}
|
|
||||||
callback(null, grpc.credentials.createFromGoogleCredential(credential));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOauth2Creds(scope, callback) {
|
function getOauth2Creds(scope, callback) {
|
||||||
(new GoogleAuth()).getApplicationDefault(function(err, credential) {
|
const auth = new GoogleAuth({scopes: scope});
|
||||||
if (err) {
|
auth.getClient().then(client => client.getAccessToken()).then((token) => {
|
||||||
callback(err);
|
const updateMd = (service_url, callback) => {
|
||||||
return;
|
const metadata = new grpc.Metadata();
|
||||||
}
|
|
||||||
credential = credential.createScoped(scope);
|
|
||||||
credential.getAccessToken(function(err, token) {
|
|
||||||
if (err) {
|
|
||||||
callback(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var updateMd = function(service_url, callback) {
|
|
||||||
var metadata = new grpc.Metadata();
|
|
||||||
metadata.add('authorization', 'Bearer ' + token);
|
metadata.add('authorization', 'Bearer ' + token);
|
||||||
callback(null, metadata);
|
callback(null, metadata);
|
||||||
};
|
};
|
||||||
callback(null, grpc.credentials.createFromMetadataGenerator(updateMd));
|
callback(null, grpc.credentials.createFromMetadataGenerator(updateMd));
|
||||||
});
|
}).catch(error => {
|
||||||
|
assert.fail(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "^4.16.3",
|
"express": "^4.16.3",
|
||||||
"google-auth-library": "^0.9.2",
|
"google-auth-library": "^5.5.1",
|
||||||
"lodash": "^4.17.4",
|
"lodash": "^4.17.4",
|
||||||
"poisson-process": "^1.0.0"
|
"poisson-process": "^1.0.0"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue