Skip to content

Commit

Permalink
pubsub: set sslCreds when apiEndpoint is used (#2583)
Browse files Browse the repository at this point in the history
  • Loading branch information
callmehiphop authored and stephenplusplus committed Sep 7, 2017
1 parent 49c4cd4 commit 5c8973e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/pubsub/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
var common = require('@google-cloud/common');
var extend = require('extend');
var googleAuth = require('google-auto-auth');
var grpc = require('grpc');
var is = require('is');

var PKG = require('../package.json');
Expand Down Expand Up @@ -291,6 +292,7 @@ PubSub.prototype.determineBaseUrl_ = function() {

this.options.servicePath = baseUrlParts[0];
this.options.port = baseUrlParts[1];
this.options.sslCreds = grpc.credentials.createInsecure();
};

/**
Expand Down
10 changes: 10 additions & 0 deletions packages/pubsub/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
var arrify = require('arrify');
var assert = require('assert');
var extend = require('extend');
var grpc = require('grpc');
var proxyquire = require('proxyquire');
var util = require('@google-cloud/common').util;

var PKG = require('../package.json');
var v1 = require('../src/v1/index.js');

var fakeGrpc = extend({}, grpc);

var SubscriptionCached = require('../src/subscription.js');
var SubscriptionOverride;

Expand Down Expand Up @@ -122,6 +125,7 @@ describe('PubSub', function() {
util: fakeUtil
},
'google-auto-auth': fakeGoogleAutoAuth,
grpc: fakeGrpc,
'./snapshot.js': FakeSnapshot,
'./subscription.js': Subscription,
'./topic.js': FakeTopic,
Expand Down Expand Up @@ -604,12 +608,18 @@ describe('PubSub', function() {
var defaultBaseUrl_ = 'defaulturl';
var testingUrl = 'localhost:8085';

var fakeCreds = {};
fakeGrpc.credentials.createInsecure = function() {
return fakeCreds;
};

setHost(defaultBaseUrl_);
pubsub.options.apiEndpoint = testingUrl;
pubsub.determineBaseUrl_();

assert.strictEqual(pubsub.options.servicePath, 'localhost');
assert.strictEqual(pubsub.options.port, '8085');
assert.strictEqual(pubsub.options.sslCreds, fakeCreds);
});

it('should remove slashes from the baseUrl', function() {
Expand Down

0 comments on commit 5c8973e

Please sign in to comment.