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

Fixed trailing spaces in wifi ssid getting dropped. #62

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
51 changes: 47 additions & 4 deletions test/wpa_cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ var WPA_CLI_STATUS_COMPLETED = [
'ip_address=10.34.141.168',
'p2p_device_address=e4:28:9c:a8:53:72',
'address=e4:28:9c:a8:53:72',
'uuid=e1cda789-8c88-53e8-ffff-31c304580c1e'
'uuid=e1cda789-8c88-53e8-ffff-31c304580c1e',
''
].join('\n');

var WPA_CLI_STATUS_4WAY_HANDSHAKE = [
Expand All @@ -55,21 +56,32 @@ var WPA_CLI_STATUS_4WAY_HANDSHAKE = [
'ip_address=10.34.141.168',
'p2p_device_address=e4:28:9c:a8:53:72',
'address=e4:28:9c:a8:53:72',
'uuid=e1cda789-8c88-53e8-ffff-31c304580c1e'
'uuid=e1cda789-8c88-53e8-ffff-31c304580c1e',
''
].join('\n');

var WPA_CLI_STATUS_SCANNING = [
'wpa_state=SCANNING',
'ip_address=10.34.141.168',
'p2p_device_address=e4:28:9c:a8:53:72',
'address=e4:28:9c:a8:53:72',
'uuid=e1cda789-8c88-53e8-ffff-31c304580c1e'
'uuid=e1cda789-8c88-53e8-ffff-31c304580c1e',
''
].join('\n');

var WPA_CLI_SCAN_RESULTS = [
'bssid / frequency / signal level / flags / ssid',
'2c:f5:d3:02:ea:d9 2472 -31 [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][ESS] FakeWifi',
'2c:f5:d3:02:ea:d9 2472 -31 [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][ESS] FakeWifi2'
'2c:f5:d3:02:ea:d9 2472 -31 [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][ESS] FakeWifi2',
''
].join('\n');

var WPA_CLI_SCAN_RESULTS_SPACE = [
'bssid / frequency / signal level / flags / ssid',
'2c:f5:d3:02:ea:d9 2472 -31 [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][ESS] FakeWifi ',
'2c:f5:d3:02:ea:d9 2472 -31 [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][ESS] FakeWifi2',
'2c:f5:d3:02:ea:d9 2472 -31 [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][ESS] FakeWifi3 ',
''
].join('\n');

var WPA_CLI_SCAN_NORESULTS = [
Expand Down Expand Up @@ -605,6 +617,37 @@ describe('wpa_cli', function() {
});
});

it('scan_results SPACE', function(done) {
this.OUTPUT = WPA_CLI_SCAN_RESULTS_SPACE;
wpa_cli.scan_results('wlan0', function(err, results) {
should(results).eql([
{
bssid: '2c:f5:d3:02:ea:d9',
frequency: 2472,
signalLevel: -31,
flags: '[WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][ESS]',
ssid: 'FakeWifi '
},
{
bssid: '2c:f5:d3:02:ea:d9',
frequency: 2472,
signalLevel: -31,
flags: '[WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][ESS]',
ssid: 'FakeWifi2'
},
{
bssid: '2c:f5:d3:02:ea:d9',
frequency: 2472,
signalLevel: -31,
flags: '[WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][ESS]',
ssid: 'FakeWifi3 '
}
]);

done();
});
});

it('should handle errors', function(done) {
wpa_cli.exec = function(command, callback) {
callback('error');
Expand Down
2 changes: 1 addition & 1 deletion wpa_cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ function parse_scan_results_interface(callback) {
if (error) {
callback(error);
} else {
callback(error, parse_scan_results(stdout.trim()));
callback(error, parse_scan_results(stdout.replace(/\n$/, '')));
}
};
}
Expand Down