Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove HipChat adapter #207

Merged
merged 4 commits into from
Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Changelog
in development
--------------

0.11.0
------

* Remove HipChat adapter [PR #207] (change)

0.10.4
------

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "hubot-stackstorm",
"description": "A hubot plugin for integrating with StackStorm event-driven infrastructure automation platform.",
"version": "0.10.4",
"version": "0.11.0",
"author": "StackStorm, Inc. <[email protected]>",
"license": "Apache-2.0",
"keywords": [
Expand Down
92 changes: 0 additions & 92 deletions src/lib/adapters/hipchat.js

This file was deleted.

61 changes: 0 additions & 61 deletions test/test-formatdata.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,67 +227,6 @@ describe('MSTeamsFormatter', function() {
});
});

describe('HipChatFormatter', function() {
var adapterName = 'hipchat';
var robot = new DummyRobot('dummy', null, false);

it('should echo back for non-empty', function() {
var adapter = adapters.getAdapter(adapterName, robot);
var o = adapter.formatData('DATA');
expect(o).to.be.an('string');
expect(o).to.equal('/code DATA');
});

it('should be an empty string for empty', function() {
var adapter = adapters.getAdapter(adapterName, robot);
var o = adapter.formatData('');
expect(o).to.be.an('string');
expect(o).to.equal('');
});

it('should correctly format recipient', function() {
var adapter = adapters.getAdapter(adapterName, robot);
env.HUBOT_HIPCHAT_JID = '[email protected]';
var o = adapter.formatRecipient('Estee');
expect(o).to.be.an('string');
expect(o).to.equal('[email protected]');
});

it('should correctly format recipient with conf.btf.hipchat.com', function() {
var adapter = adapters.getAdapter(adapterName, robot);
env.HUBOT_HIPCHAT_JID = '[email protected]';
env.HUBOT_HIPCHAT_XMPP_DOMAIN = "btf.hipchat.com";
var o = adapter.formatRecipient('Estee');
expect(o).to.be.an('string');
expect(o).to.equal('[email protected]');
});

it('should normalize command', function() {
var adapter = adapters.getAdapter(adapterName, robot);
var o = adapter.normalizeCommand('run local "uname -a"');
expect(o).to.be.an('string');
expect(o).to.equal('run local "uname -a"');
});

it('should normalize the addressee', function() {
var adapter = adapters.getAdapter(adapterName, robot);
// HipChat packages the room and user name differently
var msg = {
message: {
user: {
jid: "HipChatRoomName",
mention_name: "HipChatUserName"
}
}
};
var o = adapter.normalizeAddressee(msg);
expect(o.name).to.be.an('string');
expect(o.name).to.equal('HipChatUserName');
expect(o.room).to.be.an('string');
expect(o.room).to.equal('HipChatRoomName');
});
});

describe('RocketChatFormatter', function() {
var adapterName = 'rocketchat';
var robot = new DummyRobot('dummy', null, false);
Expand Down
142 changes: 0 additions & 142 deletions test/test-postdata.js
Original file line number Diff line number Diff line change
Expand Up @@ -741,148 +741,6 @@ describe("mattermost post data", function() {
});
});

