describe('getAuthorizeURL', function () { var auth = new OAuth({ clientId: '123456', }); it('should ok', function () { const callback = 'https://yourwebapp.com/authcallback/'; const scope = 'openid /acs/ccc'; const state = '1234567890'; var url = auth.getAuthorizeURL(callback, state, scope, 'offline'); expect(url).to.be.equal('https://signin.aliyun.com/oauth2/v1/auth?client_id=123456&redirect_uri=https%3A%2F%2Fyourwebapp.com%2Fauthcallback%2F&response_type=code&scope=openid%20%2Facs%2Fccc&access_type=offline&state=1234567890'); }); });
it('insert && errors', async () => { try { const stream = clickhouse.insert('INSERT INTO BAD_TABLE').stream(); for (let i = 0; i < 10; i++) { stream.writeRow([i, `test: ${i}`]); } await stream.exec(); // no way! expect(1).to.be.equal(0); } catch (err) { expect(err).to.be.ok(); expect(err.code).to.be(60); } });
it('should be able to call doPostRequest', function(done) { expect(oauth2client2legged.doPostRequest).to.be.a(Function); expect(oauth2client3legged.doPostRequest).to.be.a(Function); var host = 'localtest.com', urlBasePath = 'http://' + host; nock(urlBasePath) .post('/foo', {}) .reply(200, function(uri, respBody){ expect(this.req.headers).to.have.property('content-type'); expect(this.req.headers.host).to.equal(host); return respBody; }); oauth2client2legged.doPostRequest(urlBasePath + '/foo', {}, function(response){ expect(response).to.be.equal(''); done(); }, function(err){ done(err); }); });
describe('list reserved capacity should ok', function () { const client = new FunctionComputeClient(ACCOUNT_ID, { accessKeyID: ACCESS_KEY_ID, accessKeySecret: ACCESS_KEY_SECRET, region: 'cn-shanghai' }); it('listReservedCapacities should ok', async function () { const response = await client.listReservedCapacities(); expect(response.data).to.be.ok(); expect(response.data.reservedCapacities).to.be.ok(); for (var i = 0; i < response.data.reservedCapacities.length; i++) { const elem = response.data.reservedCapacities[i]; expect(elem.instanceId.length).to.be.equal(22); expect(elem.cu).to.be.above(0); expect(elem.Deadline > elem.CreatedTime).to.be.true; expect(elem).to.have.property('lastModifiedTime'); expect(elem).to.have.property('isRefunded'); } }); });
console.log(response.data); expect(response.data).to.be.ok(); expect(response.data.destinationConfig.onSuccess.destination).to.be.equal(asyncConfig.destinationConfig.onSuccess.destination); expect(response.data.lastModifiedTime).to.be.ok(); expect(response.data.createdTime).to.be.ok(); const response = await client.getFunctionAsyncConfig(serviceName, functionName, ""); expect(response.data).to.be.ok(); expect(response.data.maxAsyncEventAgeInSeconds).to.be.equal(asyncConfig.maxAsyncEventAgeInSeconds); }); for (var i = 0; i < response.data.configs.length; i++) { const elem = response.data.configs[i]; expect(elem.maxAsyncEventAgeInSeconds).to.be.equal(asyncConfig.maxAsyncEventAgeInSeconds); expect(elem.maxAsyncRetryAttempts).to.be.equal(asyncConfig.maxAsyncRetryAttempts);
}); expect(response.data).to.be.ok(); expect(response.data.target).to.be.equal(1); expect(response.data.resource).to.be.ok(); }); const response = await client.getProvisionConfig(serviceName, functionName, aliasName); expect(response.data).to.be.ok(); expect(response.data.target).to.be.equal(1); expect(response.data.resource).to.be.ok(); }); for (var i = 0; i < response.data.provisionConfigs.length; i++) { const elem = response.data.provisionConfigs[i]; expect(elem.target).to.be.equal(1); expect(elem.resource).to.be.ok();