summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Mannehed <samuel@cendio.se>2016-08-29 14:56:57 +0200
committerSamuel Mannehed <samuel@cendio.se>2016-09-01 16:34:34 +0200
commitf9177c92c776328be1879dc486ff179a61da1c53 (patch)
tree9fdfc6a2f3aded29e21e2d6d673dd26c1d1a43f6
parentf4f4e8993d6daeb43b957766cd6973993232ba13 (diff)
downloadnovnc-removePasswordState.tar.gz
Remove special password stateremovePasswordState
We already have a callback mechanism for this, so let's use that. Fixes vnc_auto.html (#646) which was broken after 4e0c36dda708628836dc6f5d68fc40d05c7716d9
-rw-r--r--include/rfb.js9
-rw-r--r--include/ui.js34
-rw-r--r--tests/test.rfb.js29
3 files changed, 45 insertions, 27 deletions
diff --git a/include/rfb.js b/include/rfb.js
index 9935962..e84c8a7 100644
--- a/include/rfb.js
+++ b/include/rfb.js
@@ -265,7 +265,6 @@ var RFB;
sendPassword: function (passwd) {
this._rfb_password = passwd;
- this._rfb_state = 'Authentication';
setTimeout(this._init_msg.bind(this), 0);
},
@@ -429,7 +428,6 @@ var RFB;
* ProtocolVersion
* Security
* Authentication
- * password - waiting for password, not part of RFB
* SecurityResult
* ClientInitialization - not triggered by server message
* ServerInitialization (to normal)
@@ -732,8 +730,8 @@ var RFB;
var xvp_sep = this._xvp_password_sep;
var xvp_auth = this._rfb_password.split(xvp_sep);
if (xvp_auth.length < 3) {
- this._updateState('password', 'XVP credentials required (user' + xvp_sep +
- 'target' + xvp_sep + 'password) -- got only ' + this._rfb_password);
+ Util.Debug('XVP credentials required (user' + xvp_sep +
+ 'target' + xvp_sep + 'password) -- got only ' + this._rfb_password);
this._onPasswordRequired(this);
return false;
}
@@ -750,9 +748,6 @@ var RFB;
_negotiate_std_vnc_auth: function () {
if (this._rfb_password.length === 0) {
- // Notify via both callbacks since it's kind of
- // an RFB state change and a UI interface issue
- this._updateState('password', "Password Required");
this._onPasswordRequired(this);
return false;
}
diff --git a/include/ui.js b/include/ui.js
index d69a4f6..66608d1 100644
--- a/include/ui.js
+++ b/include/ui.js
@@ -192,6 +192,7 @@ var UI;
try {
UI.rfb = new RFB({'target': $D('noVNC_canvas'),
'onUpdateState': UI.updateState,
+ 'onPasswordRequired': UI.passwordRequired,
'onXvpInit': UI.updateXvpButton,
'onClipboard': UI.clipboardReceive,
'onFBUComplete': UI.initialResize,
@@ -275,23 +276,15 @@ var UI;
case 'loaded':
klass = "noVNC_status_normal";
break;
- case 'password':
- UI.toggleConnectPanel();
-
- $D('noVNC_connect_button').value = "Send Password";
- $D('noVNC_connect_button').onclick = UI.setPassword;
- $D('noVNC_setting_password').focus();
-
- klass = "noVNC_status_warn";
- break;
default:
klass = "noVNC_status_warn";
break;
}
+ $D('noVNC_control_bar').setAttribute("class", klass);
if (typeof(msg) !== 'undefined') {
- $D('noVNC_control_bar').setAttribute("class", klass);
$D('noVNC_status').innerHTML = msg;
+
}
UI.updateVisualState();
@@ -750,6 +743,25 @@ var UI;
// Don't display the connection settings until we're actually disconnected
},
+/* ------^-------
+ * /CONNECTION
+ * ==============
+ * PASSWORD
+ * ------v------*/
+
+ passwordRequired: function(rfb) {
+ UI.connSettingsOpen = false;
+ UI.toggleConnectPanel();
+
+ $D('noVNC_connect_button').value = "Send Password";
+ $D('noVNC_connect_button').onclick = UI.setPassword;
+ $D('noVNC_setting_password').focus();
+
+ var msg = "Password is required";
+ UI.popupStatus(msg);
+ UI.updateState(null, "warning", null, msg);
+ },
+
setPassword: function() {
UI.rfb.sendPassword($D('noVNC_setting_password').value);
//Reset connect button.
@@ -761,7 +773,7 @@ var UI;
},
/* ------^-------
- * /CONNECTION
+ * /PASSWORD
* ==============
* FULLSCREEN
* ------v------*/
diff --git a/tests/test.rfb.js b/tests/test.rfb.js
index 06eeebe..22059f3 100644
--- a/tests/test.rfb.js
+++ b/tests/test.rfb.js
@@ -107,10 +107,9 @@ describe('Remote Frame Buffer Protocol Client', function() {
beforeEach(function () { this.clock = sinon.useFakeTimers(); });
afterEach(function () { this.clock.restore(); });
- it('should set the state to "Authentication"', function () {
- client._rfb_state = "blah";
+ it('should set the rfb password properly"', function () {
client.sendPassword('pass');
- expect(client._rfb_state).to.equal('Authentication');
+ expect(client._rfb_password).to.equal('pass');
});
it('should call init_msg "soon"', function () {
@@ -704,9 +703,13 @@ describe('Remote Frame Buffer Protocol Client', function() {
client._rfb_version = 3.8;
});
- it('should transition to the "password" state if missing a password', function () {
+ it('should call the passwordRequired callback if missing a password', function () {
+ client.set_onPasswordRequired(sinon.spy());
send_security(2, client);
- expect(client._rfb_state).to.equal('password');
+
+ var spy = client.get_onPasswordRequired();
+ expect(client._rfb_password.length).to.equal(0);
+ expect(spy).to.have.been.calledOnce;
});
it('should encrypt the password with DES and then send it back', function () {
@@ -753,15 +756,23 @@ describe('Remote Frame Buffer Protocol Client', function() {
expect(client._negotiate_std_vnc_auth).to.have.been.calledOnce;
});
- it('should transition to the "password" state if the passwords is missing', function() {
+ it('should call the passwordRequired callback if the password is missing', function() {
+ client.set_onPasswordRequired(sinon.spy());
+ client._rfb_password = '';
send_security(22, client);
- expect(client._rfb_state).to.equal('password');
+
+ var spy = client.get_onPasswordRequired();
+ expect(client._rfb_password.length).to.equal(0);
+ expect(spy).to.have.been.calledOnce;
});
- it('should transition to the "password" state if the passwords is improperly formatted', function() {
+ it('should call the passwordRequired callback if the password is improperly formatted', function() {
+ client.set_onPasswordRequired(sinon.spy());
client._rfb_password = 'user@target';
send_security(22, client);
- expect(client._rfb_state).to.equal('password');
+
+ var spy = client.get_onPasswordRequired();
+ expect(spy).to.have.been.calledOnce;
});
it('should split the password, send the first two parts, and pass on the last part', function () {