|
| 1 | +import { |
| 2 | + CloudserverClient, |
| 3 | + CheckConnectionInput, |
| 4 | + CheckConnectionCommand, |
| 5 | + GetLocationsStatusInput, |
| 6 | + GetLocationsStatusCommand, |
| 7 | + GetLocationsIngestionStatusInput, |
| 8 | + GetLocationsIngestionStatusCommand, |
| 9 | + ListFailedCommandInput, |
| 10 | + ListFailedCommand, |
| 11 | +} from '../src/index'; |
| 12 | +import { S3Client, GetObjectCommand as s3getCommand } from '@aws-sdk/client-s3'; |
| 13 | +import { createTestClient, testConfig } from './testSetup'; |
| 14 | +import assert from 'assert'; |
| 15 | + |
| 16 | + |
| 17 | +// |
| 18 | +const AWS = require('aws-sdk'); |
| 19 | +const { Service } = require('aws-sdk'); |
| 20 | + |
| 21 | +describe('CloudServer Check Status API Tests', () => { |
| 22 | + let client: CloudserverClient; |
| 23 | + |
| 24 | + beforeAll(() => { |
| 25 | + ({client} = createTestClient()); |
| 26 | + }); |
| 27 | + |
| 28 | + it.skip('should test checkConnection', async () => { |
| 29 | + const input: CheckConnectionInput = {}; |
| 30 | + const checkConnectionCommand = new CheckConnectionCommand(input); |
| 31 | + const result = await client.send(checkConnectionCommand); |
| 32 | + console.log('CheckConnectionCommand', result.$metadata.httpStatusCode); |
| 33 | + assert.strictEqual(result.$metadata.httpStatusCode, 200); |
| 34 | + }); |
| 35 | + |
| 36 | + it.skip('should test GetLocationsStatus', async () => { |
| 37 | + const input: GetLocationsStatusInput = {}; |
| 38 | + const getLocationsStatusCommand = new GetLocationsStatusCommand(input); |
| 39 | + const result = await client.send(getLocationsStatusCommand); |
| 40 | + console.log('GetLocationsStatusCommand', result); |
| 41 | + assert.strictEqual(result.$metadata.httpStatusCode, 200); |
| 42 | + |
| 43 | + // assert.strictEqual(result.$metadata.httpStatusCode, 200); |
| 44 | + }); |
| 45 | + |
| 46 | + it.skip('should test GetLocationsIngestionStatus', async () => { |
| 47 | + const input: GetLocationsIngestionStatusInput = {}; |
| 48 | + const getLocationsIngestionStatusCommand = new GetLocationsIngestionStatusCommand(input); |
| 49 | + const result = await client.send(getLocationsIngestionStatusCommand); |
| 50 | + console.log('GetLocationsIngestionStatusCommand', result); |
| 51 | + // assert.strictEqual(result.$metadata.httpStatusCode, 200); |
| 52 | + assert.strictEqual(result.$metadata.httpStatusCode, 200); |
| 53 | + }); |
| 54 | + |
| 55 | + it('should test listFailed', async () => { |
| 56 | + const input: ListFailedCommandInput = {}; |
| 57 | + const cmd = new ListFailedCommand(input); |
| 58 | + const result = await client.send(cmd); |
| 59 | + console.log('ListFailedCommand', result); |
| 60 | + // assert.strictEqual(result.$metadata.httpStatusCode, 200); |
| 61 | + assert.strictEqual(result.$metadata.httpStatusCode, 200); |
| 62 | + }); |
| 63 | + |
| 64 | + |
| 65 | + it.skip('test old client', async () => { |
| 66 | + AWS.apiLoader.services.backbeat = {}; |
| 67 | + Object.defineProperty(AWS.apiLoader.services.backbeat, '2017-07-01', { |
| 68 | + get: function get() { |
| 69 | + const model = require('../legacy/zenko-2018-07-08-json.api.json'); |
| 70 | + return model; |
| 71 | + }, |
| 72 | + enumerable: true, |
| 73 | + configurable: true, |
| 74 | + }); |
| 75 | + const BackbeatClient = Service.defineService('backbeat', ['2017-07-01']); |
| 76 | + |
| 77 | + BackbeatClient.prototype.validateService = function validateService() { |
| 78 | + if (!this.config.region) { |
| 79 | + this.config.region = 'us-east-1'; |
| 80 | + } |
| 81 | + }; |
| 82 | + const conf = { |
| 83 | + accessKeyId: 'accessKey1', |
| 84 | + secretAccessKey: 'verySecretKey1', |
| 85 | + endpoint: 'http://localhost:8000', |
| 86 | + region: 'us-east-1', |
| 87 | + sslEnabled: false, |
| 88 | + s3ForcePathStyle: true, |
| 89 | + apiVersions: { s3: '2006-03-01' }, |
| 90 | + signatureVersion: 'v4', |
| 91 | + signatureCache: false, |
| 92 | + }; |
| 93 | + const c = new BackbeatClient(conf) |
| 94 | + |
| 95 | + await new Promise((resolve, reject) => { |
| 96 | + c.checkConnection({}, (err: any, data: any) => { |
| 97 | + if (err) { |
| 98 | + console.log('Error:', err); |
| 99 | + reject(err); |
| 100 | + } else { |
| 101 | + console.log('Success:', data); |
| 102 | + resolve(data); |
| 103 | + } |
| 104 | + }); |
| 105 | + }); |
| 106 | + }); |
| 107 | +}); |
0 commit comments