Skip to content

Commit

Permalink
Disallow USB connections with t2 root command (#673) (#692)
Browse files Browse the repository at this point in the history
Fixes #673
  • Loading branch information
wyze authored and rwaldron committed Apr 19, 2016
1 parent 4432036 commit ef0a5e2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
12 changes: 12 additions & 0 deletions bin/tessel-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,18 @@ makeCommand('root')
.callback(function(opts) {
callControllerWith('root', opts);
})
.option('lan', {
flag: true,
hidden: true
})
.option('lanPrefer', {
flag: true,
hidden: true
})
.option('usb', {
flag: true,
hidden: true
})
.help('Gain SSH root access to one of your authorized tessels');


Expand Down
6 changes: 6 additions & 0 deletions lib/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,12 @@ controller.root = function(opts) {
opts.lan = true;
// We must already be authorized
opts.authorized = true;
// Disable USB flag if passed
if (opts.usb) {
opts.usb = false;
logs.warn('You are trying to connect to Tessel via USB, but this command only works with Wifi.');
logs.warn('I will use Wifi to try and look for your Tessel.');
}
// Fetch a Tessel
return controller.standardTesselCommand(opts, function(tessel) {
logs.info('Starting SSH Session on Tessel. Type \'exit\' at the prompt to end.');
Expand Down
22 changes: 22 additions & 0 deletions test/unit/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,28 @@ exports['controller.root'] = {
});
},

setsOptsUsbFalseAndWarns: function(test) {
test.expect(4);

var opts = {
usb: true
};

this.logsWarn.restore();
this.logsWarn = this.sandbox.stub(logs, 'warn', function() {});

controller.root(opts)
.then(() => {
var options = this.standardTesselCommand.lastCall.args[0];

test.equal(this.standardTesselCommand.callCount, 1);
test.equal(options, opts);
test.equal(options.usb, false);
test.equal(this.logsWarn.callCount, 2);
test.done();
});
},

setsAuthorizedTrue: function(test) {
test.expect(3);

Expand Down

0 comments on commit ef0a5e2

Please sign in to comment.