{"action":"created","comment":{"url":"https://api.github.com/repos/Azure/azure-sdk-for-node/pulls/comments/37210960","id":37210960,"diff_hunk":"@@ -0,0 +1,527 @@\n+// \n+// Copyright (c) Microsoft and contributors.  All rights reserved.\n+// \n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//   http://www.apache.org/licenses/LICENSE-2.0\n+// \n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// \n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+// \n+\n+\n+var fs = require('fs');\n+var path = require('path');\n+var sinon = require('sinon');\n+var _ = require('underscore');\n+var util = require('util');\n+var FileTokenCache = require('../../lib/util/fileTokenCache');\n+var MockTokenCache = require('./mock-token-cache');\n+var nockHelper = require('./nock-helper');\n+var msRestAzure = require('ms-rest-azure');\n+var ResourceManagementClient = require('../../lib/services/resourceManagement/lib/resource/resourceManagementClient');\n+\n+/**\n+ * @class\n+ * Initializes a new instance of the ArmTestUtils class.\n+ * @constructor\n+ * \n+ * @param {object} mochaSuiteObject - The mocha suite object\n+ *\n+ * @param {string} testPrefix - The prefix to use for the test suite\n+ * \n+ * @param {Array} env - (Optional) Array of environment variables required by the test\n+ * Example:\n+ * [\n+ *   { requiresToken: true },\n+ *   { name: 'AZURE_ARM_TEST_LOCATION', defaultValue: 'West US' },\n+ *   { name: 'AZURE_AD_TEST_PASSWORD'},\n+ * ];\n+ */\n+function ArmTestUtils(mochaSuiteObject, testPrefix, env) {\n+  this.mochaSuiteObject = mochaSuiteObject;\n+  this.testPrefix = this.normalizeTestName(testPrefix);\n+  this.mockServerClient;\n+  this.currentTest = '';\n+  this.scopeWritten;\n+  //Recording info\n+  this.setRecordingsDirectory(__dirname + '/../recordings/' + this.testPrefix + '/');\n+  this.suiteRecordingsFile = this.getRecordingsDirectory() + 'suite.' + this.testPrefix + '.nock.js';\n+  this.recordingsFile = __dirname + '/../recordings/' + this.testPrefix + '.nock.js';\n+  //test modes\n+  this.isMocked = !process.env.NOCK_OFF;\n+  this.isRecording = process.env.AZURE_NOCK_RECORD;\n+  this.isPlayback = !process.env.NOCK_OFF && !process.env.AZURE_NOCK_RECORD;\n+  //authentication info\n+  this.subscriptionId = process.env['AZURE_SUBSCRIPTION_ID'] || 'subscription-id';\n+  this.clientId = process.env['CLIENT_ID'] || 'client-id';\n+  this.domain = process.env['DOMAIN'] || 'domain';\n+  this.username = process.env['USERNAME'] || 'username@example.com';\n+  this.password = process.env['PASSWORD'] || 'dummypassword';\n+  this.secret = process.env['APPLICATION_SECRET'] || 'dummysecret';\n+  this.clientRedirectUri = process.env['CLIENT_REDIRECT_URI'] || 'clientRedirectUri';\n+  this.tokenCache = new FileTokenCache(this.getTockenCacheFilePath());\n+  //subscriptionId should be recorded for playback\n+  env.push('AZURE_SUBSCRIPTION_ID');\n+  // Normalize environment\n+  this.normalizeEnvironment(env);\n+  this.validateEnvironment();\n+  //track & restore generated uuids to be used as part of request url, like a RBAC role assignment name\n+  this.uuidsGenerated = [];\n+  this.currentUuid = 0;\n+  this.randomTestIdsGenerated = [];\n+  this.numberOfRandomTestIdGenerated = 0;\n+  //stub necessary methods if in playback mode\n+  this._stubMethods();\n+}\n+\n+_.extend(ArmTestUtils.prototype, {\n+  _stubMethods: function () {\n+    if (this.isPlayback) {\n+      sinon.stub(msRestAzure.UserTokenCredentials.prototype, 'signRequest', function (webResource, callback) {\n+        return callback(null);\n+      });\n+\n+      sinon.stub(msRestAzure.ApplicationTokenCredentials.prototype, 'signRequest', function (webResource, callback) {\n+        return callback(null);\n+      });\n+\n+      sinon.stub(this, 'createResourcegroup', function (groupName, location, callback) {\n+        return callback(null);\n+      });\n+\n+      sinon.stub(this, 'deleteResourcegroup', function (groupName, callback) {\n+        return callback(null);\n+      });\n+    }\n+  },\n+  \n+  _setupResourceManagementClient: function () {\n+   this.resourceManagement = new ResourceManagementClient(this.createUserCredentials(), this.subscriptionId);\n+   if (this.isPlayback) {\n+    this.resourceManagement.longRunningOperationRetryTimeoutInSeconds = 0;\n+   }\n+  },\n+\n+  createResourcegroup: function (groupName, location, callback) {\n+    console.log('Creating Resource Group: ' + groupName);\n+    //if (!this.isPlayback) {","path":"test/framework/arm-test-utils.js","position":113,"original_position":113,"commit_id":"13e4086fd53bb805b482a11d1494ceb6b5cb5bde","original_commit_id":"13e4086fd53bb805b482a11d1494ceb6b5cb5bde","user":{"login":"yugangw-msft","id":6014209,"avatar_url":"https://avatars.githubusercontent.com/u/6014209?v=3","gravatar_id":"","url":"https://api.github.com/users/yugangw-msft","html_url":"https://github.com/yugangw-msft","followers_url":"https://api.github.com/users/yugangw-msft/followers","following_url":"https://api.github.com/users/yugangw-msft/following{/other_user}","gists_url":"https://api.github.com/users/yugangw-msft/gists{/gist_id}","starred_url":"https://api.github.com/users/yugangw-msft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yugangw-msft/subscriptions","organizations_url":"https://api.github.com/users/yugangw-msft/orgs","repos_url":"https://api.github.com/users/yugangw-msft/repos","events_url":"https://api.github.com/users/yugangw-msft/events{/privacy}","received_events_url":"https://api.github.com/users/yugangw-msft/received_events","type":"User","site_admin":false},"body":"i assume you re using the \"stub\" option? So the commented out check will eventually be gone?","created_at":"2015-08-17T17:10:06Z","updated_at":"2015-08-17T17:10:06Z","html_url":"https://github.com/Azure/azure-sdk-for-node/pull/1485#discussion_r37210960","pull_request_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/pulls/1485","_links":{"self":{"href":"https://api.github.com/repos/Azure/azure-sdk-for-node/pulls/comments/37210960"},"html":{"href":"https://github.com/Azure/azure-sdk-for-node/pull/1485#discussion_r37210960"},"pull_request":{"href":"https://api.github.com/repos/Azure/azure-sdk-for-node/pulls/1485"}}},"pull_request":{"url":"https://api.github.com/repos/Azure/azure-sdk-for-node/pulls/1485","id":42605705,"html_url":"https://github.com/Azure/azure-sdk-for-node/pull/1485","diff_url":"https://github.com/Azure/azure-sdk-for-node/pull/1485.diff","patch_url":"https://github.com/Azure/azure-sdk-for-node/pull/1485.patch","issue_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/issues/1485","number":1485,"state":"open","locked":false,"title":"test infrastructure improvements","user":{"login":"amarzavery","id":4521223,"avatar_url":"https://avatars.githubusercontent.com/u/4521223?v=3","gravatar_id":"","url":"https://api.github.com/users/amarzavery","html_url":"https://github.com/amarzavery","followers_url":"https://api.github.com/users/amarzavery/followers","following_url":"https://api.github.com/users/amarzavery/following{/other_user}","gists_url":"https://api.github.com/users/amarzavery/gists{/gist_id}","starred_url":"https://api.github.com/users/amarzavery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amarzavery/subscriptions","organizations_url":"https://api.github.com/users/amarzavery/orgs","repos_url":"https://api.github.com/users/amarzavery/repos","events_url":"https://api.github.com/users/amarzavery/events{/privacy}","received_events_url":"https://api.github.com/users/amarzavery/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-08-17T16:14:16Z","updated_at":"2015-08-17T17:10:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f84afc77debaecfe728da0047e0fe7b132e0362c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/pulls/1485/commits","review_comments_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/pulls/1485/comments","review_comment_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/issues/1485/comments","statuses_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/statuses/13e4086fd53bb805b482a11d1494ceb6b5cb5bde","head":{"label":"amarzavery:adal","ref":"adal","sha":"13e4086fd53bb805b482a11d1494ceb6b5cb5bde","user":{"login":"amarzavery","id":4521223,"avatar_url":"https://avatars.githubusercontent.com/u/4521223?v=3","gravatar_id":"","url":"https://api.github.com/users/amarzavery","html_url":"https://github.com/amarzavery","followers_url":"https://api.github.com/users/amarzavery/followers","following_url":"https://api.github.com/users/amarzavery/following{/other_user}","gists_url":"https://api.github.com/users/amarzavery/gists{/gist_id}","starred_url":"https://api.github.com/users/amarzavery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amarzavery/subscriptions","organizations_url":"https://api.github.com/users/amarzavery/orgs","repos_url":"https://api.github.com/users/amarzavery/repos","events_url":"https://api.github.com/users/amarzavery/events{/privacy}","received_events_url":"https://api.github.com/users/amarzavery/received_events","type":"User","site_admin":false},"repo":{"id":17145836,"name":"azure-sdk-for-node","full_name":"amarzavery/azure-sdk-for-node","owner":{"login":"amarzavery","id":4521223,"avatar_url":"https://avatars.githubusercontent.com/u/4521223?v=3","gravatar_id":"","url":"https://api.github.com/users/amarzavery","html_url":"https://github.com/amarzavery","followers_url":"https://api.github.com/users/amarzavery/followers","following_url":"https://api.github.com/users/amarzavery/following{/other_user}","gists_url":"https://api.github.com/users/amarzavery/gists{/gist_id}","starred_url":"https://api.github.com/users/amarzavery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amarzavery/subscriptions","organizations_url":"https://api.github.com/users/amarzavery/orgs","repos_url":"https://api.github.com/users/amarzavery/repos","events_url":"https://api.github.com/users/amarzavery/events{/privacy}","received_events_url":"https://api.github.com/users/amarzavery/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/amarzavery/azure-sdk-for-node","description":"Windows Azure SDK for Node.js","fork":true,"url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node","forks_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/forks","keys_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/teams","hooks_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/hooks","issue_events_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/issues/events{/number}","events_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/events","assignees_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/assignees{/user}","branches_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/branches{/branch}","tags_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/tags","blobs_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/git/refs{/sha}","trees_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/statuses/{sha}","languages_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/languages","stargazers_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/stargazers","contributors_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/contributors","subscribers_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/subscribers","subscription_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/subscription","commits_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/commits{/sha}","git_commits_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/git/commits{/sha}","comments_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/comments{/number}","issue_comment_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/issues/comments{/number}","contents_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/contents/{+path}","compare_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/merges","archive_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/downloads","issues_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/issues{/number}","pulls_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/pulls{/number}","milestones_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/milestones{/number}","notifications_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/labels{/name}","releases_url":"https://api.github.com/repos/amarzavery/azure-sdk-for-node/releases{/id}","created_at":"2014-02-24T18:19:10Z","updated_at":"2014-11-20T03:02:53Z","pushed_at":"2015-08-17T09:06:16Z","git_url":"git://github.com/amarzavery/azure-sdk-for-node.git","ssh_url":"git@github.com:amarzavery/azure-sdk-for-node.git","clone_url":"https://github.com/amarzavery/azure-sdk-for-node.git","svn_url":"https://github.com/amarzavery/azure-sdk-for-node","homepage":"http://www.windowsazure.com/en-us/develop/nodejs/","size":15883,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":0,"forks":3,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Azure:autorest","ref":"autorest","sha":"b6ef86c5dbfe78777dd96b88e9a9f7200b8c52de","user":{"login":"Azure","id":6844498,"avatar_url":"https://avatars.githubusercontent.com/u/6844498?v=3","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"repo":{"id":2950981,"name":"azure-sdk-for-node","full_name":"Azure/azure-sdk-for-node","owner":{"login":"Azure","id":6844498,"avatar_url":"https://avatars.githubusercontent.com/u/6844498?v=3","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Azure/azure-sdk-for-node","description":"Azure SDK for Node.js","fork":false,"url":"https://api.github.com/repos/Azure/azure-sdk-for-node","forks_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/forks","keys_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/teams","hooks_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/hooks","issue_events_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/issues/events{/number}","events_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/events","assignees_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/assignees{/user}","branches_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/branches{/branch}","tags_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/tags","blobs_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/git/refs{/sha}","trees_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/statuses/{sha}","languages_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/languages","stargazers_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/stargazers","contributors_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/contributors","subscribers_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/subscribers","subscription_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/subscription","commits_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/commits{/sha}","git_commits_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/git/commits{/sha}","comments_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/comments{/number}","issue_comment_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/issues/comments{/number}","contents_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/contents/{+path}","compare_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/merges","archive_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/downloads","issues_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/issues{/number}","pulls_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/pulls{/number}","milestones_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/milestones{/number}","notifications_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/labels{/name}","releases_url":"https://api.github.com/repos/Azure/azure-sdk-for-node/releases{/id}","created_at":"2011-12-09T23:38:42Z","updated_at":"2015-08-13T22:19:56Z","pushed_at":"2015-08-17T16:14:16Z","git_url":"git://github.com/Azure/azure-sdk-for-node.git","ssh_url":"git@github.com:Azure/azure-sdk-for-node.git","clone_url":"https://github.com/Azure/azure-sdk-for-node.git","svn_url":"https://github.com/Azure/azure-sdk-for-node","homepage":"http://azure.github.io/azure-sdk-for-node/","size":24034,"stargazers_count":616,"watchers_count":616,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":222,"mirror_url":null,"open_issues_count":33,"forks":222,"open_issues":33,"watchers":616,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Azure/azure-sdk-for-node/pulls/1485"},"html":{"href":"https://github.com/Azure/azure-sdk-for-node/pull/1485"},"issue":{"href":"https://api.github.com/repos/Azure/azure-sdk-for-node/issues/1485"},"comments":{"href":"https://api.github.com/repos/Azure/azure-sdk-for-node/issues/1485/comments"},"review_comments":{"href":"https://api.github.com/repos/Azure/azure-sdk-for-node/pulls/1485/comments"},"review_comment":{"href":"https://api.github.com/repos/Azure/azure-sdk-for-node/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Azure/azure-sdk-for-node/pulls/1485/commits"},"statuses":{"href":"https://api.github.com/repos/Azure/azure-sdk-for-node/statuses/13e4086fd53bb805b482a11d1494ceb6b5cb5bde"}}}}