|
1 | 1 | 'use strict';
|
2 | 2 | const co = require('co');
|
3 |
| -const rp = require('request-promise'); |
| 3 | +const amqp = require('amqplib'); |
4 | 4 |
|
5 | 5 | // This function will be called by the platform to verify credentials
|
6 | 6 | module.exports = function verifyCredentials(credentials, cb) {
|
7 | 7 | console.log('Credentials passed for verification %j', credentials);
|
8 |
| - |
| 8 | + const amqpURI = credentials.amqpURI; |
| 9 | + const amqpExchange = 'verify_credentials_test'; |
9 | 10 | co(function*() {
|
10 |
| - console.log('Fetching user information'); |
11 |
| - |
12 |
| - const test = yield rp({ |
13 |
| - uri: 'https://cdn.elastic.io/test.json', |
14 |
| - json: true |
15 |
| - }); |
16 |
| - |
17 |
| - console.log('Fetched JSON value=%j', test); |
18 |
| - |
19 |
| - console.log('Verification completed'); |
20 |
| - |
| 11 | + console.log('Connecting to amqpURI=%s', amqpURI); |
| 12 | + const conn = yield amqp.connect(amqpURI); |
| 13 | + console.log('Creating a confirm channel'); |
| 14 | + const channel = yield conn.createConfirmChannel(); |
| 15 | + console.log('Asserting topic exchange exchange=%s', amqpExchange); |
| 16 | + yield channel.assertExchange(amqpExchange, 'topic', { durable: false }); |
| 17 | + console.log('Verified successfully'); |
21 | 18 | cb(null, {verified: true});
|
22 | 19 | }).catch(err => {
|
23 | 20 | console.log('Error occurred', err.stack || err);
|
|
0 commit comments