|
| 1 | +/* eslint-disable no-mixed-spaces-and-tabs */ |
| 2 | +/* eslint-disable no-tabs */ |
1 | 3 | const cloudinary = require("../../../../cloudinary"); |
2 | 4 | const TIMEOUT = require('../../../testUtils/testConstants').TIMEOUT; |
3 | 5 | let runOnlyForInternalPRs = process.env.TRAVIS_SECURE_ENV_VARS ? describe : describe.skip; |
4 | 6 |
|
5 | 7 |
|
6 | | -describe.skip('Provisioning API - Access Keys Management', function () { |
| 8 | +describe('Provisioning API - Access Keys Management', function () { |
7 | 9 | let CLOUD_SECRET; |
8 | 10 | let CLOUD_API; |
9 | 11 | let CLOUD_NAME; |
10 | 12 | let CLOUD_ID; |
11 | 13 | let CLOUD_NAME_PREFIX = `justaname${process.hrtime()[1] % 10000}`; |
12 | 14 | this.timeout(TIMEOUT.LONG); |
13 | 15 |
|
14 | | - before("Setup the required test", async () => { |
| 16 | + before("Setup the required test", async function (){ |
15 | 17 | let config = cloudinary.config(true); |
16 | 18 | if (!(config.provisioning_api_key && config.provisioning_api_secret && config.account_id)) { |
17 | 19 | // For external PRs the env variables are not availble, so we skip the provisioning API |
@@ -86,16 +88,45 @@ describe.skip('Provisioning API - Access Keys Management', function () { |
86 | 88 | expect(Object.keys(accessKeys.access_keys[0])).to.eql(['name', 'api_key', 'api_secret', 'created_at', 'updated_at', 'enabled']); |
87 | 89 | }); |
88 | 90 |
|
89 | | - it('Update access key', async () => { |
90 | | - const keyName = `test-access-key-${Date.now()}` |
91 | | - const newAccessKey = await cloudinary.provisioning.account.generate_access_key(CLOUD_ID, { name: keyName }); |
92 | | - expect(Object.keys(newAccessKey)).to.eql(['name', 'api_key', 'api_secret', 'created_at', 'updated_at', 'enabled']); |
| 91 | + it("Update access key", async () => { |
| 92 | + const keyName = `test-access-key-${Date.now()}`; |
| 93 | + const newAccessKey = |
| 94 | + await cloudinary.provisioning.account.generate_access_key( |
| 95 | + CLOUD_ID, |
| 96 | + { name: keyName, enabled: false } |
| 97 | + ); |
| 98 | + expect(Object.keys(newAccessKey)).to.eql([ |
| 99 | + "name", |
| 100 | + "api_key", |
| 101 | + "api_secret", |
| 102 | + "created_at", |
| 103 | + "updated_at", |
| 104 | + "enabled" |
| 105 | + ]); |
93 | 106 | expect(newAccessKey.name).to.eql(keyName); |
| 107 | + expect(newAccessKey.enabled).to.eql(false); |
94 | 108 |
|
95 | 109 | const newName = `${keyName}-updated`; |
96 | | - const updatedAccessKey = await cloudinary.provisioning.account.update_access_key(CLOUD_ID, newAccessKey.api_key, { name: newName }); |
97 | | - expect(Object.keys(newAccessKey)).to.eql(['name', 'api_key', 'api_secret', 'created_at', 'updated_at', 'enabled']); |
| 110 | + const updatedAccessKey = |
| 111 | + await cloudinary.provisioning.account.update_access_key( |
| 112 | + CLOUD_ID, |
| 113 | + newAccessKey.api_key, |
| 114 | + { name: newName, enabled: true, dedicated_for: "webhooks" } |
| 115 | + ); |
| 116 | + expect(Object.keys(updatedAccessKey)).to.eql([ |
| 117 | + "name", |
| 118 | + "api_key", |
| 119 | + "api_secret", |
| 120 | + "created_at", |
| 121 | + "updated_at", |
| 122 | + "enabled", |
| 123 | + "dedicated_for" |
| 124 | + ]); |
98 | 125 | expect(updatedAccessKey.name).to.eql(newName); |
| 126 | + expect(updatedAccessKey.enabled).to.eql(true); |
| 127 | + expect(updatedAccessKey.dedicated_for).to.be.an("array"); |
| 128 | + expect(updatedAccessKey.dedicated_for.length).to.eql(1); |
| 129 | + expect(updatedAccessKey.dedicated_for[0]).to.eql("webhooks"); |
99 | 130 | }); |
100 | 131 |
|
101 | 132 | it('Delete access keys', async () => { |
|
0 commit comments