From 915461920f2a8165f69eab7534f857391b41919d Mon Sep 17 00:00:00 2001 From: amolr Date: Tue, 18 Apr 2017 17:34:37 -0700 Subject: [PATCH] Adding Support for HTTP 2 APNS Authentication --- gulpfile.js | 2 +- .../lib/models/apnsCredential.js | 39 ++++++++++++++ .../lib/models/index.d.ts | 51 +++++++++++++++++++ ...notificationHubCreateOrUpdateParameters.js | 12 +++++ .../lib/models/notificationHubResource.js | 12 +++++ .../lib/models/pnsCredentialsResource.js | 12 +++++ .../lib/notificationHubsManagementClient.js | 2 +- .../lib/operations/index.d.ts | 26 ++++++++++ .../lib/operations/notificationHubs.js | 39 ++++++++++++++ nodeSDK.njsproj | 15 +++++- npm-debug.log | 48 +++++++++++++++++ .../notificationHub-tests.js | 13 ++++- 12 files changed, 266 insertions(+), 5 deletions(-) create mode 100644 npm-debug.log diff --git a/gulpfile.js b/gulpfile.js index a60e6da5a..b78e56b53 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -205,7 +205,7 @@ const mappings = { 'notificationhubs': { 'packageName': 'azure-arm-notificationhubs', 'dir': 'notificationHubsManagement/lib', - 'source': 'arm-notificationhubs/2016-03-01/swagger/notificationhubs.json' + 'source': 'arm-notificationhubs/2017-04-01/swagger/notificationhubs.json' }, 'operationalinsights': { 'packageName': 'azure-arm-operationalinsights', diff --git a/lib/services/notificationHubsManagement/lib/models/apnsCredential.js b/lib/services/notificationHubsManagement/lib/models/apnsCredential.js index 780551cc4..fb57abad5 100644 --- a/lib/services/notificationHubsManagement/lib/models/apnsCredential.js +++ b/lib/services/notificationHubsManagement/lib/models/apnsCredential.js @@ -24,6 +24,17 @@ * * @member {string} [thumbprint] The Apns certificate Thumbprint * + * @member {string} [keyId] A 10-character key identifier (kid) key, obtained + * from your developer account + * + * @member {string} [appName] The name of the application + * + * @member {string} [appId] The issuer (iss) registered claim key, whose value + * is your 10-character Team ID, obtained from your developer account + * + * @member {string} [token] Provider Authentication Token, obtained through + * your developer account + * */ class ApnsCredential { constructor() { @@ -70,6 +81,34 @@ class ApnsCredential { type: { name: 'String' } + }, + keyId: { + required: false, + serializedName: 'properties.keyId', + type: { + name: 'String' + } + }, + appName: { + required: false, + serializedName: 'properties.appName', + type: { + name: 'String' + } + }, + appId: { + required: false, + serializedName: 'properties.appId', + type: { + name: 'String' + } + }, + token: { + required: false, + serializedName: 'properties.token', + type: { + name: 'String' + } } } } diff --git a/lib/services/notificationHubsManagement/lib/models/index.d.ts b/lib/services/notificationHubsManagement/lib/models/index.d.ts index 5d554446b..6302b602a 100644 --- a/lib/services/notificationHubsManagement/lib/models/index.d.ts +++ b/lib/services/notificationHubsManagement/lib/models/index.d.ts @@ -402,12 +402,27 @@ export interface PolicykeyResource { * * @member {string} [thumbprint] The Apns certificate Thumbprint * + * @member {string} [keyId] A 10-character key identifier (kid) key, obtained + * from your developer account + * + * @member {string} [appName] The name of the application + * + * @member {string} [appId] The issuer (iss) registered claim key, whose value + * is your 10-character Team ID, obtained from your developer account + * + * @member {string} [token] Provider Authentication Token, obtained through + * your developer account + * */ export interface ApnsCredential { apnsCertificate?: string; certificateKey?: string; endpoint?: string; thumbprint?: string; + keyId?: string; + appName?: string; + appId?: string; + token?: string; } /** @@ -528,6 +543,18 @@ export interface BaiduCredential { * * @member {string} [apnsCredential.thumbprint] The Apns certificate Thumbprint * + * @member {string} [apnsCredential.keyId] A 10-character key identifier (kid) + * key, obtained from your developer account + * + * @member {string} [apnsCredential.appName] The name of the application + * + * @member {string} [apnsCredential.appId] The issuer (iss) registered claim + * key, whose value is your 10-character Team ID, obtained from your developer + * account + * + * @member {string} [apnsCredential.token] Provider Authentication Token, + * obtained through your developer account + * * @member {object} [wnsCredential] The WnsCredential of the created * NotificationHub * @@ -614,6 +641,18 @@ export interface NotificationHubCreateOrUpdateParameters extends Resource { * * @member {string} [apnsCredential.thumbprint] The Apns certificate Thumbprint * + * @member {string} [apnsCredential.keyId] A 10-character key identifier (kid) + * key, obtained from your developer account + * + * @member {string} [apnsCredential.appName] The name of the application + * + * @member {string} [apnsCredential.appId] The issuer (iss) registered claim + * key, whose value is your 10-character Team ID, obtained from your developer + * account + * + * @member {string} [apnsCredential.token] Provider Authentication Token, + * obtained through your developer account + * * @member {object} [wnsCredential] The WnsCredential of the created * NotificationHub * @@ -692,6 +731,18 @@ export interface NotificationHubResource extends Resource { * * @member {string} [apnsCredential.thumbprint] The Apns certificate Thumbprint * + * @member {string} [apnsCredential.keyId] A 10-character key identifier (kid) + * key, obtained from your developer account + * + * @member {string} [apnsCredential.appName] The name of the application + * + * @member {string} [apnsCredential.appId] The issuer (iss) registered claim + * key, whose value is your 10-character Team ID, obtained from your developer + * account + * + * @member {string} [apnsCredential.token] Provider Authentication Token, + * obtained through your developer account + * * @member {object} [wnsCredential] The WnsCredential of the created * NotificationHub * diff --git a/lib/services/notificationHubsManagement/lib/models/notificationHubCreateOrUpdateParameters.js b/lib/services/notificationHubsManagement/lib/models/notificationHubCreateOrUpdateParameters.js index 26a2c7ff5..b63c22c47 100644 --- a/lib/services/notificationHubsManagement/lib/models/notificationHubCreateOrUpdateParameters.js +++ b/lib/services/notificationHubsManagement/lib/models/notificationHubCreateOrUpdateParameters.js @@ -38,6 +38,18 @@ const models = require('./index'); * * @member {string} [apnsCredential.thumbprint] The Apns certificate Thumbprint * + * @member {string} [apnsCredential.keyId] A 10-character key identifier (kid) + * key, obtained from your developer account + * + * @member {string} [apnsCredential.appName] The name of the application + * + * @member {string} [apnsCredential.appId] The issuer (iss) registered claim + * key, whose value is your 10-character Team ID, obtained from your developer + * account + * + * @member {string} [apnsCredential.token] Provider Authentication Token, + * obtained through your developer account + * * @member {object} [wnsCredential] The WnsCredential of the created * NotificationHub * diff --git a/lib/services/notificationHubsManagement/lib/models/notificationHubResource.js b/lib/services/notificationHubsManagement/lib/models/notificationHubResource.js index 6fa70516a..98c4b1146 100644 --- a/lib/services/notificationHubsManagement/lib/models/notificationHubResource.js +++ b/lib/services/notificationHubsManagement/lib/models/notificationHubResource.js @@ -37,6 +37,18 @@ const models = require('./index'); * * @member {string} [apnsCredential.thumbprint] The Apns certificate Thumbprint * + * @member {string} [apnsCredential.keyId] A 10-character key identifier (kid) + * key, obtained from your developer account + * + * @member {string} [apnsCredential.appName] The name of the application + * + * @member {string} [apnsCredential.appId] The issuer (iss) registered claim + * key, whose value is your 10-character Team ID, obtained from your developer + * account + * + * @member {string} [apnsCredential.token] Provider Authentication Token, + * obtained through your developer account + * * @member {object} [wnsCredential] The WnsCredential of the created * NotificationHub * diff --git a/lib/services/notificationHubsManagement/lib/models/pnsCredentialsResource.js b/lib/services/notificationHubsManagement/lib/models/pnsCredentialsResource.js index 943d184fb..b6b4393ba 100644 --- a/lib/services/notificationHubsManagement/lib/models/pnsCredentialsResource.js +++ b/lib/services/notificationHubsManagement/lib/models/pnsCredentialsResource.js @@ -29,6 +29,18 @@ const models = require('./index'); * * @member {string} [apnsCredential.thumbprint] The Apns certificate Thumbprint * + * @member {string} [apnsCredential.keyId] A 10-character key identifier (kid) + * key, obtained from your developer account + * + * @member {string} [apnsCredential.appName] The name of the application + * + * @member {string} [apnsCredential.appId] The issuer (iss) registered claim + * key, whose value is your 10-character Team ID, obtained from your developer + * account + * + * @member {string} [apnsCredential.token] Provider Authentication Token, + * obtained through your developer account + * * @member {object} [wnsCredential] The WnsCredential of the created * NotificationHub * diff --git a/lib/services/notificationHubsManagement/lib/notificationHubsManagementClient.js b/lib/services/notificationHubsManagement/lib/notificationHubsManagementClient.js index aa10d23be..bc3e9fcd4 100644 --- a/lib/services/notificationHubsManagement/lib/notificationHubsManagementClient.js +++ b/lib/services/notificationHubsManagement/lib/notificationHubsManagementClient.js @@ -64,7 +64,7 @@ class NotificationHubsManagementClient extends ServiceClient { super(credentials, options); - this.apiVersion = '2016-03-01'; + this.apiVersion = '2016-03-01';//'2017-04-01'; this.acceptLanguage = 'en-US'; this.longRunningOperationRetryTimeout = 30; this.generateClientRequestId = true; diff --git a/lib/services/notificationHubsManagement/lib/operations/index.d.ts b/lib/services/notificationHubsManagement/lib/operations/index.d.ts index 3e13132f9..073939f7a 100644 --- a/lib/services/notificationHubsManagement/lib/operations/index.d.ts +++ b/lib/services/notificationHubsManagement/lib/operations/index.d.ts @@ -1453,6 +1453,19 @@ export interface NotificationHubs { * @param {string} [parameters.apnsCredential.thumbprint] The Apns certificate * Thumbprint * + * @param {string} [parameters.apnsCredential.keyId] A 10-character key + * identifier (kid) key, obtained from your developer account + * + * @param {string} [parameters.apnsCredential.appName] The name of the + * application + * + * @param {string} [parameters.apnsCredential.appId] The issuer (iss) + * registered claim key, whose value is your 10-character Team ID, obtained + * from your developer account + * + * @param {string} [parameters.apnsCredential.token] Provider Authentication + * Token, obtained through your developer account + * * @param {object} [parameters.wnsCredential] The WnsCredential of the created * NotificationHub * @@ -1569,6 +1582,19 @@ export interface NotificationHubs { * @param {string} [parameters.apnsCredential.thumbprint] The Apns certificate * Thumbprint * + * @param {string} [parameters.apnsCredential.keyId] A 10-character key + * identifier (kid) key, obtained from your developer account + * + * @param {string} [parameters.apnsCredential.appName] The name of the + * application + * + * @param {string} [parameters.apnsCredential.appId] The issuer (iss) + * registered claim key, whose value is your 10-character Team ID, obtained + * from your developer account + * + * @param {string} [parameters.apnsCredential.token] Provider Authentication + * Token, obtained through your developer account + * * @param {object} [parameters.wnsCredential] The WnsCredential of the created * NotificationHub * diff --git a/lib/services/notificationHubsManagement/lib/operations/notificationHubs.js b/lib/services/notificationHubsManagement/lib/operations/notificationHubs.js index 896c7bd20..2297d0604 100644 --- a/lib/services/notificationHubsManagement/lib/operations/notificationHubs.js +++ b/lib/services/notificationHubsManagement/lib/operations/notificationHubs.js @@ -237,6 +237,19 @@ function _checkAvailability(resourceGroupName, namespaceName, parameters, option * @param {string} [parameters.apnsCredential.thumbprint] The Apns certificate * Thumbprint * + * @param {string} [parameters.apnsCredential.keyId] A 10-character key + * identifier (kid) key, obtained from your developer account + * + * @param {string} [parameters.apnsCredential.appName] The name of the + * application + * + * @param {string} [parameters.apnsCredential.appId] The issuer (iss) + * registered claim key, whose value is your 10-character Team ID, obtained + * from your developer account + * + * @param {string} [parameters.apnsCredential.token] Provider Authentication + * Token, obtained through your developer account + * * @param {object} [parameters.wnsCredential] The WnsCredential of the created * NotificationHub * @@ -2510,6 +2523,19 @@ class NotificationHubs { * @param {string} [parameters.apnsCredential.thumbprint] The Apns certificate * Thumbprint * + * @param {string} [parameters.apnsCredential.keyId] A 10-character key + * identifier (kid) key, obtained from your developer account + * + * @param {string} [parameters.apnsCredential.appName] The name of the + * application + * + * @param {string} [parameters.apnsCredential.appId] The issuer (iss) + * registered claim key, whose value is your 10-character Team ID, obtained + * from your developer account + * + * @param {string} [parameters.apnsCredential.token] Provider Authentication + * Token, obtained through your developer account + * * @param {object} [parameters.wnsCredential] The WnsCredential of the created * NotificationHub * @@ -2638,6 +2664,19 @@ class NotificationHubs { * @param {string} [parameters.apnsCredential.thumbprint] The Apns certificate * Thumbprint * + * @param {string} [parameters.apnsCredential.keyId] A 10-character key + * identifier (kid) key, obtained from your developer account + * + * @param {string} [parameters.apnsCredential.appName] The name of the + * application + * + * @param {string} [parameters.apnsCredential.appId] The issuer (iss) + * registered claim key, whose value is your 10-character Team ID, obtained + * from your developer account + * + * @param {string} [parameters.apnsCredential.token] Provider Authentication + * Token, obtained through your developer account + * * @param {object} [parameters.wnsCredential] The WnsCredential of the created * NotificationHub * diff --git a/nodeSDK.njsproj b/nodeSDK.njsproj index 0d8962721..c7f09f44b 100644 --- a/nodeSDK.njsproj +++ b/nodeSDK.njsproj @@ -16,6 +16,13 @@ true 11.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + False + AZURE_SUBSCRIPTION_ID=2cac2a14-ba6b-46a6-bce8-2d9781a41ba2 +CLIENT_ID=0e44d72c-4a92-4fd0-a640-d165dde5da87 +DOMAIN=microsoft.com +APPLICATION_SECRET=KsQw6kI7QKLair8uZkqFkMblh2ryIkJB98usb6xr2wU= +NOCK_OFF=true + @@ -1532,8 +1539,12 @@ - - + + Mocha + + + Mocha + Mocha diff --git a/npm-debug.log b/npm-debug.log new file mode 100644 index 000000000..6ae2ccf78 --- /dev/null +++ b/npm-debug.log @@ -0,0 +1,48 @@ +0 info it worked if it ends with ok +1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe', +1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', +1 verbose cli 'run', +1 verbose cli 'unit-arm' ] +2 info using npm@3.10.10 +3 info using node@v6.10.2 +4 verbose run-script [ 'preunit-arm', 'unit-arm', 'postunit-arm' ] +5 info lifecycle azure@2.0.0-preview~preunit-arm: azure@2.0.0-preview +6 silly lifecycle azure@2.0.0-preview~preunit-arm: no script for preunit-arm, continuing +7 info lifecycle azure@2.0.0-preview~unit-arm: azure@2.0.0-preview +8 verbose lifecycle azure@2.0.0-preview~unit-arm: unsafe-perm in lifecycle true +9 verbose lifecycle azure@2.0.0-preview~unit-arm: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;E:\AzureSDKNode\azure-sdk-for-node\node_modules\.bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;c:\Program Files (x86)\HP\HP Performance Advisor;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files\Git\cmd;C:\Program Files (x86)\GitExtensions\;C:\Program Files\dotnet\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft SDKs\Azure\CLI\wbin;C:\ProgramData\chocolatey\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\Git\cmd;C:\Users\amolr\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Program Files (x86)\MSBuild\14.0\Bin;C:\Program Files (x86)\WiX Toolset v3.8\bin;E:\Nuget.exe;C:\Users\amolr\AppData\Roaming\npm +10 verbose lifecycle azure@2.0.0-preview~unit-arm: CWD: E:\AzureSDKNode\azure-sdk-for-node +11 silly lifecycle azure@2.0.0-preview~unit-arm: Args: [ '/d /s /c', 'node scripts/unit-arm.js testlistarm.txt' ] +12 silly lifecycle azure@2.0.0-preview~unit-arm: Returned: code: 1 signal: null +13 info lifecycle azure@2.0.0-preview~unit-arm: Failed to exec unit-arm script +14 verbose stack Error: azure@2.0.0-preview unit-arm: `node scripts/unit-arm.js testlistarm.txt` +14 verbose stack Exit status 1 +14 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:255:16) +14 verbose stack at emitTwo (events.js:106:13) +14 verbose stack at EventEmitter.emit (events.js:191:7) +14 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:40:14) +14 verbose stack at emitTwo (events.js:106:13) +14 verbose stack at ChildProcess.emit (events.js:191:7) +14 verbose stack at maybeClose (internal/child_process.js:886:16) +14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5) +15 verbose pkgid azure@2.0.0-preview +16 verbose cwd E:\AzureSDKNode\azure-sdk-for-node +17 error Windows_NT 10.0.14393 +18 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "unit-arm" +19 error node v6.10.2 +20 error npm v3.10.10 +21 error code ELIFECYCLE +22 error azure@2.0.0-preview unit-arm: `node scripts/unit-arm.js testlistarm.txt` +22 error Exit status 1 +23 error Failed at the azure@2.0.0-preview unit-arm script 'node scripts/unit-arm.js testlistarm.txt'. +23 error Make sure you have the latest version of node.js and npm installed. +23 error If you do, this is most likely a problem with the azure package, +23 error not with npm itself. +23 error Tell the author that this fails on your system: +23 error node scripts/unit-arm.js testlistarm.txt +23 error You can get information on how to open an issue for this project with: +23 error npm bugs azure +23 error Or if that isn't available, you can get their info via: +23 error npm owner ls azure +23 error There is likely additional logging output above. +24 verbose exit [ 1, true ] diff --git a/test/services/notificationHubsManagement/notificationHub-tests.js b/test/services/notificationHubsManagement/notificationHub-tests.js index b1d38bbfc..1c7fc0e57 100644 --- a/test/services/notificationHubsManagement/notificationHub-tests.js +++ b/test/services/notificationHubsManagement/notificationHub-tests.js @@ -71,6 +71,13 @@ describe('Notification Hubs Management', function () { packageSid : 'ms-app://s-1-15-2-1817505189-427745171-3213743798-2985869298-800724128-1004923984-4143860699', secretKey : 'w7TBprR-THIS-IS-DUMMY-KEYAzSYFhp', windowsLiveEndpoint : 'http://pushtestservice.cloudapp.net/LiveID/accesstoken.srf' + }, + apnsCredential: { + token: "MIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgpVB15km4qskA5Ra5XvdtOwWPvaXIhVVQZdonzINh + hGgCgYIKoZIzj0DAQehRANCAASS3ek04J20BqA6WWDlD6 + xd3dJEifhW87wI0nnkfUB8LDb424TiWlzGIgnxV79hb3QHCAUNsPdBfLLF + Od8yqL", + appName: "Sample", + appId: "EF9WEB9D5K", + keyId: "TXRXD9P6K7", + endpoint: "https://api.push.apple.com:443/3/device" } }; @@ -178,7 +185,11 @@ describe('Notification Hubs Management', function () { nhub.wnsCredential.secretKey.should.equal(createNotificationHubParameters.wnsCredential.secretKey); nhub.wnsCredential.packageSid.should.equal(createNotificationHubParameters.wnsCredential.packageSid); nhub.wnsCredential.windowsLiveEndpoint.should.equal(createNotificationHubParameters.wnsCredential.windowsLiveEndpoint); - + nhub.apnsCredential.keyId.should.equal(createNotificationHubParameters.apnsCredential.keyId); + nhub.apnsCredential.appId.should.equal(createNotificationHubParameters.apnsCredential.appId); + nhub.apnsCredential.appName.should.equal(createNotificationHubParameters.apnsCredential.appName); + nhub.apnsCredential.token.should.equal(createNotificationHubParameters.apnsCredential.token); + nhub.apnsCredential.endpoint.should.equal(createNotificationHubParameters.apnsCredential.endpoint); //console.log("Create Notification Hub Authorization Rules : " + authorizationRuleName); client.notificationHubs.createOrUpdateAuthorizationRule(groupName, namespaceName, notificationHubName, authorizationRuleName, authRuleParameter, function (err, result, request, response) { should.not.exist(err);