Skip to content

Commit 5c86bfa

Browse files
committed
Move back authentication error check.
Move back authentication error check from `start` to `loadCommand` and removed options input.
1 parent 9903e19 commit 5c86bfa

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

scripts/stackstorm.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ module.exports = function(robot) {
251251
.catch(function (err) {
252252
var error_msg = 'Failed to retrieve commands from "%s": %s';
253253
robot.logger.error(util.format(error_msg, env.ST2_API_URL, err.message));
254+
if (err.status === 401 && err.message.includes("Unauthorized")) {
255+
logErrorAndExit(err);
256+
}
254257
});
255258
};
256259

@@ -390,11 +393,7 @@ module.exports = function(robot) {
390393
_stream = stream; // save stream for use in stop()
391394
stream.on('error', function (err) {
392395
robot.logger.error('StackStorm event stream error:', err);
393-
if (err.status === 401) {
394-
logErrorAndExit(err);
395-
} else {
396-
robot.logger.error('Implicitly attempting to reconnect to StackStorm event stream.');
397-
}
396+
robot.logger.error('Implicitly attempting to reconnect to StackStorm event stream.');
398397
});
399398
stream.addEventListener('st2.announcement__chatops', function (e) {
400399
var data;

tests/test-st2-invalid-auth.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe("invalid st2 credential configuration", function() {
8686
for (i = 0; i < error_spy.args.length; i++) {
8787
try {
8888
expect(error_spy.args[i][0]).to.be.a('string');
89-
expect(error_spy.args[i][0]).to.startWith('Failed to retrieve commands from');
89+
expect(error_spy.args[i][0]).to.startWith('Failed to authenticate with st2 username and password:');
9090
break;
9191
} catch (err) {
9292
// If we have reached the last call and we still haven't found it

0 commit comments

Comments
 (0)