diff --git a/README.md b/README.md index 7e1e5336b5f..6d48d6f5e72 100644 --- a/README.md +++ b/README.md @@ -34,16 +34,16 @@ $ npm install --save gcloud - [gcloud-kvstore][gcloud-kvstore] - Use Datastore as a simple key-value store. - [hya-wave][hya-wave] - Cloud-based web sample editor. Part of the [hya-io][hya-io] family of products. -## Authorization +## Authentication -With `gcloud-node` it's incredibly easy to get authorized and start using Google's APIs. You can set your credentials on a global basis as well as on a per-API basis. See each individual API section below to see how you can auth on a per-API-basis. This is useful if you want to use different accounts for different Google Cloud services. +With `gcloud-node` it's incredibly easy to get authenticated and start using Google's APIs. You can set your credentials on a global basis as well as on a per-API basis. See each individual API section below to see how you can auth on a per-API-basis. This is useful if you want to use different accounts for different Google Cloud services. ### On Google Compute Engine -If you are running this client on Google Compute Engine, we handle authorization for you with no configuration. You just need to make sure that when you [set up the GCE instance][gce-how-to], you add the correct scopes for the APIs you want to access. +If you are running this client on Google Compute Engine, we handle authentication for you with no configuration. You just need to make sure that when you [set up the GCE instance][gce-how-to], you add the correct scopes for the APIs you want to access. ``` js -// Authorizing on a global basis. +// Authenticating on a global basis. var projectId = process.env.GCLOUD_PROJECT_ID; // E.g. 'grape-spaceship-123' var gcloud = require('gcloud')({ projectId: projectId @@ -63,11 +63,11 @@ If you are not running this client on Google Compute Engine, you need a Google D * Google Cloud Storage * Google Cloud Storage JSON API 4. Navigate to **APIs & auth** > **Credentials** and then: - * If you want to use a new service account, click on **Create new Client ID** and select **Service account**. After the account is created, you will be prompted to download the JSON key file that the library uses to authorize your requests. + * If you want to use a new service account, click on **Create new Client ID** and select **Service account**. After the account is created, you will be prompted to download the JSON key file that the library uses to authenticate your requests. * If you want to generate a new key for an existing service account, click on **Generate new JSON key** and download the JSON key file. ``` js -// Authorizing on a global basis. +// Authenticating on a global basis. var projectId = process.env.GCLOUD_PROJECT_ID; // E.g. 'grape-spaceship-123' var gcloud = require('gcloud')({ @@ -91,8 +91,8 @@ You can also set auth on a per-API-instance basis. The examples below show you h ```js var gcloud = require('gcloud'); -// Authorizing on a per-API-basis. You don't need to do this if you auth on a -// global basis (see Authorization section above). +// Authenticating on a per-API-basis. You don't need to do this if you auth on a +// global basis (see Authentication section above). var bigquery = gcloud.bigquery({ projectId: 'my-project', keyFilename: '/path/to/keyfile.json' @@ -127,8 +127,8 @@ job.getQueryResults().on('data', function(row) {}); ```js var gcloud = require('gcloud'); -// Authorizing on a per-API-basis. You don't need to do this if you auth on a -// global basis (see Authorization section above). +// Authenticating on a per-API-basis. You don't need to do this if you auth on a +// global basis (see Authentication section above). var dataset = gcloud.datastore.dataset({ projectId: 'my-project', @@ -178,8 +178,8 @@ dataset.save({ ```js var gcloud = require('gcloud'); -// Authorizing on a per-API-basis. You don't need to do this if you auth on a -// global basis (see Authorization section above). +// Authenticating on a per-API-basis. You don't need to do this if you auth on a +// global basis (see Authentication section above). var dns = gcloud.dns({ projectId: 'my-project', @@ -218,8 +218,8 @@ zone.export('/zonefile.zone', function(err) {}); ```js var gcloud = require('gcloud'); -// Authorizing on a per-API-basis. You don't need to do this if you -// auth on a global basis (see Authorization section above). +// Authenticating on a per-API-basis. You don't need to do this if you +// auth on a global basis (see Authentication section above). var pubsub = gcloud.pubsub({ projectId: 'my-project', @@ -261,8 +261,8 @@ topic.subscribe('new-subscription', function(err, subscription) { var fs = require('fs'); var gcloud = require('gcloud'); -// Authorizing on a per-API-basis. You don't need to do this if you auth on a -// global basis (see Authorization section above). +// Authenticating on a per-API-basis. You don't need to do this if you auth on a +// global basis (see Authentication section above). var gcs = gcloud.storage({ projectId: 'my-project', @@ -312,8 +312,8 @@ localReadStream.pipe(remoteWriteStream); ```js var gcloud = require('gcloud'); -// Authorizing on a per-API-basis. You don't need to do this if you auth on a -// global basis (see Authorization section above). +// Authenticating on a per-API-basis. You don't need to do this if you auth on a +// global basis (see Authentication section above). var gce = gcloud.compute({ projectId: 'my-project', @@ -384,8 +384,8 @@ project.getMetadata(function(err, metadata) { ```js var gcloud = require('gcloud'); -// Authorizing on a per-API-basis. You don't need to do this if you auth on a -// global basis (see Authorization section above). +// Authenticating on a per-API-basis. You don't need to do this if you auth on a +// global basis (see Authentication section above). var search = gcloud.search({ projectId: 'my-project', diff --git a/docs/authorization.md b/docs/authentication.md similarity index 69% rename from docs/authorization.md rename to docs/authentication.md index 1a9e149f7a7..468b5aaa598 100644 --- a/docs/authorization.md +++ b/docs/authentication.md @@ -1,6 +1,6 @@ ## With `gcloud-node` -With `gcloud-node` it's incredibly easy to get authorized and start using Google's APIs. You can set your credentials on a global basis as well as on a per-API basis. See each individual API section below to see how you can auth on a per-API-basis. This is useful if you want to use different accounts for different Google Cloud services. +With `gcloud-node` it's incredibly easy to get authenticated and start using Google's APIs. You can set your credentials on a global basis as well as on a per-API basis. See each individual API section below to see how you can auth on a per-API-basis. This is useful if you want to use different accounts for different Google Cloud services. ```hljs-class var config = { diff --git a/docs/faq.md b/docs/faq.md index beaf7908523..44f5c505074 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -1,10 +1,10 @@ ## How do I use `gcloud` with Google Compute Engine? -If you are running this client on Google Compute Engine, we handle authorization for you with no configuration. You just need to make sure that when you [set up the GCE instance][gce-how-to], you add the correct scopes for the APIs you want to access. +If you are running this client on Google Compute Engine, we handle authentication for you with no configuration. You just need to make sure that when you [set up the GCE instance][gce-how-to], you add the correct scopes for the APIs you want to access. ## I'm not using Compute Engine. What do I need to do? -If you are not running this client on Google Compute Engine, you need a Google Developers service account. To create a service account, please see our [Authorization][auth-guide] guide. +If you are not running this client on Google Compute Engine, you need a Google Developers service account. To create a service account, please see our [Authentication][auth-guide] guide. ## Does this replace [Google Cloud Node.js Client][googleapis]? @@ -13,4 +13,4 @@ Google Cloud Node.js Client is a client library for using the broad set of Googl [dev-console]: https://console.developers.google.com/project [gce-how-to]: https://developers.google.com/compute/docs/authentication#using [googleapis]: https://github.com/google/google-api-nodejs-client -[auth-guide]: #/authorization +[auth-guide]: #/authentication diff --git a/docs/index.html b/docs/index.html index ab91e64d5f4..7ccee7fe3cb 100755 --- a/docs/index.html +++ b/docs/index.html @@ -36,7 +36,7 @@ - + diff --git a/docs/site/components/authorization/authorization.html b/docs/site/components/authentication/authentication.html similarity index 54% rename from docs/site/components/authorization/authorization.html rename to docs/site/components/authentication/authentication.html index be36048a1db..fd7d64acdd7 100644 --- a/docs/site/components/authorization/authorization.html +++ b/docs/site/components/authentication/authentication.html @@ -1,8 +1,8 @@ -
+ header-templateUrl="authentication-header.html" + title="Authentication">
+ gcloud-markdown="https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/readme.md">
-
+
diff --git a/docs/site/components/authentication/authentication.js b/docs/site/components/authentication/authentication.js new file mode 100644 index 00000000000..16ef14a0030 --- /dev/null +++ b/docs/site/components/authentication/authentication.js @@ -0,0 +1,16 @@ +angular + .module('gcloud.authentication', ['ngRoute', 'gcloud.subpage', 'gcloud.markdown']) + .config(function($routeProvider) { + 'use strict'; + + $routeProvider.when('/authentication', { + controller: 'AuthenticationCtrl', + templateUrl: 'site/components/authentication/authentication.html', + reloadOnSearch: false + }); + }) + + .controller('AuthenticationCtrl', function($scope) { + 'use strict'; + + }); diff --git a/docs/site/components/authorization/authorization.js b/docs/site/components/authorization/authorization.js deleted file mode 100644 index 172c2e007f4..00000000000 --- a/docs/site/components/authorization/authorization.js +++ /dev/null @@ -1,16 +0,0 @@ -angular - .module('gcloud.authorization', ['ngRoute', 'gcloud.subpage', 'gcloud.markdown']) - .config(function($routeProvider) { - 'use strict'; - - $routeProvider.when('/authorization', { - controller: 'AuthorizationCtrl', - templateUrl: 'site/components/authorization/authorization.html', - reloadOnSearch: false - }); - }) - - .controller('AuthorizationCtrl', function($scope) { - 'use strict'; - - }); diff --git a/docs/site/components/docs/docs.html b/docs/site/components/docs/docs.html index 214ea44b7de..187d6aa776a 100644 --- a/docs/site/components/docs/docs.html +++ b/docs/site/components/docs/docs.html @@ -39,7 +39,7 @@