describe("hipchat post data", function() {
var logger = new Log('info');
var robot = new Robot(false, new MockSlackAdapter(logger));
var adapter = adapters.getAdapter('hipchat', robot);

it('should post to channel', function() {
this.clock = sinon.useFakeTimers();
robot.messageRoom = sinon.spy();
env.HUBOT_HIPCHAT_JID = 'dfd_fdf';
env.HUBOT_HIPCHAT_XMPP_DOMAIN = 'danger'; // btf.hipchat.com

var input = {
channel: 'hipchat-test',
message: 'Hello world!',
user: 'stackstorm',
whisper: false
};
var user = util.format('@%s: ', input.user),
jid = env.HUBOT_HIPCHAT_JID.split("_")[0],
recipient = util.format('%s_%s@%s', jid, input.channel, 'conf.hipchat.com');

adapter.postData(input);
expect(robot.messageRoom).to.have.been.calledWith(recipient, '@stackstorm: ');
this.clock.tick(500);
expect(robot.messageRoom).to.have.been.calledWith(recipient, '/code Hello world!');
expect(robot.messageRoom).to.have.been.calledTwice;
this.clock.restore();
});

it('should whisper to channel', function() {
robot.send = sinon.spy();
env.HUBOT_HIPCHAT_JID = 'dfd_fdf';
env.HUBOT_HIPCHAT_XMPP_DOMAIN = 'danger'; // btf.hipchat.com

var input = {
channel: 'hipchat-test',
message: 'Hello world!',
user: 'stackstorm',
whisper: true
};
var user = util.format('@%s: ', input.user),
jid = env.HUBOT_HIPCHAT_JID.split("_")[0],
recipient = util.format('%s_%s@%s', jid, input.channel, 'conf.hipchat.com');

adapter.postData(input);
expect(robot.send).to.have.been.calledOnce;
expect(robot.send).to.have.been.calledWith(input.channel, '/code Hello world!');
});

it('should post to channel with recipient', function() {
this.clock = sinon.useFakeTimers();
robot.messageRoom = sinon.spy();
env.HUBOT_HIPCHAT_JID = 'dfd_fdf';
env.HUBOT_HIPCHAT_XMPP_DOMAIN = 'danger'; // btf.hipchat.com

var input = {
channel: '@hipchat-test',
message: 'Hello world!',
user: 'stackstorm',
whisper: false
};
var user = util.format('@%s: ', input.user),
jid = env.HUBOT_HIPCHAT_JID.split("_")[0],
recipient = util.format('%s_%s@%s', jid, input.channel, 'conf.hipchat.com');

adapter.postData(input);
expect(robot.messageRoom).to.have.been.calledWith(input.channel, '@stackstorm: ');
this.clock.tick(500);
expect(robot.messageRoom).to.have.been.calledWith(input.channel, '/code Hello world!');
expect(robot.messageRoom).to.have.been.calledTwice;
this.clock.restore();
});

it('should post to channel with pretext', function() {
this.clock = sinon.useFakeTimers();
robot.messageRoom = sinon.spy();
env.HUBOT_HIPCHAT_JID = 'dfd_fdf';
env.HUBOT_HIPCHAT_XMPP_DOMAIN = 'danger'; // btf.hipchat.com

var input = {
channel: 'hipchat-test',
message: 'PRETEXT HEADER{~}Hello world!',
user: 'stackstorm',
whisper: false
};
var user = util.format('@%s: ', input.user),
jid = env.HUBOT_HIPCHAT_JID.split("_")[0],
recipient = util.format('%s_%s@%s', jid, input.channel, 'conf.hipchat.com');

adapter.postData(input);
expect(robot.messageRoom).to.have.been.calledWith(recipient, '@stackstorm: PRETEXT HEADER');
this.clock.tick(500);
expect(robot.messageRoom).to.have.been.calledWith(recipient, '/code Hello world!');
expect(robot.messageRoom).to.have.been.calledTwice;
this.clock.restore();
});

it('should post to channel with only pretext', function() {
robot.messageRoom = sinon.spy();
env.HUBOT_HIPCHAT_JID = 'dfd_fdf';
env.HUBOT_HIPCHAT_XMPP_DOMAIN = 'danger'; // btf.hipchat.com

var input = {
channel: 'hipchat-test',
message: 'PRETEXT HEADER{~}',
user: 'stackstorm',
whisper: false
};
var user = util.format('@%s: ', input.user),
jid = env.HUBOT_HIPCHAT_JID.split("_")[0],
recipient = util.format('%s_%s@%s', jid, input.channel, 'conf.hipchat.com');

adapter.postData(input);
expect(robot.messageRoom).to.have.been.calledOnce;
expect(robot.messageRoom).to.have.been.calledWith(recipient, '@stackstorm: PRETEXT HEADER');
});

it('should whisper to channel with pretext', function() {
this.clock = sinon.useFakeTimers();
robot.send = sinon.spy();
env.HUBOT_HIPCHAT_JID = 'dfd_fdf';
env.HUBOT_HIPCHAT_XMPP_DOMAIN = 'danger'; // btf.hipchat.com

var input = {
channel: 'hipchat-test',
message: 'PRETEXT HEADER{~}Hello world!',
user: 'stackstorm',
whisper: true
};
var user = util.format('@%s: ', input.user),
jid = env.HUBOT_HIPCHAT_JID.split("_")[0],
recipient = util.format('%s_%s@%s', jid, input.channel, 'conf.hipchat.com');

adapter.postData(input);
expect(robot.send).to.have.been.calledWith(input.channel, 'PRETEXT HEADER');
this.clock.tick(500);
expect(robot.send).to.have.been.calledWith(input.channel, '/code Hello world!');
expect(robot.send).to.have.been.calledTwice;
this.clock.restore();
});
});

describe("spark post data", function() {
var logger = new Log('info');
var robot = new Robot(false, new MockSlackAdapter(logger));
Expand Down