How to use the ms-rest-azure.TokenCredentials function in ms-rest-azure

To help you get started, we’ve selected a few ms-rest-azure examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / autorest / src / generator / AutoRest.NodeJS.Azure.Tests / AcceptanceTests / azureSpecialProperties.js View on Github external
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

'use strict';

var should = require('should');
var http = require('http');
var assert = require('assert');
var msRestAzure = require('ms-rest-azure');

var specialsClient = require('../Expected/AcceptanceTests/AzureSpecials/autoRestAzureSpecialParametersTestClient');
var dummySubscriptionId = '1234-5678-9012-3456';
var dummyToken = 'dummy12321343423';
var credentials = new msRestAzure.TokenCredentials(dummyToken);

var clientOptions = {};
var baseUri = 'http://localhost:3000';

describe('nodejs', function () {

  describe('Azure Special Properties', function () {
    var testClient = new specialsClient(credentials, dummySubscriptionId, baseUri, clientOptions);
    it('should use the default api-version when no api-version parameter is present', function (done) {
      testClient.apiVersionDefault.getMethodGlobalValid(function (error, result, request, response) {
        should.not.exist(error);
        response.statusCode.should.equal(200);
        testClient.apiVersionDefault.getMethodGlobalNotProvidedValid(function (error, result, request, response) {
          should.not.exist(error);
          response.statusCode.should.equal(200);
          testClient.apiVersionDefault.getPathGlobalValid(function (error, result, request, response) {
github Azure / azure-sdk-for-java / AutoRest / Generators / NodeJS / Azure.NodeJS.Tests / AcceptanceTests / azureSpecialProperties.js View on Github external
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

'use strict';

var should = require('should');
var http = require('http');
var util = require('util');
var assert = require('assert');
var msRestAzure = require('ms-rest-azure');

var specialsClient = require('../Expected/AcceptanceTests/AzureSpecials/autoRestAzureSpecialParametersTestClient');
var dummySubscriptionId = '1234-5678-9012-3456';
var dummyToken = 'dummy12321343423';
var credentials = new msRestAzure.TokenCredentials(dummyToken);

var clientOptions = {};
var baseUri = 'http://localhost:3000';

describe('nodejs', function () {

  describe('Azure Special Properties', function () {
    var testClient = new specialsClient(credentials, dummySubscriptionId, baseUri, clientOptions);
    it('should use the default api-version when no api-version parameter is present', function (done) {
      testClient.apiVersionDefault.getMethodGlobalValid(function (error, result, request, response) {
        should.not.exist(error);
        response.statusCode.should.equal(200);
        testClient.apiVersionDefault.getMethodGlobalNotProvidedValid(function (error, result, request, response) {
          should.not.exist(error);
          response.statusCode.should.equal(200);
          testClient.apiVersionDefault.getPathGlobalValid(function (error, result, request, response) {
github Azure / autorest / src / generator / AutoRest.NodeJS.Azure.Tests / AcceptanceTests / subscriptionIdApiVersion.js View on Github external
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

'use strict';

var should = require('should');
var http = require('http');
var assert = require('assert');
var msRestAzure = require('ms-rest-azure');

var azureUrlClient = require('../Expected/AcceptanceTests/SubscriptionIdApiVersion/microsoftAzureTestUrl');
var dummySubscriptionId = 'a878ae02-6106-429z-9397-58091ee45g98';
var dummyToken = 'dummy12321343423';
var credentials = new msRestAzure.TokenCredentials(dummyToken);

var clientOptions = {};
var baseUri = 'http://localhost:3000';

describe('nodejs', function () {

  describe('Azure Swagger Url', function () {
    var testClient = new azureUrlClient(credentials, dummySubscriptionId, baseUri, clientOptions);

    it('should correctly send the subscriptionId as path parameter and api-version ' +
      'as a query parameter in the request url', function (done) {
      testClient.group.getSampleResourceGroup('testgroup101', function (error, result, request, response) {
        should.not.exist(error);
        response.statusCode.should.equal(200);
        done();
      });
github Azure / azure-sdk-for-java / AutoRest / Generators / NodeJS / Azure.NodeJS.Tests / AcceptanceTests / resourceFlattening.js View on Github external
// Licensed under the MIT License. See License.txt in the project root for license information.

'use strict';

var should = require('should');
var http = require('http');
var util = require('util');
var assert = require('assert');
var msRestAzure = require('ms-rest-azure');
var msRest = require('ms-rest');

var flatteningClient = require('../Expected/AcceptanceTests/ResourceFlattening/autoRestResourceFlatteningTestService');

var dummySubscriptionId = 'a878ae02-6106-429z-9397-58091ee45g98';
var dummyToken = 'dummy12321343423';
var credentials = new msRestAzure.TokenCredentials(dummyToken);

var clientOptions = {};
var baseUri = 'http://localhost:3000';

describe('nodejs', function () {

  describe('Swagger ResourceFlattening BAT', function () {

    describe('Resource Flattening Operations', function () {
      var testOptions = clientOptions;
      testOptions.requestOptions = { jar: true };
      testOptions.filters = [new msRest.ExponentialRetryPolicyFilter(3, 0, 0, 0)];
      testOptions.noRetryPolicy = true;
      var testClient = new flatteningClient(credentials, baseUri, clientOptions);

      it('should get external resource as an array', function (done) {
github Azure / autorest / src / generator / AutoRest.NodeJS.Azure.Tests / AcceptanceTests / azureCompositeClient.js View on Github external
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

'use strict';

var should = require('should');
var http = require('http');
var assert = require('assert');
var msRestAzure = require('ms-rest-azure');

var azureCompositeClient = require('../Expected/AcceptanceTests/AzureCompositeModelClient/azureCompositeModel');
var dummyToken = 'dummy12321343423';
var credentials = new msRestAzure.TokenCredentials(dummyToken);

var clientOptions = {};
var baseUri = 'http://localhost:3000';

describe('nodejs', function () {

  describe('Azure Composite Client', function () {
    var testClient = new azureCompositeClient(credentials, baseUri, clientOptions);
    it('should get and put valid basic type properties', function (done) {
      testClient.basicOperations.getValid(function (error, result) {
        should.not.exist(error);
        result.id.should.equal(2);
        result.name.should.equal('abc');
        result.color.should.equal('YELLOW');
        testClient.basicOperations.putValid({ 'id': 2, 'name': 'abc', color: 'Magenta' }, function (error, result) {
          should.not.exist(error);
github Azure / azure-sdk-for-java / AutoRest / Generators / NodeJS / Azure.NodeJS.Tests / AcceptanceTests / azureCustomBaseUri.js View on Github external
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

'use strict';

var should = require('should');
var http = require('http');
var util = require('util');
var assert = require('assert');
var msRestAzure = require('ms-rest-azure');

var customBaseUriClient = require('../Expected/AcceptanceTests/CustomBaseUri/autoRestParameterizedHostTestClient');
var dummySubscriptionId = '1234-5678-9012-3456';
var dummyToken = 'dummy12321343423';
var credentials = new msRestAzure.TokenCredentials(dummyToken);

var clientOptions = {};

describe('nodejs', function () {
  describe('Custom BaseUri Client', function () {
    clientOptions.host = 'host:3000';
    var testClient = new customBaseUriClient(credentials, clientOptions);
    it('should return 200', function (done) {
      testClient.paths.getEmpty('local', function (error, result, request, response) {
        should.not.exist(error);
        response.statusCode.should.equal(200);
        done();
      });
    });
    it('should throw due to bad "host", bad "account" and missing account', function (done) {
      testClient.host = 'nonexistent';
github Azure / azure-sdk-for-java / AutoRest / Generators / NodeJS / Azure.NodeJS.Tests / AcceptanceTests / paging.js View on Github external
// Licensed under the MIT License. See License.txt in the project root for license information.

'use strict';

var should = require('should');
var http = require('http');
var util = require('util');
var assert = require('assert');
var msRest = require('ms-rest');
var msRestAzure = require('ms-rest-azure');

var pagingClient = require('../Expected/AcceptanceTests/Paging/autoRestPagingTestService');

var dummySubscriptionId = 'a878ae02-6106-429z-9397-58091ee45g98';
var dummyToken = 'dummy12321343423';
var credentials = new msRestAzure.TokenCredentials(dummyToken);

var clientOptions = {};
var baseUri = 'http://localhost:3000';

describe('nodejs', function () {

  describe('Swagger Pageable BAT', function () {

    describe('Pageable Operations', function () {
      clientOptions.requestOptions = { jar: true };
      clientOptions.filters = [new msRest.ExponentialRetryPolicyFilter(3, 0, 0, 0)];
      clientOptions.noRetryPolicy = true;
      var testClient = new pagingClient(credentials, baseUri, clientOptions);

      it('should get single pages', function (done) {
        testClient.paging.getSinglePages(function (error, result) {
github Azure / autorest / src / generator / AutoRest.NodeJS.Azure.Tests / AcceptanceTests / paging.js View on Github external
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

'use strict';

var should = require('should');
var http = require('http');
var assert = require('assert');
var msRest = require('ms-rest');
var msRestAzure = require('ms-rest-azure');

var pagingClient = require('../Expected/AcceptanceTests/Paging/autoRestPagingTestService');

var dummySubscriptionId = 'a878ae02-6106-429z-9397-58091ee45g98';
var dummyToken = 'dummy12321343423';
var credentials = new msRestAzure.TokenCredentials(dummyToken);

var clientOptions = {};
var baseUri = 'http://localhost:3000';

describe('nodejs', function () {

  describe('Swagger Pageable BAT', function () {

    describe('Pageable Operations', function () {
      clientOptions.requestOptions = { jar: true };
      clientOptions.filters = [new msRest.ExponentialRetryPolicyFilter(3, 0, 0, 0)];
      clientOptions.noRetryPolicy = true;
      var testClient = new pagingClient(credentials, baseUri, clientOptions);

      it('should get single pages', function (done) {
        testClient.paging.getSinglePages(function (error, result) {
github Azure / azure-sdk-for-java / AutoRest / Generators / NodeJS / Azure.NodeJS.Tests / AcceptanceTests / coverage.js View on Github external
'use strict';

var should = require('should');
var http = require('http');
var util = require('util');
var assert = require('assert');
var _ = require('underscore')

var msRest = require('ms-rest');
var msRestAzure = require('ms-rest-azure');

var reportClient = require('../Expected/AcceptanceTests/AzureReport/autoRestReportServiceForAzure');

var dummySubscriptionId = 'a878ae02-6106-429z-9397-58091ee45g98';
var dummyToken = 'dummy12321343423';
var credentials = new msRestAzure.TokenCredentials(dummyToken);

var clientOptions = {};
var baseUri = 'http://localhost:3000';

describe('nodejs', function () {

  describe('Swagger BAT coverage report', function () {
    var testClient = new reportClient(credentials, baseUri, clientOptions);
    it('should have 100% coverage for Azure', function (done) {
      testClient.getReport(function (error, result) {
        should.not.exist(error);
        //console.log('The test coverage for azure is ' + util.inspect(result));
        var total = _.keys(result).length;
        var passed = 0;
        _.keys(result).forEach(function(item) {
          if (result[item] > 0) {
github Azure / azure-sdk-for-java / AutoRest / Generators / NodeJS / Azure.NodeJS.Tests / AcceptanceTests / head.js View on Github external

'use strict';

var should = require('should');
var http = require('http');
var util = require('util');
var assert = require('assert');
var msRest = require('ms-rest');
var msRestAzure = require('ms-rest-azure');

var headClient = require('../Expected/AcceptanceTests/Head/autoRestHeadTestService');
var headExceptionClient = require('../Expected/AcceptanceTests/HeadExceptions/autoRestHeadExceptionTestService');

var dummySubscriptionId = 'a878ae02-6106-429z-9397-58091ee45g98';
var dummyToken = 'dummy12321343423';
var credentials = new msRestAzure.TokenCredentials(dummyToken);

var clientOptions = {};
var baseUri = 'http://localhost:3000';

describe('nodejs', function () {

  describe('Swagger Head BAT', function () {

    describe('Head Operations', function () {
      var testOptions = clientOptions;
      testOptions.requestOptions = { jar: true };
      testOptions.filters = [new msRest.ExponentialRetryPolicyFilter(3, 0, 0, 0)];
      testOptions.noRetryPolicy = true;
      var testClient = new headClient(credentials, baseUri, clientOptions);

      it('should return true for 200 status code', function (done) {