mirror of
https://github.com/grpc/grpc-node.git
synced 2026-02-01 14:54:35 +00:00
tests: Update google-auth-library dependency from 0.9 to 6.1
This commit is contained in:
parent
a5cc154c8e
commit
89a030c00a
@ -22,7 +22,8 @@ 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');
|
|
||||||
|
const { GoogleAuth } = require('google-auth-library');
|
||||||
|
|
||||||
var protoPackage = protoLoader.loadSync(
|
var protoPackage = protoLoader.loadSync(
|
||||||
'src/proto/grpc/testing/test.proto',
|
'src/proto/grpc/testing/test.proto',
|
||||||
@ -463,60 +464,31 @@ function oauth2Test(client, done, extra) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function perRpcAuthTest(client, done, extra) {
|
function perRpcAuthTest(client, done, extra) {
|
||||||
(new GoogleAuth()).getApplicationDefault(function(err, credential) {
|
const creds = grpc.credentials.createFromGoogleCredential(new GoogleAuth({scopes: extra.oauth_scope}));
|
||||||
|
client.unaryCall(arg, {credentials: creds}, function(err, resp) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
var arg = {
|
assert.strictEqual(resp.username, SERVICE_ACCOUNT_EMAIL);
|
||||||
fill_username: true,
|
assert(extra.oauth_scope.indexOf(resp.oauth_scope) > -1);
|
||||||
fill_oauth_scope: true
|
if (done) {
|
||||||
};
|
done();
|
||||||
var scope = extra.oauth_scope;
|
|
||||||
if (credential.createScopedRequired() && scope) {
|
|
||||||
credential = credential.createScoped(scope);
|
|
||||||
}
|
}
|
||||||
var creds = grpc.credentials.createFromGoogleCredential(credential);
|
|
||||||
client.unaryCall(arg, {credentials: creds}, function(err, resp) {
|
|
||||||
assert.ifError(err);
|
|
||||||
assert.strictEqual(resp.username, SERVICE_ACCOUNT_EMAIL);
|
|
||||||
assert(extra.oauth_scope.indexOf(resp.oauth_scope) > -1);
|
|
||||||
if (done) {
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getApplicationCreds(scope, callback) {
|
function getApplicationCreds(scope, callback) {
|
||||||
(new GoogleAuth()).getApplicationDefault(function(err, credential) {
|
callback(null, grpc.credentials.createFromGoogleCredential(new GoogleAuth({scopes: scope})));
|
||||||
if (err) {
|
|
||||||
callback(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
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) {
|
(new GoogleAuth()).getAccessToken().then((token) => {
|
||||||
if (err) {
|
var updateMd = function(service_url, callback) {
|
||||||
callback(err);
|
var metadata = new grpc.Metadata();
|
||||||
return;
|
metadata.add('authorization', 'Bearer ' + token);
|
||||||
}
|
callback(null, metadata);
|
||||||
credential = credential.createScoped(scope);
|
};
|
||||||
credential.getAccessToken(function(err, token) {
|
callback(null, grpc.credentials.createFromMetadataGenerator(updateMd));
|
||||||
if (err) {
|
}, (error) => {
|
||||||
callback(err);
|
callback(error);
|
||||||
return;
|
|
||||||
}
|
|
||||||
var updateMd = function(service_url, callback) {
|
|
||||||
var metadata = new grpc.Metadata();
|
|
||||||
metadata.add('authorization', 'Bearer ' + token);
|
|
||||||
callback(null, metadata);
|
|
||||||
};
|
|
||||||
callback(null, grpc.credentials.createFromMetadataGenerator(updateMd));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "^4.16.3",
|
"express": "^4.16.3",
|
||||||
"google-auth-library": "^0.9.2",
|
"google-auth-library": "^6.1.0",
|
||||||
"grpc": "^1.24.2",
|
"grpc": "^1.24.2",
|
||||||
"lodash": "^4.17.4",
|
"lodash": "^4.17.4",
|
||||||
"poisson-process": "^1.0.0"
|
"poisson-process": "^1.0.0"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user