keyFilename: '/path/to/keyfile.json' });

- The full set of options which can be passed to gcloud and sub-modules are outlined here. + The full set of options which can be passed to gcloud and sub-modules are outlined here.


diff --git a/docs/site/components/language-switcher/language-switcher.html b/docs/site/components/language-switcher/language-switcher.html index c04be040b82..50221f09ef8 100644 --- a/docs/site/components/language-switcher/language-switcher.html +++ b/docs/site/components/language-switcher/language-switcher.html @@ -7,8 +7,8 @@

Getting Started

  • - - Authorization + + Authentication
  • diff --git a/docs/site/home.html b/docs/site/home.html index 202dad40e68..d4eec3f2328 100755 --- a/docs/site/home.html +++ b/docs/site/home.html @@ -76,7 +76,7 @@

    What is it?

    to you.

    gcloud is configured to access Google Cloud Platform - services and authorize (OAuth 2.0) automatically on your behalf. + services and authenticate (OAuth 2.0) automatically on your behalf. With a one-line install and a private key, you are up and ready to go. Better yet, if you are running on a Google Compute Engine instance, the one-line install is enough!

    diff --git a/docs/site/home.js b/docs/site/home.js index 026d05e30fb..041e33d7407 100644 --- a/docs/site/home.js +++ b/docs/site/home.js @@ -1,7 +1,7 @@ angular .module('gcloud', [ 'ngRoute', - 'gcloud.authorization', + 'gcloud.authentication', 'gcloud.docs', 'gcloud.faq', 'gcloud.contributing', diff --git a/lib/bigquery/index.js b/lib/bigquery/index.js index 45786c8e8b4..f6ff063e7f6 100644 --- a/lib/bigquery/index.js +++ b/lib/bigquery/index.js @@ -100,7 +100,7 @@ function BigQuery(options) { return new BigQuery(options); } - this.makeAuthorizedRequest_ = util.makeAuthorizedRequestFactory({ + this.makeAuthenticatedRequest_ = util.makeAuthenticatedRequestFactory({ credentials: options.credentials, keyFile: options.keyFilename, scopes: SCOPES, @@ -622,7 +622,7 @@ BigQuery.prototype.makeReq_ = function(method, path, query, body, callback) { reqOpts.json = body; } - this.makeAuthorizedRequest_(reqOpts, callback); + this.makeAuthenticatedRequest_(reqOpts, callback); }; /*! Developer Documentation diff --git a/lib/bigquery/table.js b/lib/bigquery/table.js index 3bf10e86cbf..c0a21e95026 100644 --- a/lib/bigquery/table.js +++ b/lib/bigquery/table.js @@ -311,7 +311,7 @@ Table.prototype.createWriteStream = function(metadata) { dup.once('writing', function() { util.makeWritableStream(dup, { - makeAuthorizedRequest: that.bigQuery.makeAuthorizedRequest_, + makeAuthenticatedRequest: that.bigQuery.makeAuthenticatedRequest_, metadata: { configuration: { load: metadata diff --git a/lib/common/util.js b/lib/common/util.js index 585a5c1d363..f558dcb93c3 100644 --- a/lib/common/util.js +++ b/lib/common/util.js @@ -44,8 +44,8 @@ var util = module.exports; var missingProjectIdError = new Error([ 'Sorry, we cannot connect to Google Cloud Services without a project ID.', - 'See https://googlecloudplatform.github.io/gcloud-node/#/authorization for', - 'a detailed guide on creating an authorized connection.' + 'See https://googlecloudplatform.github.io/gcloud-node/#/authentication for', + 'a detailed guide on creating an authenticated connection.' ].join(' ')); util.missingProjectIdError = missingProjectIdError; @@ -193,8 +193,8 @@ function parseApiResp(err, resp, body) { util.parseApiResp = parseApiResp; /** - * Take a Duplexify stream, fetch an authorized connection header, and create an - * outgoing writable stream. + * Take a Duplexify stream, fetch an authenticated connection header, and create + * an outgoing writable stream. * * @param {Duplexify} dup - Duplexify stream. * @param {object} options - Configuration object. @@ -240,14 +240,14 @@ function makeWritableStream(dup, options, onComplete) { ] }); - options.makeAuthorizedRequest(reqOpts, { - onAuthorized: function(err, authorizedReqOpts) { + options.makeAuthenticatedRequest(reqOpts, { + onAuthenticated: function(err, authenticatedReqOpts) { if (err) { dup.destroy(err); return; } - request(authorizedReqOpts, function(err, resp, body) { + request(authenticatedReqOpts, function(err, resp, body) { util.handleResp(err, resp, body, function(err, data) { if (err) { dup.destroy(err); @@ -295,7 +295,7 @@ function shouldRetryRequest(err) { util.shouldRetryRequest = shouldRetryRequest; /** - * Get a function for making authorized requests. + * Get a function for making authenticated requests. * * @param {object} config - Configuration object. * @param {boolean=} config.autoRetry - Automatically retry requests if the @@ -312,22 +312,22 @@ util.shouldRetryRequest = shouldRetryRequest; * @param {string=} config.keyFile - Path to a .json, .pem, or .p12 keyfile. * @param {array} config.scopes - Array of scopes required for the API. */ -function makeAuthorizedRequestFactory(config) { +function makeAuthenticatedRequestFactory(config) { config = config || {}; var authClient = googleAuth(config); /** - * The returned function that will make an authorized request. + * The returned function that will make an authenticated request. * * @param {type} reqOpts - Request options in the format `request` expects. * @param {object|function} options - Configuration object or callback * function. - * @param {function=} options.onAuthorized - If provided, a request will not - * be made. Instead, this function is passed the error & authorized + * @param {function=} options.onAuthenticated - If provided, a request will + * not be made. Instead, this function is passed the error & authenticated * request options. */ - function makeAuthorizedRequest(reqOpts, options) { + function makeAuthenticatedRequest(reqOpts, options) { var stream; var reqConfig = extend({}, config); @@ -336,38 +336,38 @@ function makeAuthorizedRequestFactory(config) { reqConfig.stream = stream; } - function onAuthorized(err, authorizedReqOpts) { + function onAuthenticated(err, authenticatedReqOpts) { // google-auth-library returns a "Could not load..." error if it can't get // an access token. However, it's possible an API request doesn't need to // be authenticated, e.g. when downloading a file from a public bucket. We // consider this error a warning, and allow the request to go through - // without authorization, relying on the upstream API to return an error + // without authentication, relying on the upstream API to return an error // the user would find more helpful, should one occur. if (err && err.message.indexOf('Could not load') === -1) { if (stream) { stream.destroy(err); } else { - (options.onAuthorized || options)(err); + (options.onAuthenticated || options)(err); } return; } - authorizedReqOpts = util.decorateRequest(authorizedReqOpts); + authenticatedReqOpts = util.decorateRequest(authenticatedReqOpts); - if (options && options.onAuthorized) { - options.onAuthorized(null, authorizedReqOpts); + if (options && options.onAuthenticated) { + options.onAuthenticated(null, authenticatedReqOpts); } else { - util.makeRequest(authorizedReqOpts, reqConfig, options); + util.makeRequest(authenticatedReqOpts, reqConfig, options); } } if (reqConfig.customEndpoint) { // Using a custom API override. Do not use `google-auto-auth` for // authentication. (ex: connecting to a local Datastore server) - onAuthorized(null, reqOpts); + onAuthenticated(null, reqOpts); } else { - authClient.authorizeRequest(reqOpts, onAuthorized); + authClient.authorizeRequest(reqOpts, onAuthenticated); } if (stream) { @@ -375,15 +375,15 @@ function makeAuthorizedRequestFactory(config) { } } - makeAuthorizedRequest.getCredentials = + makeAuthenticatedRequest.getCredentials = authClient.getCredentials.bind(authClient); - makeAuthorizedRequest.authClient = authClient; + makeAuthenticatedRequest.authClient = authClient; - return makeAuthorizedRequest; + return makeAuthenticatedRequest; } -util.makeAuthorizedRequestFactory = makeAuthorizedRequestFactory; +util.makeAuthenticatedRequestFactory = makeAuthenticatedRequestFactory; /** * Make a request through the `retryRequest` module with built-in error handling diff --git a/lib/compute/index.js b/lib/compute/index.js index 94db02d5e53..f5abd18308e 100644 --- a/lib/compute/index.js +++ b/lib/compute/index.js @@ -120,7 +120,8 @@ function Compute(options) { // We store the authConfig for use with gceImages in Zone. this.authConfig = authConfig; - this.makeAuthorizedRequest_ = util.makeAuthorizedRequestFactory(authConfig); + this.makeAuthenticatedRequest_ = + util.makeAuthenticatedRequestFactory(authConfig); this.projectId = options.projectId; } @@ -1363,7 +1364,7 @@ Compute.prototype.makeReq_ = function(method, path, query, body, callback) { reqOpts.json = body; } - this.makeAuthorizedRequest_(reqOpts, callback); + this.makeAuthenticatedRequest_(reqOpts, callback); }; /*! Developer Documentation diff --git a/lib/datastore/dataset.js b/lib/datastore/dataset.js index 2c5f988562f..c22296e4ee4 100644 --- a/lib/datastore/dataset.js +++ b/lib/datastore/dataset.js @@ -110,7 +110,7 @@ function Dataset(options) { throw util.missingProjectIdError; } - this.makeAuthorizedRequest_ = util.makeAuthorizedRequestFactory({ + this.makeAuthenticatedRequest_ = util.makeAuthenticatedRequestFactory({ customEndpoint: typeof options.apiEndpoint !== 'undefined', credentials: options.credentials, keyFile: options.keyFilename, diff --git a/lib/datastore/request.js b/lib/datastore/request.js index f9ff6b14a71..38f602213f8 100644 --- a/lib/datastore/request.js +++ b/lib/datastore/request.js @@ -779,17 +779,17 @@ DatastoreRequest.prototype.makeReq_ = function(method, body, callback) { } }; - this.makeAuthorizedRequest_(reqOpts, { - onAuthorized: function(err, authorizedReqOpts) { + this.makeAuthenticatedRequest_(reqOpts, { + onAuthenticated: function(err, authenticatedReqOpts) { if (err) { callback(err, null); // TODO(ryanseys): What goes as third parameter? return; } - authorizedReqOpts.headers = authorizedReqOpts.headers || {}; - authorizedReqOpts.headers['Content-Length'] = pbRequest.length; + authenticatedReqOpts.headers = authenticatedReqOpts.headers || {}; + authenticatedReqOpts.headers['Content-Length'] = pbRequest.length; - var apiRequest = request(authorizedReqOpts); + var apiRequest = request(authenticatedReqOpts); apiRequest.on('error', callback); diff --git a/lib/datastore/transaction.js b/lib/datastore/transaction.js index 91f79187046..29a40e91ac8 100644 --- a/lib/datastore/transaction.js +++ b/lib/datastore/transaction.js @@ -39,7 +39,7 @@ var extend = require('extend'); /*! Developer Documentation * - * @param {module:common/connection#Connection} connection - An authorized + * @param {module:common/connection#Connection} connection - An authenticated * connection to Google Cloud Datastore. * @param {string} projectId - Dataset ID. This is your project ID from the * Google Developers Console. @@ -72,7 +72,7 @@ var extend = require('extend'); function Transaction(dataset, projectId) { this.id = null; this.apiEndpoint = dataset.apiEndpoint; - this.makeAuthorizedRequest_ = dataset.makeAuthorizedRequest_; + this.makeAuthenticatedRequest_ = dataset.makeAuthenticatedRequest_; this.projectId = projectId; // A queue for entity modifications made during the transaction. diff --git a/lib/dns/index.js b/lib/dns/index.js index fe7ab99cdd9..24a81b5f942 100644 --- a/lib/dns/index.js +++ b/lib/dns/index.js @@ -82,7 +82,7 @@ function DNS(options) { return new DNS(options); } - this.makeAuthorizedRequest_ = util.makeAuthorizedRequestFactory({ + this.makeAuthenticatedRequest_ = util.makeAuthenticatedRequestFactory({ credentials: options.credentials, keyFile: options.keyFilename, scopes: SCOPES, @@ -239,7 +239,7 @@ DNS.prototype.makeReq_ = function(method, path, query, body, callback) { reqOpts.json = body; } - this.makeAuthorizedRequest_(reqOpts, callback); + this.makeAuthenticatedRequest_(reqOpts, callback); }; /*! Developer Documentation diff --git a/lib/index.js b/lib/index.js index 2b6df596340..8a0d8f59579 100644 --- a/lib/index.js +++ b/lib/index.js @@ -228,7 +228,7 @@ var scopedApis = { * 2. Provide them at the time of instantiation of sub-modules, e.g. a Datastore * dataset, a Cloud Storage bucket, etc. * - * See our [Authorization Guide](#/authorization) for how to obtain the + * See our [Authentication Guide](#/authentication) for how to obtain the * necessary credentials for connecting to your project. * * @alias module:gcloud diff --git a/lib/pubsub/index.js b/lib/pubsub/index.js index 81afc88b201..9a9cf551716 100644 --- a/lib/pubsub/index.js +++ b/lib/pubsub/index.js @@ -86,7 +86,7 @@ function PubSub(options) { return new PubSub(options); } - this.makeAuthorizedRequest_ = util.makeAuthorizedRequestFactory({ + this.makeAuthenticatedRequest_ = util.makeAuthenticatedRequestFactory({ credentials: options.credentials, keyFile: options.keyFilename, scopes: SCOPES, @@ -538,7 +538,7 @@ PubSub.prototype.makeReq_ = function(method, path, q, body, callback) { reqOpts.json = body; } - this.makeAuthorizedRequest_(reqOpts, callback); + this.makeAuthenticatedRequest_(reqOpts, callback); }; /*! Developer Documentation diff --git a/lib/resource/index.js b/lib/resource/index.js index 0f6901a019c..ec0f06cc2eb 100644 --- a/lib/resource/index.js +++ b/lib/resource/index.js @@ -90,7 +90,7 @@ function Resource(options) { this.defaultProjectId_ = options.projectId; - this.makeAuthorizedRequest_ = util.makeAuthorizedRequestFactory({ + this.makeAuthenticatedRequest_ = util.makeAuthenticatedRequestFactory({ credentials: options.credentials, keyFile: options.keyFilename, scopes: SCOPES, @@ -288,7 +288,7 @@ Resource.prototype.makeReq_ = function(method, path, query, body, callback) { reqOpts.json = body; } - this.makeAuthorizedRequest_(reqOpts, callback); + this.makeAuthenticatedRequest_(reqOpts, callback); }; /*! Developer Documentation diff --git a/lib/search/index.js b/lib/search/index.js index 1bd9e84363d..b5caa7275eb 100644 --- a/lib/search/index.js +++ b/lib/search/index.js @@ -85,7 +85,7 @@ function Search(options) { return new Search(options); } - this.makeAuthorizedRequest_ = util.makeAuthorizedRequestFactory({ + this.makeAuthenticatedRequest_ = util.makeAuthenticatedRequestFactory({ credentials: options.credentials, email: options.email, keyFile: options.keyFilename, @@ -245,7 +245,7 @@ Search.prototype.makeReq_ = function(method, path, query, body, callback) { reqOpts.json = body; } - this.makeAuthorizedRequest_(reqOpts, callback); + this.makeAuthenticatedRequest_(reqOpts, callback); }; /*! Developer Documentation diff --git a/lib/storage/bucket.js b/lib/storage/bucket.js index 027eacb6e71..0a046a7e9ed 100644 --- a/lib/storage/bucket.js +++ b/lib/storage/bucket.js @@ -269,7 +269,7 @@ Bucket.prototype.combine = function(sources, destination, callback) { } } - this.storage.makeAuthorizedRequest_({ + this.storage.makeAuthenticatedRequest_({ method: 'POST', uri: format('{base}/{destBucket}/o/{destFile}/compose', { base: STORAGE_BASE_URL, @@ -1105,7 +1105,7 @@ Bucket.prototype.makeReq_ = function(method, path, query, body, callback) { reqOpts.json = body; } - this.storage.makeAuthorizedRequest_(reqOpts, callback); + this.storage.makeAuthenticatedRequest_(reqOpts, callback); }; /*! Developer Documentation diff --git a/lib/storage/file.js b/lib/storage/file.js index c1bd470cd21..3c041836460 100644 --- a/lib/storage/file.js +++ b/lib/storage/file.js @@ -470,7 +470,7 @@ File.prototype.createReadStream = function(options) { }; } - var requestStream = self.bucket.storage.makeAuthorizedRequest_(reqOpts); + var requestStream = self.bucket.storage.makeAuthenticatedRequest_(reqOpts); var validateStream; // We listen to the response event from the request stream so that we can... @@ -600,7 +600,7 @@ File.prototype.createResumableUpload = function(metadata, callback) { } resumableUpload.createURI({ - authClient: this.bucket.storage.makeAuthorizedRequest_.authClient, + authClient: this.bucket.storage.makeAuthenticatedRequest_.authClient, bucket: this.bucket.name, file: this.name, generation: this.generation, @@ -1057,9 +1057,9 @@ File.prototype.getSignedPolicy = function(options, callback) { conditions: conditions }; - var makeAuthorizedRequest_ = this.bucket.storage.makeAuthorizedRequest_; + var makeAuthenticatedRequest_ = this.bucket.storage.makeAuthenticatedRequest_; - makeAuthorizedRequest_.getCredentials(function(err, credentials) { + makeAuthenticatedRequest_.getCredentials(function(err, credentials) { if (err) { var signingError = new Error('Signing failed. See `error` property.'); signingError.error = err; @@ -1188,9 +1188,9 @@ File.prototype.getSignedUrl = function(options, callback) { options.resource = '/' + this.bucket.name + '/' + name; - var makeAuthorizedRequest_ = this.bucket.storage.makeAuthorizedRequest_; + var makeAuthenticatedRequest_ = this.bucket.storage.makeAuthenticatedRequest_; - makeAuthorizedRequest_.getCredentials(function(err, credentials) { + makeAuthenticatedRequest_.getCredentials(function(err, credentials) { if (err) { var signingError = new Error('Signing failed. See `error` property.'); signingError.error = err; @@ -1398,7 +1398,7 @@ File.prototype.startResumableUpload_ = function(dup, metadata) { var self = this; var uploadStream = resumableUpload({ - authClient: this.bucket.storage.makeAuthorizedRequest_.authClient, + authClient: this.bucket.storage.makeAuthenticatedRequest_.authClient, bucket: this.bucket.name, file: this.name, generation: this.generation, @@ -1446,7 +1446,7 @@ File.prototype.startSimpleUpload_ = function(dup, metadata) { } util.makeWritableStream(dup, { - makeAuthorizedRequest: self.bucket.storage.makeAuthorizedRequest_, + makeAuthenticatedRequest: self.bucket.storage.makeAuthenticatedRequest_, metadata: metadata, request: reqOpts }, function(data) { diff --git a/lib/storage/index.js b/lib/storage/index.js index e2d0ebc71f1..0cae08b5b93 100644 --- a/lib/storage/index.js +++ b/lib/storage/index.js @@ -88,7 +88,7 @@ function Storage(options) { return new Storage(options); } - this.makeAuthorizedRequest_ = util.makeAuthorizedRequestFactory({ + this.makeAuthenticatedRequest_ = util.makeAuthenticatedRequestFactory({ credentials: options.credentials, keyFile: options.keyFilename, scopes: SCOPES, @@ -387,7 +387,7 @@ Storage.prototype.makeReq_ = function(method, path, query, body, callback) { reqOpts.json = body; } - this.makeAuthorizedRequest_(reqOpts, callback); + this.makeAuthenticatedRequest_(reqOpts, callback); }; /*! Developer Documentation diff --git a/test/bigquery/index.js b/test/bigquery/index.js index be254b9b472..82f4cd81178 100644 --- a/test/bigquery/index.js +++ b/test/bigquery/index.js @@ -688,7 +688,7 @@ describe('BigQuery', function() { var body = { hi: 'there' }; it('should make correct request', function(done) { - bq.makeAuthorizedRequest_ = function(request) { + bq.makeAuthenticatedRequest_ = function(request) { var basePath = 'https://www.googleapis.com/bigquery/v2/projects/'; assert.equal(request.method, method); assert.equal(request.uri, basePath + bq.projectId + path); @@ -700,7 +700,7 @@ describe('BigQuery', function() { }); it('should execute callback', function(done) { - bq.makeAuthorizedRequest_ = function(request, callback) { + bq.makeAuthenticatedRequest_ = function(request, callback) { callback(); }; bq.makeReq_(method, path, query, body, done); diff --git a/test/common/util.js b/test/common/util.js index b9503c7b482..186f26eaac8 100644 --- a/test/common/util.js +++ b/test/common/util.js @@ -105,8 +105,8 @@ describe('common/util', function() { it('should export an error for module instantiation errors', function() { var missingProjectIdError = new Error([ 'Sorry, we cannot connect to Google Cloud Services without a project ID.', - 'See https://googlecloudplatform.github.io/gcloud-node/#/authorization', - 'for a detailed guide on creating an authorized connection.' + 'See https://googlecloudplatform.github.io/gcloud-node/#/authentication', + 'for a detailed guide on creating an authenticated connection.' ].join(' ')); assert.deepEqual(util.missingProjectIdError, missingProjectIdError); @@ -271,7 +271,7 @@ describe('common/util', function() { util.makeWritableStream(dup, { metadata: metadata, - makeAuthorizedRequest: function(request) { + makeAuthenticatedRequest: function(request) { assert.equal(request.method, 'POST'); assert.equal(request.qs.uploadType, 'multipart'); @@ -306,7 +306,7 @@ describe('common/util', function() { metadata: { contentType: 'application/json' }, - makeAuthorizedRequest: function(request) { + makeAuthenticatedRequest: function(request) { assert.equal(request.method, req.method); assert.deepEqual(request.qs, req.qs); assert.equal(request.something, req.something); @@ -331,8 +331,8 @@ describe('common/util', function() { }); util.makeWritableStream(ws, { - makeAuthorizedRequest: function(request, opts) { - opts.onAuthorized(error); + makeAuthenticatedRequest: function(request, opts) { + opts.onAuthenticated(error); } }); }); @@ -345,7 +345,7 @@ describe('common/util', function() { }; util.makeWritableStream(dup, { - makeAuthorizedRequest: function() {} + makeAuthenticatedRequest: function() {} }); }); @@ -371,8 +371,8 @@ describe('common/util', function() { }); util.makeWritableStream(dup, { - makeAuthorizedRequest: function(request, opts) { - opts.onAuthorized(); + makeAuthenticatedRequest: function(request, opts) { + opts.onAuthenticated(); } }); @@ -397,8 +397,8 @@ describe('common/util', function() { }; var options = { - makeAuthorizedRequest: function(request, opts) { - opts.onAuthorized(); + makeAuthenticatedRequest: function(request, opts) { + opts.onAuthenticated(); } }; @@ -413,7 +413,7 @@ describe('common/util', function() { }); }); - describe('makeAuthorizedRequestFactory', function() { + describe('makeAuthenticatedRequestFactory', function() { var authClient = { getCredentials: function() {} }; beforeEach(function() { @@ -431,11 +431,11 @@ describe('common/util', function() { return authClient; }; - util.makeAuthorizedRequestFactory(config); + util.makeAuthenticatedRequestFactory(config); }); it('should return a function', function() { - assert.equal(typeof util.makeAuthorizedRequestFactory(), 'function'); + assert.equal(typeof util.makeAuthenticatedRequestFactory(), 'function'); }); it('should return a getCredentials method', function(done) { @@ -447,8 +447,8 @@ describe('common/util', function() { return { getCredentials: getCredentials }; }; - var makeAuthorizedRequest = util.makeAuthorizedRequestFactory(); - makeAuthorizedRequest.getCredentials(); + var makeAuthenticatedRequest = util.makeAuthenticatedRequestFactory(); + makeAuthenticatedRequest.getCredentials(); }); it('should return the authClient', function() { @@ -458,15 +458,15 @@ describe('common/util', function() { return authClient; }; - var makeAuthorizedRequest = util.makeAuthorizedRequestFactory(); - assert.strictEqual(makeAuthorizedRequest.authClient, authClient); + var makeAuthenticatedRequest = util.makeAuthenticatedRequestFactory(); + assert.strictEqual(makeAuthenticatedRequest.authClient, authClient); }); - describe('customEndpoint (no authorization attempted)', function() { - var makeAuthorizedRequest; + describe('customEndpoint (no authentication attempted)', function() { + var makeAuthenticatedRequest; beforeEach(function() { - makeAuthorizedRequest = util.makeAuthorizedRequestFactory({ + makeAuthenticatedRequest = util.makeAuthenticatedRequestFactory({ customEndpoint: true }); }); @@ -479,16 +479,16 @@ describe('common/util', function() { done(); }; - makeAuthorizedRequest(reqOpts, { onAuthorized: assert.ifError }); + makeAuthenticatedRequest(reqOpts, { onAuthenticated: assert.ifError }); }); - it('should pass options back to onAuthorized callback', function(done) { + it('should pass options back to callback', function(done) { var reqOpts = { a: 'b', c: 'd' }; - makeAuthorizedRequest(reqOpts, { - onAuthorized: function(err, authorizedReqOpts) { + makeAuthenticatedRequest(reqOpts, { + onAuthenticated: function(err, authenticatedReqOpts) { assert.ifError(err); - assert.deepEqual(reqOpts, authorizedReqOpts); + assert.deepEqual(reqOpts, authenticatedReqOpts); done(); } }); @@ -502,12 +502,12 @@ describe('common/util', function() { done(); }; - makeAuthorizedRequest(reqOpts, assert.ifError); + makeAuthenticatedRequest(reqOpts, assert.ifError); }); }); - describe('needs authorization', function() { - it('should pass correct arguments to authorizeRequest', function(done) { + describe('needs authentication', function() { + it('should pass correct args to authorizeRequest', function(done) { var reqOpts = { e: 'f', g: 'h' }; authClient.authorizeRequest = function(rOpts) { @@ -515,18 +515,18 @@ describe('common/util', function() { done(); }; - var makeAuthorizedRequest = util.makeAuthorizedRequestFactory(); - makeAuthorizedRequest(reqOpts, {}); + var makeAuthenticatedRequest = util.makeAuthenticatedRequestFactory(); + makeAuthenticatedRequest(reqOpts, {}); }); it('should return a stream if callback is missing', function() { authClient.authorizeRequest = function() {}; - var makeAuthorizedRequest = util.makeAuthorizedRequestFactory({}); - assert(makeAuthorizedRequest({}) instanceof stream.Stream); + var makeAuthenticatedRequest = util.makeAuthenticatedRequestFactory({}); + assert(makeAuthenticatedRequest({}) instanceof stream.Stream); }); - describe('authorization errors', function() { + describe('authentication errors', function() { var error = new Error('Error.'); beforeEach(function() { @@ -548,9 +548,9 @@ describe('common/util', function() { }); }; - var makeAuthorizedRequest = util.makeAuthorizedRequestFactory(); - makeAuthorizedRequest({}, { - onAuthorized: function(err) { + var makeAuthenticatedRequest = util.makeAuthenticatedRequestFactory(); + makeAuthenticatedRequest({}, { + onAuthenticated: function(err) { assert.strictEqual(err, null); done(); } @@ -558,17 +558,17 @@ describe('common/util', function() { }); it('should invoke the callback with error', function(done) { - var makeAuthorizedRequest = util.makeAuthorizedRequestFactory(); - makeAuthorizedRequest({}, function(err) { + var makeAuthenticatedRequest = util.makeAuthenticatedRequestFactory(); + makeAuthenticatedRequest({}, function(err) { assert.strictEqual(err, error); done(); }); }); - it('should invoke the onAuthorized handler with error', function(done) { - var makeAuthorizedRequest = util.makeAuthorizedRequestFactory(); - makeAuthorizedRequest({}, { - onAuthorized: function(err) { + it('should exec onAuthenticated callback with error', function(done) { + var makeAuthenticatedRequest = util.makeAuthenticatedRequestFactory(); + makeAuthenticatedRequest({}, { + onAuthenticated: function(err) { assert.strictEqual(err, error); done(); } @@ -576,8 +576,8 @@ describe('common/util', function() { }); it('should emit an error and end the stream', function(done) { - var makeAuthorizedRequest = util.makeAuthorizedRequestFactory(); - makeAuthorizedRequest({}).on('error', function(err) { + var makeAuthenticatedRequest = util.makeAuthenticatedRequestFactory(); + makeAuthenticatedRequest({}).on('error', function(err) { assert.strictEqual(err, error); var stream = this; @@ -589,7 +589,7 @@ describe('common/util', function() { }); }); - describe('authorization success', function() { + describe('authentication success', function() { var reqOpts = { a: 'b', c: 'd' }; beforeEach(function() { @@ -598,16 +598,16 @@ describe('common/util', function() { }; }); - it('should return the authorized request to callback', function(done) { + it('should return authenticated request to callback', function(done) { utilOverrides.decorateRequest = function(reqOpts_) { assert.strictEqual(reqOpts_, reqOpts); return reqOpts; }; - var makeAuthorizedRequest = util.makeAuthorizedRequestFactory(); - makeAuthorizedRequest(reqOpts, { - onAuthorized: function(err, authorizedReqOpts) { - assert.strictEqual(authorizedReqOpts, reqOpts); + var makeAuthenticatedRequest = util.makeAuthenticatedRequestFactory(); + makeAuthenticatedRequest(reqOpts, { + onAuthenticated: function(err, authenticatedReqOpts) { + assert.strictEqual(authenticatedReqOpts, reqOpts); done(); } }); @@ -621,28 +621,30 @@ describe('common/util', function() { return reqOpts; }; - utilOverrides.makeRequest = function(authorizedReqOpts, cfg, cb) { - assert.strictEqual(authorizedReqOpts, reqOpts); + utilOverrides.makeRequest = function(authenticatedReqOpts, cfg, cb) { + assert.strictEqual(authenticatedReqOpts, reqOpts); assert.deepEqual(cfg, config); cb(); }; - var makeAuthorizedRequest = util.makeAuthorizedRequestFactory(config); - makeAuthorizedRequest(reqOpts, done); + var makeAuthenticatedRequest = + util.makeAuthenticatedRequestFactory(config); + makeAuthenticatedRequest(reqOpts, done); }); it('should provide stream to makeRequest', function(done) { var stream; - utilOverrides.makeRequest = function(authorizedReqOpts, cfg) { + utilOverrides.makeRequest = function(authenticatedReqOpts, cfg) { setImmediate(function() { assert.strictEqual(cfg.stream, stream); done(); }); }; - var makeAuthorizedRequest = util.makeAuthorizedRequestFactory({}); - stream = makeAuthorizedRequest(reqOpts); + var makeAuthenticatedRequest = + util.makeAuthenticatedRequestFactory({}); + stream = makeAuthenticatedRequest(reqOpts); }); }); }); diff --git a/test/compute/index.js b/test/compute/index.js index defbd600e06..4c31422cbfb 100644 --- a/test/compute/index.js +++ b/test/compute/index.js @@ -25,7 +25,7 @@ var util = require('../../lib/common/util.js'); var slice = Array.prototype.slice; var fakeUtil = extend({}, util, { - makeAuthorizedRequestFactory: util.noop + makeAuthenticatedRequestFactory: util.noop }); var extended = false; @@ -155,20 +155,20 @@ describe('Compute', function() { }); }); - it('should create a makeAuthorizedRequest method', function(done) { - fakeUtil.makeAuthorizedRequestFactory = function(options_) { + it('should create a makeAuthenticatedRequest method', function(done) { + fakeUtil.makeAuthenticatedRequestFactory = function(options_) { assert.deepEqual(options_, { credentials: options.credentials, email: options.email, keyFile: options.keyFilename, scopes: ['https://www.googleapis.com/auth/compute'] }); - fakeUtil.makeAuthorizedRequestFactory = util.noop; + fakeUtil.makeAuthenticatedRequestFactory = util.noop; return done; }; var compute = new Compute(options); - compute.makeAuthorizedRequest_(); + compute.makeAuthenticatedRequest_(); }); it('should localize the project id', function() { @@ -1399,7 +1399,7 @@ describe('Compute', function() { var query = 'query'; var body = 'body'; - compute.makeAuthorizedRequest_ = function(reqOpts, callback) { + compute.makeAuthenticatedRequest_ = function(reqOpts, callback) { assert.equal(reqOpts.method, method); assert.equal(reqOpts.qs, query); diff --git a/test/datastore/request.js b/test/datastore/request.js index 7c2a4228974..54466c768fa 100644 --- a/test/datastore/request.js +++ b/test/datastore/request.js @@ -116,8 +116,8 @@ describe('Request', function() { requestOverride = null; request = new Request(); request.apiEndpoint = CUSTOM_ENDPOINT; - request.makeAuthorizedRequest_ = function(req, callback) { - (callback.onAuthorized || callback)(null, req); + request.makeAuthenticatedRequest_ = function(req, callback) { + (callback.onAuthenticated || callback)(null, req); }; }); @@ -761,7 +761,7 @@ describe('Request', function() { describe('makeReq_', function() { beforeEach(function() { request.connection = { - createAuthorizedReq: util.noop + createAuthenticatedReq: util.noop }; }); @@ -776,7 +776,7 @@ describe('Request', function() { }); request.projectId = projectId; - request.makeAuthorizedRequest_ = function(opts) { + request.makeAuthenticatedRequest_ = function(opts) { assert.equal(opts.method, 'POST'); assert.equal(opts.uri, expectedUri); assert.equal(opts.headers['Content-Type'], 'application/x-protobuf'); @@ -793,8 +793,8 @@ describe('Request', function() { done(); return new stream.Writable(); }; - request.makeAuthorizedRequest_ = function(opts, callback) { - (callback.onAuthorized || callback)(null, mockRequest); + request.makeAuthenticatedRequest_ = function(opts, callback) { + (callback.onAuthenticated || callback)(null, mockRequest); }; request.makeReq_('commit', {}, util.noop); }); @@ -842,8 +842,8 @@ describe('Request', function() { describe('transactional and non-transactional properties', function() { beforeEach(function() { - request.createAuthorizedRequest_ = function(opts, callback) { - (callback.onAuthorized || callback)(); + request.createAuthenticatedRequest_ = function(opts, callback) { + (callback.onAuthenticated || callback)(); }; }); diff --git a/test/datastore/transaction.js b/test/datastore/transaction.js index 3d801ffdef5..22d3dc6c644 100644 --- a/test/datastore/transaction.js +++ b/test/datastore/transaction.js @@ -73,7 +73,7 @@ describe('Transaction', function() { beforeEach(function() { transaction = new Transaction({ - authorizeReq_: function(req, callback) { + authenticateReq_: function(req, callback) { return callback(null, req); } }, 'project-id'); @@ -84,7 +84,7 @@ describe('Transaction', function() { var projectId = 'abc'; var fakeDataset = { apiEndpoint: 'http://localhost:8080', - makeAuthorizedRequest_: function fakeMakeAuthorizedRequest_() {} + makeAuthenticatedRequest_: function fakeMakeAuthenticatedRequest_() {} }; var transaction = new Transaction(fakeDataset, projectId); @@ -92,8 +92,8 @@ describe('Transaction', function() { assert.strictEqual(transaction.id, null); assert.deepEqual(transaction.apiEndpoint, fakeDataset.apiEndpoint); assert.equal( - transaction.makeAuthorizedRequest_, - fakeDataset.makeAuthorizedRequest_ + transaction.makeAuthenticatedRequest_, + fakeDataset.makeAuthenticatedRequest_ ); assert.equal(transaction.projectId, projectId); }); diff --git a/test/dns/index.js b/test/dns/index.js index d881fb97d70..be0e71520f4 100644 --- a/test/dns/index.js +++ b/test/dns/index.js @@ -37,13 +37,13 @@ var fakeStreamRouter = { } }; -var makeAuthorizedRequestFactoryOverride; +var makeAuthenticatedRequestFactoryOverride; var fakeUtil = extend({}, util, { - makeAuthorizedRequestFactory: function() { - if (makeAuthorizedRequestFactoryOverride) { - return makeAuthorizedRequestFactoryOverride.apply(null, arguments); + makeAuthenticatedRequestFactory: function() { + if (makeAuthenticatedRequestFactoryOverride) { + return makeAuthenticatedRequestFactoryOverride.apply(null, arguments); } else { - return util.makeAuthorizedRequestFactory.apply(null, arguments); + return util.makeAuthenticatedRequestFactory.apply(null, arguments); } } }); @@ -76,7 +76,7 @@ describe('DNS', function() { }); beforeEach(function() { - makeAuthorizedRequestFactoryOverride = null; + makeAuthenticatedRequestFactoryOverride = null; dns = new DNS({ projectId: PROJECT_ID @@ -107,7 +107,7 @@ describe('DNS', function() { fakeUtil.normalizeArguments = normalizeArguments; }); - it('should create an authorized request function', function(done) { + it('should create an authenticated request function', function(done) { var options = { projectId: 'projectId', credentials: 'credentials', @@ -115,7 +115,7 @@ describe('DNS', function() { keyFilename: 'keyFile' }; - makeAuthorizedRequestFactoryOverride = function(options_) { + makeAuthenticatedRequestFactoryOverride = function(options_) { assert.deepEqual(options_, { credentials: options.credentials, email: options.email, @@ -129,7 +129,7 @@ describe('DNS', function() { }; var dns = new DNS(options); - dns.makeAuthorizedRequest_(); + dns.makeAuthenticatedRequest_(); }); it('should localize the projectId', function() { @@ -395,13 +395,13 @@ describe('DNS', function() { }); describe('makeReq_', function() { - it('should make correct authorized request', function(done) { + it('should make correct authenticated request', function(done) { var method = 'POST'; var path = '/'; var query = 'query'; var body = 'body'; - dns.makeAuthorizedRequest_ = function(reqOpts, callback) { + dns.makeAuthenticatedRequest_ = function(reqOpts, callback) { assert.equal(reqOpts.method, method); assert.equal(reqOpts.qs, query); diff --git a/test/pubsub/index.js b/test/pubsub/index.js index 5cf358993a8..18e0dbf21c4 100644 --- a/test/pubsub/index.js +++ b/test/pubsub/index.js @@ -556,7 +556,7 @@ describe('PubSub', function() { it('should pass network requests to the connection object', function(done) { var pubsub = new PubSub({ projectId: PROJECT_ID }); - pubsub.makeAuthorizedRequest_ = function() { + pubsub.makeAuthenticatedRequest_ = function() { done(); }; diff --git a/test/resource/index.js b/test/resource/index.js index 6c4bc39c167..36d778febec 100644 --- a/test/resource/index.js +++ b/test/resource/index.js @@ -40,13 +40,13 @@ var fakeStreamRouter = { } }; -var makeAuthorizedRequestFactoryOverride; +var makeAuthenticatedRequestFactoryOverride; var fakeUtil = extend({}, util, { - makeAuthorizedRequestFactory: function() { - if (makeAuthorizedRequestFactoryOverride) { - return makeAuthorizedRequestFactoryOverride.apply(null, arguments); + makeAuthenticatedRequestFactory: function() { + if (makeAuthenticatedRequestFactoryOverride) { + return makeAuthenticatedRequestFactoryOverride.apply(null, arguments); } else { - return util.makeAuthorizedRequestFactory.apply(null, arguments); + return util.makeAuthenticatedRequestFactory.apply(null, arguments); } } }); @@ -75,7 +75,7 @@ describe('Resource', function() { }); beforeEach(function() { - makeAuthorizedRequestFactoryOverride = null; + makeAuthenticatedRequestFactoryOverride = null; resource = new Resource({ projectId: PROJECT_ID @@ -106,7 +106,7 @@ describe('Resource', function() { fakeUtil.normalizeArguments = normalizeArguments; }); - it('should create an authorized request function', function(done) { + it('should create an authenticated request function', function(done) { var options = { projectId: 'projectId', credentials: 'credentials', @@ -114,7 +114,7 @@ describe('Resource', function() { keyFilename: 'keyFile' }; - makeAuthorizedRequestFactoryOverride = function(options_) { + makeAuthenticatedRequestFactoryOverride = function(options_) { assert.deepEqual(options_, { credentials: options.credentials, email: options.email, @@ -127,7 +127,7 @@ describe('Resource', function() { }; var resource = new Resource(options); - resource.makeAuthorizedRequest_(); + resource.makeAuthenticatedRequest_(); }); it('should localize the projectId', function() { @@ -354,7 +354,7 @@ describe('Resource', function() { c: 'd' }; - resource.makeAuthorizedRequest_ = function(reqOpts, callback) { + resource.makeAuthenticatedRequest_ = function(reqOpts, callback) { assert.strictEqual(reqOpts.method, method); assert.strictEqual(reqOpts.uri, base + path); diff --git a/test/search/index.js b/test/search/index.js index e97ae78abae..91200610e83 100644 --- a/test/search/index.js +++ b/test/search/index.js @@ -41,13 +41,13 @@ var fakeStreamRouter = { } }; -var makeAuthorizedRequestFactoryOverride; +var makeAuthenticatedRequestFactoryOverride; var fakeUtil = extend({}, util, { - makeAuthorizedRequestFactory: function() { - if (makeAuthorizedRequestFactoryOverride) { - return makeAuthorizedRequestFactoryOverride.apply(null, arguments); + makeAuthenticatedRequestFactory: function() { + if (makeAuthenticatedRequestFactoryOverride) { + return makeAuthenticatedRequestFactoryOverride.apply(null, arguments); } else { - return util.makeAuthorizedRequestFactory.apply(null, arguments); + return util.makeAuthenticatedRequestFactory.apply(null, arguments); } } }); @@ -76,7 +76,7 @@ describe('Search', function() { }); beforeEach(function() { - makeAuthorizedRequestFactoryOverride = null; + makeAuthenticatedRequestFactoryOverride = null; search = new Search({ projectId: PROJECT_ID @@ -107,7 +107,7 @@ describe('Search', function() { fakeUtil.normalizeArguments = normalizeArguments; }); - it('should create an authorized request function', function(done) { + it('should create an authenticated request function', function(done) { var options = { projectId: 'projectId', credentials: 'credentials', @@ -115,7 +115,7 @@ describe('Search', function() { keyFilename: 'keyFile' }; - makeAuthorizedRequestFactoryOverride = function(options_) { + makeAuthenticatedRequestFactoryOverride = function(options_) { assert.deepEqual(options_, { credentials: options.credentials, email: options.email, @@ -130,7 +130,7 @@ describe('Search', function() { }; var search = new Search(options); - search.makeAuthorizedRequest_(); + search.makeAuthenticatedRequest_(); }); it('should localize the projectId', function() { @@ -274,13 +274,13 @@ describe('Search', function() { }); describe('makeReq_', function() { - it('should make correct authorized request', function(done) { + it('should make correct authenticated request', function(done) { var method = 'POST'; var path = '/'; var query = 'query'; var body = 'body'; - search.makeAuthorizedRequest_ = function(reqOpts, callback) { + search.makeAuthenticatedRequest_ = function(reqOpts, callback) { assert.equal(reqOpts.method, method); assert.equal(reqOpts.qs, query); diff --git a/test/storage/bucket.js b/test/storage/bucket.js index 8dc1dbe8d1a..f5f44494602 100644 --- a/test/storage/bucket.js +++ b/test/storage/bucket.js @@ -85,7 +85,7 @@ describe('Bucket', function() { var BUCKET_NAME = 'test-bucket'; var bucket; var options = { - makeAuthorizedRequest_: function(req, callback) { + makeAuthenticatedRequest_: function(req, callback) { callback(null, req); } }; @@ -119,7 +119,7 @@ describe('Bucket', function() { }); it('should re-use provided connection', function() { - assert.deepEqual(bucket.authorizeReq_, options.authorizeReq_); + assert.deepEqual(bucket.authenticateReq_, options.authenticateReq_); }); it('should default metadata to an empty object', function() { @@ -158,7 +158,7 @@ describe('Bucket', function() { var file1 = bucket.file('1.txt'); var file2 = '2.txt'; - bucket.storage.makeAuthorizedRequest_ = function(reqOpts) { + bucket.storage.makeAuthenticatedRequest_ = function(reqOpts) { assert.equal(reqOpts.json.sourceObjects[0].name, file1.name); assert.equal(reqOpts.json.sourceObjects[1].name, file2); done(); @@ -174,7 +174,7 @@ describe('Bucket', function() { ]; async.each(destinations, function(destination, next) { - bucket.storage.makeAuthorizedRequest_ = function(reqOpts) { + bucket.storage.makeAuthenticatedRequest_ = function(reqOpts) { assert(reqOpts.uri.indexOf(bucket.name + '/o/destination.txt') > -1); next(); }; @@ -186,7 +186,7 @@ describe('Bucket', function() { it('should use content type from the destination metadata', function(done) { var destination = 'destination.txt'; - bucket.storage.makeAuthorizedRequest_ = function(reqOpts) { + bucket.storage.makeAuthenticatedRequest_ = function(reqOpts) { assert.equal( reqOpts.json.destination.contentType, mime.contentType(destination) @@ -201,7 +201,7 @@ describe('Bucket', function() { var destination = bucket.file('destination.txt'); destination.metadata = { contentType: 'content-type' }; - bucket.storage.makeAuthorizedRequest_ = function(reqOpts) { + bucket.storage.makeAuthenticatedRequest_ = function(reqOpts) { assert.equal( reqOpts.json.destination.contentType, destination.metadata.contentType @@ -215,7 +215,7 @@ describe('Bucket', function() { it('should detect dest content type if not in metadata', function(done) { var destination = 'destination.txt'; - bucket.storage.makeAuthorizedRequest_ = function(reqOpts) { + bucket.storage.makeAuthenticatedRequest_ = function(reqOpts) { assert.equal( reqOpts.json.destination.contentType, mime.contentType(destination) @@ -239,7 +239,7 @@ describe('Bucket', function() { var sources = [bucket.file('1.txt'), bucket.file('2.txt')]; var destination = bucket.file('destination.txt'); - bucket.storage.makeAuthorizedRequest_ = function(reqOpts) { + bucket.storage.makeAuthenticatedRequest_ = function(reqOpts) { var expectedUri = format('{base}/{bucket}/o/{file}/compose', { base: 'https://www.googleapis.com/storage/v1/b', bucket: destination.bucket.name, @@ -261,7 +261,7 @@ describe('Bucket', function() { var sources = [bucket.file('1.txt'), bucket.file('2.txt')]; var destination = 'needs encoding.jpg'; - bucket.storage.makeAuthorizedRequest_ = function(reqOpts) { + bucket.storage.makeAuthenticatedRequest_ = function(reqOpts) { assert.equal(reqOpts.uri.indexOf(destination), -1); done(); }; @@ -276,7 +276,7 @@ describe('Bucket', function() { var destination = bucket.file('destination.txt'); - bucket.storage.makeAuthorizedRequest_ = function(reqOpts) { + bucket.storage.makeAuthenticatedRequest_ = function(reqOpts) { assert.deepEqual(reqOpts.json.sourceObjects, [ { name: sources[0].name, generation: sources[0].metadata.generation }, { name: sources[1].name, generation: sources[1].metadata.generation } @@ -292,7 +292,7 @@ describe('Bucket', function() { var sources = [bucket.file('1.txt'), bucket.file('2.txt')]; var destination = 'destination.txt'; - bucket.storage.makeAuthorizedRequest_ = function(reqOpts, callback) { + bucket.storage.makeAuthenticatedRequest_ = function(reqOpts, callback) { callback(); }; @@ -305,7 +305,7 @@ describe('Bucket', function() { var error = new Error('Error.'); - bucket.storage.makeAuthorizedRequest_ = function(reqOpts, callback) { + bucket.storage.makeAuthenticatedRequest_ = function(reqOpts, callback) { callback(error); }; @@ -320,7 +320,7 @@ describe('Bucket', function() { var destination = 'destination.txt'; var resp = { success: true }; - bucket.storage.makeAuthorizedRequest_ = function(reqOpts, callback) { + bucket.storage.makeAuthenticatedRequest_ = function(reqOpts, callback) { callback(null, resp); }; @@ -1156,7 +1156,7 @@ describe('Bucket', function() { var body = { hi: 'there' }; it('should make correct request', function(done) { - bucket.storage.makeAuthorizedRequest_ = function(request) { + bucket.storage.makeAuthenticatedRequest_ = function(request) { var basePath = 'https://www.googleapis.com/storage/v1/b'; assert.equal(request.method, method); assert.equal(request.uri, basePath + '/' + bucket.name + path); @@ -1168,7 +1168,7 @@ describe('Bucket', function() { }); it('should execute callback', function(done) { - bucket.storage.makeAuthorizedRequest_ = function(request, callback) { + bucket.storage.makeAuthenticatedRequest_ = function(request, callback) { callback(); }; bucket.makeReq_(method, path, query, body, done); diff --git a/test/storage/file.js b/test/storage/file.js index b8bf82348a8..e30852ace40 100644 --- a/test/storage/file.js +++ b/test/storage/file.js @@ -102,9 +102,9 @@ describe('File', function() { beforeEach(function() { var options = { - makeAuthorizedRequest_: function(req, callback) { + makeAuthenticatedRequest_: function(req, callback) { if (callback) { - (callback.onAuthorized || callback)(null, req); + (callback.onAuthenticated || callback)(null, req); } else { return (requestOverride || requestCached)(req); } @@ -481,8 +481,8 @@ describe('File', function() { it('should send query.generation if File has one', function(done) { var versionedFile = new File(bucket, 'file.txt', { generation: 1 }); - versionedFile.bucket.storage.makeAuthorizedRequest_ = function(reqOpts) { - assert.equal(reqOpts.qs.generation, 1); + versionedFile.bucket.storage.makeAuthenticatedRequest_ = function(rOpts) { + assert.equal(rOpts.qs.generation, 1); setImmediate(function() { done(); }); @@ -508,15 +508,15 @@ describe('File', function() { }); }); - describe('authorizing', function() { - it('should create an authorized request', function(done) { + describe('authenticating', function() { + it('should create an authenticated request', function(done) { var expectedPath = format('https://{host}/{b}/{o}', { host: 'storage.googleapis.com', b: file.bucket.name, o: encodeURIComponent(file.name) }); - file.bucket.storage.makeAuthorizedRequest_ = function(opts) { + file.bucket.storage.makeAuthenticatedRequest_ = function(opts) { assert.equal(opts.uri, expectedPath); setImmediate(function() { done(); @@ -528,7 +528,7 @@ describe('File', function() { }); it('should accept gzip encoding', function(done) { - file.bucket.storage.makeAuthorizedRequest_ = function(opts) { + file.bucket.storage.makeAuthenticatedRequest_ = function(opts) { assert.strictEqual(opts.gzip, true); setImmediate(function() { done(); @@ -543,7 +543,7 @@ describe('File', function() { var ERROR = new Error('Error.'); beforeEach(function() { - file.bucket.storage.makeAuthorizedRequest_ = function(opts) { + file.bucket.storage.makeAuthenticatedRequest_ = function(opts) { var stream = (requestOverride || request)(opts); setImmediate(function() { @@ -554,7 +554,7 @@ describe('File', function() { }; }); - it('should emit an error from authorizing', function(done) { + it('should emit an error from authenticating', function(done) { file.createReadStream() .once('error', function(err) { assert.equal(err, ERROR); @@ -571,7 +571,7 @@ describe('File', function() { requestOverride = getFakeRequest(); - file.bucket.storage.makeAuthorizedRequest_ = function() { + file.bucket.storage.makeAuthenticatedRequest_ = function() { setImmediate(function() { assert.deepEqual(requestOverride.getRequestOptions(), fakeRequest); done(); @@ -596,7 +596,7 @@ describe('File', function() { it('should unpipe stream from an error on the response', function(done) { var requestStream = through(); - file.bucket.storage.makeAuthorizedRequest_ = function() { + file.bucket.storage.makeAuthenticatedRequest_ = function() { setImmediate(function() { // Must be a stream. Doesn't matter for the tests, though. requestStream.emit('response', through()); @@ -632,7 +632,7 @@ describe('File', function() { done(); }; - file.bucket.storage.makeAuthorizedRequest_ = function() { + file.bucket.storage.makeAuthenticatedRequest_ = function() { var stream = through(); setImmediate(function() { stream.emit('complete', response); @@ -676,9 +676,9 @@ describe('File', function() { beforeEach(function() { file.metadata.mediaLink = 'http://uri'; - file.bucket.storage.makeAuthorizedRequest_ = function(opts, callback) { - if (callback) { - (callback.onAuthorized || callback)(null, {}); + file.bucket.storage.makeAuthenticatedRequest_ = function(opts, cb) { + if (cb) { + (cb.onAuthenticated || cb)(null, {}); } else { return (requestOverride || requestCached)(opts); } @@ -865,7 +865,7 @@ describe('File', function() { createURI: function(opts, callback) { var bucket = file.bucket; var storage = bucket.storage; - var authClient = storage.makeAuthorizedRequest_.authClient; + var authClient = storage.makeAuthenticatedRequest_.authClient; assert.strictEqual(opts.authClient, authClient); assert.strictEqual(opts.bucket, bucket.name); @@ -1412,7 +1412,7 @@ describe('File', function() { beforeEach(function() { var storage = bucket.storage; - storage.makeAuthorizedRequest_.getCredentials = function(callback) { + storage.makeAuthenticatedRequest_.getCredentials = function(callback) { callback(null, credentials); }; }); @@ -1433,7 +1433,7 @@ describe('File', function() { var error = new Error('Error.'); var storage = bucket.storage; - storage.makeAuthorizedRequest_.getCredentials = function(callback) { + storage.makeAuthenticatedRequest_.getCredentials = function(callback) { callback(error); }; @@ -1449,7 +1449,7 @@ describe('File', function() { it('should return an error if credentials are not present', function(done) { var storage = bucket.storage; - storage.makeAuthorizedRequest_.getCredentials = function(callback) { + storage.makeAuthenticatedRequest_.getCredentials = function(callback) { callback(null, {}); }; @@ -1666,7 +1666,7 @@ describe('File', function() { beforeEach(function() { var storage = bucket.storage; - storage.makeAuthorizedRequest_.getCredentials = function(callback) { + storage.makeAuthenticatedRequest_.getCredentials = function(callback) { callback(null, credentials); }; }); @@ -1686,7 +1686,7 @@ describe('File', function() { var error = new Error('Error.'); var storage = bucket.storage; - storage.makeAuthorizedRequest_.getCredentials = function(callback) { + storage.makeAuthenticatedRequest_.getCredentials = function(callback) { callback(error); }; @@ -1703,7 +1703,7 @@ describe('File', function() { it('should return an error if credentials are not present', function(done) { var storage = bucket.storage; - storage.makeAuthorizedRequest_.getCredentials = function(callback) { + storage.makeAuthenticatedRequest_.getCredentials = function(callback) { callback(null, {}); }; @@ -1971,7 +1971,7 @@ describe('File', function() { resumableUploadOverride = function(opts) { var bucket = file.bucket; var storage = bucket.storage; - var authClient = storage.makeAuthorizedRequest_.authClient; + var authClient = storage.makeAuthenticatedRequest_.authClient; assert.strictEqual(opts.authClient, authClient); assert.strictEqual(opts.bucket, bucket.name);