initial commit

This commit is contained in:
jkoschke
2022-08-26 12:49:14 +02:00
commit 4990667410
573 changed files with 29169 additions and 0 deletions

108
tests/node_modules/wireless-tools/test/hostapd.js generated vendored Normal file
View File

@ -0,0 +1,108 @@
/*
* Copyright (c) 2015 Christopher M. Baker
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
var should = require('should');
var hostapd = require('../hostapd');
describe('hostapd', function() {
describe('hostapd.disable(options, callback)', function() {
it('should stop the daemons', function(done) {
hostapd.exec = function(command, callback) {
should(command).eql(
'kill `pgrep -f "^hostapd -B wlan0-hostapd.conf"` || true');
callback(null, '', '');
};
hostapd.disable('wlan0', function(err) {
should(err).not.be.ok;
done();
});
})
it('should handle errors', function(done) {
hostapd.exec = function(command, callback) {
callback('error');
};
hostapd.disable('wlan0', function(err) {
should(err).eql('error');
done();
});
})
})
describe('hostapd.enable(options, callback)', function() {
it('should start the daemon', function(done) {
hostapd.exec = function(command, callback) {
should(command).eql('cat <<EOF >wlan0-hostapd.conf' +
' && hostapd -B wlan0-hostapd.conf' +
' && rm -f wlan0-hostapd.conf\n' +
'channel=6\n' +
'driver=rtl871xdrv\n' +
'hw_mode=g\n' +
'interface=wlan0\n' +
'ssid=RaspberryPi\n' +
'wpa=2\n' +
'wpa_passphrase=raspberry');
callback(null, '', '');
};
var options = {
channel: 6,
driver: 'rtl871xdrv',
hw_mode: 'g',
interface: 'wlan0',
ssid: 'RaspberryPi',
wpa: 2,
wpa_passphrase: 'raspberry'
};
hostapd.enable(options, function(err) {
should(err).not.be.ok;
done();
});
})
it('should handle errors', function(done) {
hostapd.exec = function(command, callback) {
callback('error');
};
var options = {
channel: 6,
driver: 'rtl871xdrv',
hw_mode: 'g',
interface: 'wlan0',
ssid: 'RaspberryPi',
wpa: 2,
wpa_passphrase: 'raspberry'
};
hostapd.enable(options, function(err) {
should(err).eql('error');
done();
});
})
})
})

201
tests/node_modules/wireless-tools/test/ifconfig.js generated vendored Normal file
View File

@ -0,0 +1,201 @@
/*
* Copyright (c) 2015 Christopher M. Baker
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
var should = require('should');
var ifconfig = require('../ifconfig');
var IFCONFIG_STATUS_LINUX = [
'eth0 Link encap:Ethernet HWaddr DE:AD:BE:EF:C0:DE',
' inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0',
' UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1',
' RX packets:114919 errors:0 dropped:10 overruns:0 frame:0',
' TX packets:117935 errors:0 dropped:0 overruns:0 carrier:0',
' collisions:0 txqueuelen:1000',
' RX bytes:28178397 (26.8 MiB) TX bytes:23423409 (22.3 MiB)',
'',
'lo Link encap:Local Loopbacks',
' inet addr:127.0.0.1 Mask:255.0.0.0',
' UP LOOPBACK RUNNING MTU:65536 Metric:1',
' RX packets:0 errors:0 dropped:0 overruns:0 frame:0',
' TX packets:0 errors:0 dropped:0 overruns:0 carrier:0',
' collisions:0 txqueuelen:0',
' RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)'
].join('\n');
var IFCONFIG_STATUS_INTERFACE_LINUX = [
'wlan0 HWaddr DE:AD:BE:EF:C0:DE',
' inet6 addr:fe80::21c:c0ff:feae:b5e6/64 Scope:Link',
' MTU:1500 Metric:1',
' RX packets:0 errors:0 dropped:0 overruns:0 frame:0',
' TX packets:0 errors:0 dropped:0 overruns:0 carrier:0',
' collisions:0 txqueuelen:1000',
' RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)'
].join('\n');
describe('ifconfig', function() {
describe('ifconfig.status(callback)', function() {
it('should get the status for each interface', function(done) {
ifconfig.exec = function(command, callback) {
should(command).eql('ifconfig -a');
callback(null, IFCONFIG_STATUS_LINUX, '');
};
ifconfig.status(function(err, status) {
should(status).eql([
{
interface: 'eth0',
link: 'ethernet',
address: 'de:ad:be:ef:c0:de',
ipv4_address: '192.168.1.2',
ipv4_broadcast: '192.168.1.255',
ipv4_subnet_mask: '255.255.255.0',
up: true,
broadcast: true,
running: true,
multicast: true
},
{
interface: 'lo',
link: 'local',
ipv4_address: '127.0.0.1',
ipv4_subnet_mask: '255.0.0.0',
up: true,
loopback: true,
running: true
}
]);
done();
});
})
it('should handle errors', function(done) {
ifconfig.exec = function(command, callback) {
callback('error');
};
ifconfig.status(function(err, status) {
should(err).eql('error');
done();
});
})
})
describe('ifconfig.status(interface, callback)', function() {
it('should get the status for the specified interface', function(done) {
ifconfig.exec = function(command, callback) {
should(command).eql('ifconfig wlan0');
callback(null, IFCONFIG_STATUS_INTERFACE_LINUX, '');
};
ifconfig.status('wlan0', function(err, status) {
should(status).eql({
interface: 'wlan0',
address: 'de:ad:be:ef:c0:de',
ipv6_address: 'fe80::21c:c0ff:feae:b5e6/64'
});
done();
});
})
it('should handle errors', function(done) {
ifconfig.exec = function(command, callback) {
callback('error');
};
ifconfig.status('wlan0', function(err, status) {
should(err).eql('error');
done();
});
})
})
describe('ifconfig.down(interface, callback)', function() {
it('should take down the interface', function(done) {
ifconfig.exec = function(command, callback) {
should(command).eql('ifconfig wlan0 down');
callback(null, '', '');
};
ifconfig.down('wlan0', function(err) {
should(err).not.be.ok;
done();
});
})
it('should handle errors', function(done) {
ifconfig.exec = function(command, callback) {
callback('error');
};
ifconfig.down('wlan0', function(err) {
should(err).eql('error');
done();
});
})
})
describe('ifconfig.up(options, callback)', function() {
it('should bring up the interface', function(done) {
ifconfig.exec = function(command, callback) {
should(command).eql('ifconfig wlan0 192.168.10.1' +
' netmask 255.255.255.0 broadcast 192.168.10.255 up');
callback(null, '', '');
};
var options = {
interface: 'wlan0',
ipv4_address: '192.168.10.1',
ipv4_broadcast: '192.168.10.255',
ipv4_subnet_mask: '255.255.255.0'
};
ifconfig.up(options, function(err) {
should(err).not.be.ok;
done();
});
})
it('should handle errors', function(done) {
ifconfig.exec = function(command, callback) {
callback('error');
};
var options = {
interface: 'wlan0',
ipv4_address: '192.168.10.1',
ipv4_broadcast: '192.168.10.255',
ipv4_subnet_mask: '255.255.255.0'
};
ifconfig.down(options, function(err) {
should(err).eql('error');
done();
});
})
})
})

860
tests/node_modules/wireless-tools/test/iw.js generated vendored Normal file
View File

@ -0,0 +1,860 @@
/*
* Copyright (c) 2015 Christopher M. Baker
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
var should = require('should');
var iw = require('../iw');
var IW_SCAN_LINUX = "BSS 14:91:82:c7:76:b9(on wlan0)\n" +
" TSF: 337644127 usec (0d, 00:05:37)\n" +
" freq: 2412\n" +
" beacon interval: 100 TUs\n" +
" capability: ESS Privacy ShortSlotTime (0x0411)\n" +
" signal: -87.00 dBm\n" +
" last seen: 0 ms ago\n" +
" Information elements from Probe Response frame:\n" +
" SSID: creamcorn\n" +
" Supported rates: 1.0* 2.0* 5.5* 11.0* 22.0 6.0 9.0 12.0 \n" +
" DS Parameter set: channel 1\n" +
" TIM: DTIM Count 0 DTIM Period 2 Bitmap Control 0x0 Bitmap[0] 0x0\n" +
" ERP: <no flags>\n" +
" Extended supported rates: 18.0 24.0 36.0 48.0 54.0 \n" +
" RSN: * Version: 1\n" +
" * Group cipher: CCMP\n" +
" * Pairwise ciphers: CCMP\n" +
" * Authentication suites: PSK\n" +
" * Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)\n" +
" HT capabilities:\n" +
" Capabilities: 0x6f\n" +
" RX LDPC\n" +
" HT20/HT40\n" +
" SM Power Save disabled\n" +
" RX HT20 SGI\n" +
" RX HT40 SGI\n" +
" No RX STBC\n" +
" Max AMSDU length: 3839 bytes\n" +
" No DSSS/CCK HT40\n" +
" Maximum RX AMPDU length 65535 bytes (exponent: 0x003)\n" +
" Minimum RX AMPDU time spacing: 4 usec (0x05)\n" +
" HT TX/RX MCS rate indexes supported: 0-23, 32\n" +
" HT operation:\n" +
" * primary channel: 1\n" +
" * secondary channel offset: no secondary\n" +
" * STA channel width: 20 MHz\n" +
" * RIFS: 0\n" +
" * HT protection: nonmember\n" +
" * non-GF present: 0\n" +
" * OBSS non-GF present: 1\n" +
" * dual beacon: 0\n" +
" * dual CTS protection: 0\n" +
" * STBC beacon: 0\n" +
" * L-SIG TXOP Prot: 0\n" +
" * PCO active: 0\n" +
" * PCO phase: 0\n" +
" Extended capabilities: 6\n" +
" VHT capabilities:\n" +
" VHT Capabilities (0x33801831):\n" +
" Max MPDU length: 7991\n" +
" Supported Channel Width: neither 160 nor 80+80\n" +
" RX LDPC\n" +
" short GI (80 MHz)\n" +
" SU Beamformer\n" +
" SU Beamformee\n" +
" RX antenna pattern consistency\n" +
" TX antenna pattern consistency\n" +
" VHT RX MCS set:\n" +
" 1 streams: MCS 0-9\n" +
" 2 streams: MCS 0-9\n" +
" 3 streams: MCS 0-9\n" +
" 4 streams: not supported\n" +
" 5 streams: not supported\n" +
" 6 streams: not supported\n" +
" 7 streams: not supported\n" +
" 8 streams: not supported\n" +
" VHT RX highest supported: 0 Mbps\n" +
" VHT TX MCS set:\n" +
" 1 streams: MCS 0-9\n" +
" 2 streams: MCS 0-9\n" +
" 3 streams: MCS 0-9\n" +
" 4 streams: not supported\n" +
" 5 streams: not supported\n" +
" 6 streams: not supported\n" +
" 7 streams: not supported\n" +
" 8 streams: not supported\n" +
" VHT TX highest supported: 0 Mbps\n" +
" VHT operation:\n" +
" * channel width: 0 (20 or 40 MHz)\n" +
" * center freq segment 1: 0\n" +
" * center freq segment 2: 0\n" +
" * VHT basic MCS set: 0xfffc\n" +
" WMM: * Parameter version 1\n" +
" * BE: CW 15-1023, AIFSN 3, TXOP 2048 usec\n" +
" * BK: CW 15-1023, AIFSN 7\n" +
" * VI: CW 7-15, AIFSN 2, TXOP 3008 usec\n" +
" * VO: CW 3-7, AIFSN 2, TXOP 1504 usec\n" +
"BSS f4:0f:1b:b5:5b:4d(on wlan0)\n" +
" TSF: 337645123 usec (0d, 00:05:37)\n" +
" freq: 5260\n" +
" beacon interval: 102 TUs\n" +
" capability: ESS Privacy RadioMeasure (0x1011)\n" +
" signal: -59.00 dBm\n" +
" last seen: 4530 ms ago\n" +
" Information elements from Probe Response frame:\n" +
" SSID: Wink-Visitor\n" +
" Supported rates: 6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 \n" +
" Country: US Environment: Indoor/Outdoor\n" +
" Channels [36 - 48] @ 17 dBm\n" +
" Channels [52 - 64] @ 24 dBm\n" +
" Channels [100 - 116] @ 24 dBm\n" +
" Channels [132 - 140] @ 24 dBm\n" +
" Channels [149 - 165] @ 30 dBm\n" +
" BSS Load:\n" +
" * station count: 14\n" +
" * channel utilisation: 16/255\n" +
" * available admission capacity: 23437 [*32us]\n" +
" HT capabilities:\n" +
" Capabilities: 0x19ac\n" +
" HT20\n" +
" SM Power Save disabled\n" +
" RX HT20 SGI\n" +
" TX STBC\n" +
" RX STBC 1-stream\n" +
" Max AMSDU length: 7935 bytes\n" +
" DSSS/CCK HT40\n" +
" Maximum RX AMPDU length 65535 bytes (exponent: 0x003)\n" +
" Minimum RX AMPDU time spacing: 8 usec (0x06)\n" +
" HT RX MCS rate indexes supported: 0-23\n" +
" HT TX MCS rate indexes are undefined\n" +
" HT operation:\n" +
" * primary channel: 52\n" +
" * secondary channel offset: no secondary\n" +
" * STA channel width: 20 MHz\n" +
" * RIFS: 1\n" +
" * HT protection: no\n" +
" * non-GF present: 1\n" +
" * OBSS non-GF present: 0\n" +
" * dual beacon: 0\n" +
" * dual CTS protection: 0\n" +
" * STBC beacon: 0\n" +
" * L-SIG TXOP Prot: 0\n" +
" * PCO active: 0\n" +
" * PCO phase: 0\n" +
" Extended capabilities: Proxy ARP Service, WNM-Notification, 6\n" +
" VHT capabilities:\n" +
" VHT Capabilities (0x0f8379b2):\n" +
" Max MPDU length: 11454\n" +
" Supported Channel Width: neither 160 nor 80+80\n" +
" RX LDPC\n" +
" short GI (80 MHz)\n" +
" TX STBC\n" +
" SU Beamformer\n" +
" SU Beamformee\n" +
" VHT RX MCS set:\n" +
" 1 streams: MCS 0-9\n" +
" 2 streams: MCS 0-9\n" +
" 3 streams: MCS 0-9\n" +
" 4 streams: not supported\n" +
" 5 streams: not supported\n" +
" 6 streams: not supported\n" +
" 7 streams: not supported\n" +
" 8 streams: not supported\n" +
" VHT RX highest supported: 0 Mbps\n" +
" VHT TX MCS set:\n" +
" 1 streams: MCS 0-9\n" +
" 2 streams: MCS 0-9\n" +
" 3 streams: MCS 0-9\n" +
" 4 streams: not supported\n" +
" 5 streams: not supported\n" +
" 6 streams: not supported\n" +
" 7 streams: not supported\n" +
" 8 streams: not supported\n" +
" VHT TX highest supported: 0 Mbps\n" +
" VHT operation:\n" +
" * channel width: 0 (20 or 40 MHz)\n" +
" * center freq segment 1: 0\n" +
" * center freq segment 2: 0\n" +
" * VHT basic MCS set: 0x0000\n" +
" WPA: * Version: 1\n" +
" * Group cipher: CCMP\n" +
" * Pairwise ciphers: CCMP\n" +
" * Authentication suites: PSK\n" +
" * Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)\n" +
" WMM: * Parameter version 1\n" +
" * u-APSD\n" +
" * BE: CW 15-1023, AIFSN 3\n" +
" * BK: CW 15-1023, AIFSN 7\n" +
" * VI: CW 7-15, AIFSN 2, TXOP 3008 usec\n" +
" * VO: CW 3-7, AIFSN 2, TXOP 1504 usec\n" +
"BSS f4:0f:1b:b5:5b:4e(on wlan0)\n" +
" TSF: 337645151 usec (0d, 00:05:37)\n" +
" freq: 5260\n" +
" beacon interval: 102 TUs\n" +
" capability: ESS RadioMeasure (0x1001)\n" +
" signal: -59.00 dBm\n" +
" last seen: 4530 ms ago\n" +
" Information elements from Probe Response frame:\n" +
" SSID: Flex-Visitor\n" +
" Supported rates: 6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 \n" +
" Country: US Environment: Indoor/Outdoor\n" +
" Channels [36 - 48] @ 17 dBm\n" +
" Channels [52 - 64] @ 24 dBm\n" +
" Channels [100 - 116] @ 24 dBm\n" +
" Channels [132 - 140] @ 24 dBm\n" +
" Channels [149 - 165] @ 30 dBm\n" +
" BSS Load:\n" +
" * station count: 14\n" +
" * channel utilisation: 16/255\n" +
" * available admission capacity: 23437 [*32us]\n" +
" HT capabilities:\n" +
" Capabilities: 0x19ac\n" +
" HT20\n" +
" SM Power Save disabled\n" +
" RX HT20 SGI\n" +
" TX STBC\n" +
" RX STBC 1-stream\n" +
" Max AMSDU length: 7935 bytes\n" +
" DSSS/CCK HT40\n" +
" Maximum RX AMPDU length 65535 bytes (exponent: 0x003)\n" +
" Minimum RX AMPDU time spacing: 8 usec (0x06)\n" +
" HT RX MCS rate indexes supported: 0-23\n" +
" HT TX MCS rate indexes are undefined\n" +
" HT operation:\n" +
" * primary channel: 52\n" +
" * secondary channel offset: no secondary\n" +
" * STA channel width: 20 MHz\n" +
" * RIFS: 1\n" +
" * HT protection: no\n" +
" * non-GF present: 1\n" +
" * OBSS non-GF present: 0\n" +
" * dual beacon: 0\n" +
" * dual CTS protection: 0\n" +
" * STBC beacon: 0\n" +
" * L-SIG TXOP Prot: 0\n" +
" * PCO active: 0\n" +
" * PCO phase: 0\n" +
" Extended capabilities: Proxy ARP Service, WNM-Notification, 6\n" +
" VHT capabilities:\n" +
" VHT Capabilities (0x0f8379b2):\n" +
" Max MPDU length: 11454\n" +
" Supported Channel Width: neither 160 nor 80+80\n" +
" RX LDPC\n" +
" short GI (80 MHz)\n" +
" TX STBC\n" +
" SU Beamformer\n" +
" SU Beamformee\n" +
" VHT RX MCS set:\n" +
" 1 streams: MCS 0-9\n" +
" 2 streams: MCS 0-9\n" +
" 3 streams: MCS 0-9\n" +
" 4 streams: not supported\n" +
" 5 streams: not supported\n" +
" 6 streams: not supported\n" +
" 7 streams: not supported\n" +
" 8 streams: not supported\n" +
" VHT RX highest supported: 0 Mbps\n" +
" VHT TX MCS set:\n" +
" 1 streams: MCS 0-9\n" +
" 2 streams: MCS 0-9\n" +
" 3 streams: MCS 0-9\n" +
" 4 streams: not supported\n" +
" 5 streams: not supported\n" +
" 6 streams: not supported\n" +
" 7 streams: not supported\n" +
" 8 streams: not supported\n" +
" VHT TX highest supported: 0 Mbps\n" +
" VHT operation:\n" +
" * channel width: 0 (20 or 40 MHz)\n" +
" * center freq segment 1: 0\n" +
" * center freq segment 2: 0\n" +
" * VHT basic MCS set: 0x0000\n" +
" WMM: * Parameter version 1\n" +
" * u-APSD\n" +
" * BE: CW 15-1023, AIFSN 3\n" +
" * BK: CW 15-1023, AIFSN 7\n" +
" * VI: CW 7-15, AIFSN 2, TXOP 3008 usec\n" +
" * VO: CW 3-7, AIFSN 2, TXOP 1504 usec\n" +
"BSS 6c:70:9f:e7:d8:b3(on wlan0)\n" +
" TSF: 337644811 usec (0d, 00:05:37)\n" +
" freq: 5180\n" +
" beacon interval: 100 TUs\n" +
" capability: ESS Privacy SpectrumMgmt RadioMeasure (0x1111)\n" +
" signal: -77.00 dBm\n" +
" last seen: 2110 ms ago\n" +
" Information elements from Probe Response frame:\n" +
" SSID: QA Lab 5GHz\n" +
" Supported rates: 6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 \n" +
" Country: US Environment: Indoor/Outdoor\n" +
" Channels [36 - 36] @ 17 dBm\n" +
" Channels [40 - 40] @ 17 dBm\n" +
" Channels [44 - 44] @ 17 dBm\n" +
" Channels [48 - 48] @ 17 dBm\n" +
" Channels [52 - 52] @ 24 dBm\n" +
" Channels [56 - 56] @ 24 dBm\n" +
" Channels [60 - 60] @ 24 dBm\n" +
" Channels [64 - 64] @ 24 dBm\n" +
" Channels [100 - 100] @ 24 dBm\n" +
" Channels [104 - 104] @ 24 dBm\n" +
" Channels [108 - 108] @ 24 dBm\n" +
" Channels [112 - 112] @ 24 dBm\n" +
" Channels [116 - 116] @ 24 dBm\n" +
" Channels [132 - 132] @ 24 dBm\n" +
" Channels [136 - 136] @ 24 dBm\n" +
" Channels [140 - 140] @ 24 dBm\n" +
" Channels [144 - 144] @ 24 dBm\n" +
" Channels [149 - 149] @ 30 dBm\n" +
" Channels [153 - 153] @ 30 dBm\n" +
" Channels [157 - 157] @ 30 dBm\n" +
" Channels [161 - 161] @ 30 dBm\n" +
" Channels [165 - 165] @ 30 dBm\n" +
" Power constraint: 0 dB\n" +
" TPC report: TX power: 17 dBm\n" +
" RSN: * Version: 1\n" +
" * Group cipher: CCMP\n" +
" * Pairwise ciphers: CCMP\n" +
" * Authentication suites: PSK\n" +
" * Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)\n" +
" HT capabilities:\n" +
" Capabilities: 0x9ef\n" +
" RX LDPC\n" +
" HT20/HT40\n" +
" SM Power Save disabled\n" +
" RX HT20 SGI\n" +
" RX HT40 SGI\n" +
" TX STBC\n" +
" RX STBC 1-stream\n" +
" Max AMSDU length: 7935 bytes\n" +
" No DSSS/CCK HT40\n" +
" Maximum RX AMPDU length 65535 bytes (exponent: 0x003)\n" +
" Minimum RX AMPDU time spacing: 4 usec (0x05)\n" +
" HT RX MCS rate indexes supported: 0-23\n" +
" HT TX MCS rate indexes are undefined\n" +
" HT operation:\n" +
" * primary channel: 36\n" +
" * secondary channel offset: above\n" +
" * STA channel width: any\n" +
" * RIFS: 1\n" +
" * HT protection: no\n" +
" * non-GF present: 0\n" +
" * OBSS non-GF present: 0\n" +
" * dual beacon: 0\n" +
" * dual CTS protection: 0\n" +
" * STBC beacon: 0\n" +
" * L-SIG TXOP Prot: 0\n" +
" * PCO active: 0\n" +
" * PCO phase: 0\n" +
" Extended capabilities: 6\n" +
" VHT capabilities:\n" +
" VHT Capabilities (0x0f8259b2):\n" +
" Max MPDU length: 11454\n" +
" Supported Channel Width: neither 160 nor 80+80\n" +
" RX LDPC\n" +
" short GI (80 MHz)\n" +
" TX STBC\n" +
" SU Beamformer\n" +
" SU Beamformee\n" +
" VHT RX MCS set:\n" +
" 1 streams: MCS 0-9\n" +
" 2 streams: MCS 0-9\n" +
" 3 streams: MCS 0-9\n" +
" 4 streams: not supported\n" +
" 5 streams: not supported\n" +
" 6 streams: not supported\n" +
" 7 streams: not supported\n" +
" 8 streams: not supported\n" +
" VHT RX highest supported: 0 Mbps\n" +
" VHT TX MCS set:\n" +
" 1 streams: MCS 0-9\n" +
" 2 streams: MCS 0-9\n" +
" 3 streams: MCS 0-9\n" +
" 4 streams: not supported\n" +
" 5 streams: not supported\n" +
" 6 streams: not supported\n" +
" 7 streams: not supported\n" +
" 8 streams: not supported\n" +
" VHT TX highest supported: 0 Mbps\n" +
" VHT operation:\n" +
" * channel width: 1 (80 MHz)\n" +
" * center freq segment 1: 42\n" +
" * center freq segment 2: 0\n" +
" * VHT basic MCS set: 0x0000\n" +
" WMM: * Parameter version 1\n" +
" * u-APSD\n" +
" * BE: CW 15-1023, AIFSN 3\n" +
" * BK: CW 15-1023, AIFSN 7\n" +
" * VI: CW 7-15, AIFSN 2, TXOP 3008 usec\n" +
" * VO: CW 3-7, AIFSN 2, TXOP 1504 usec\n" +
"BSS 2c:30:33:ec:4b:24(on wlan0)\n" +
" TSF: 337644493 usec (0d, 00:05:37)\n" +
" freq: 2437\n" +
" beacon interval: 31 TUs\n" +
" capability: ESS Privacy ShortPreamble SpectrumMgmt ShortSlotTime RadioMeasure (0x1531)\n" +
" signal: -68.00 dBm\n" +
" last seen: 0 ms ago\n" +
" Information elements from Probe Response frame:\n" +
" SSID: NETGEAR03\n" +
" Supported rates: 1.0* 2.0* 5.5 11.0 18.0 24.0 36.0 54.0 \n" +
" DS Parameter set: channel 6\n" +
" Country: US Environment: Indoor/Outdoor\n" +
" Channels [1 - 11] @ 30 dBm\n" +
" Power constraint: 0 dB\n" +
" TPC report: TX power: 25 dBm\n" +
" ERP: <no flags>\n" +
" ERP D4.0: <no flags>\n" +
" RSN: * Version: 1\n" +
" * Group cipher: CCMP\n" +
" * Pairwise ciphers: CCMP\n" +
" * Authentication suites: PSK\n" +
" * Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)\n" +
" Extended supported rates: 6.0 9.0 12.0 48.0 \n" +
" BSS Load:\n" +
" * station count: 1\n" +
" * channel utilisation: 166/255\n" +
" * available admission capacity: 0 [*32us]\n" +
" HT capabilities:\n" +
" Capabilities: 0x19b0\n" +
" HT20\n" +
" Static SM Power Save\n" +
" RX Greenfield\n" +
" RX HT20 SGI\n" +
" TX STBC\n" +
" RX STBC 1-stream\n" +
" Max AMSDU length: 7935 bytes\n" +
" DSSS/CCK HT40\n" +
" Maximum RX AMPDU length 65535 bytes (exponent: 0x003)\n" +
" Minimum RX AMPDU time spacing: 8 usec (0x06)\n" +
" HT RX MCS rate indexes supported: 0-15\n" +
" HT TX MCS rate indexes are undefined\n" +
" HT operation:\n" +
" * primary channel: 6\n" +
" * secondary channel offset: no secondary\n" +
" * STA channel width: 20 MHz\n" +
" * RIFS: 1\n" +
" * HT protection: no\n" +
" * non-GF present: 1\n" +
" * OBSS non-GF present: 0\n" +
" * dual beacon: 0\n" +
" * dual CTS protection: 0\n" +
" * STBC beacon: 0\n" +
" * L-SIG TXOP Prot: 0\n" +
" * PCO active: 0\n" +
" * PCO phase: 0\n" +
" Extended capabilities: Extended Channel Switching, BSS Transition, 6\n" +
" WPS: * Version: 1.0\n" +
" * Wi-Fi Protected Setup State: 2 (Configured)\n" +
" * Response Type: 3 (AP)\n" +
" * UUID: 00000000-0000-0000-0000-000000000000\n" +
" * Manufacturer: NETGEAR, Inc.\n" +
" * Model: VMB3010\n" +
" * Model Number: VMB3010\n" +
" * Serial Number: 01\n" +
" * Primary Device Type: 6-0050f204-1\n" +
" * Device name: NTGRBS\n" +
" * Config methods: Label, PBC\n" +
" * RF Bands: 0x1\n" +
" WMM: * Parameter version 1\n" +
" * u-APSD\n" +
" * BE: CW 15-1023, AIFSN 3\n" +
" * BK: CW 15-1023, AIFSN 7\n" +
" * VI: CW 7-15, AIFSN 2, TXOP 6016 usec\n" +
" * VO: CW 3-7, AIFSN 2, TXOP 3264 usec\n" +
"BSS 7c:0e:ce:b7:d7:90(on wlan0)\n" +
" TSF: 239785397355 usec (2d, 18:36:25)\n" +
" freq: 2412\n" +
" beacon interval: 102 TUs\n" +
" capability: ESS Privacy ShortPreamble ShortSlotTime RadioMeasure (0x1431)\n" +
" signal: -77.00 dBm\n" +
" last seen: 10 ms ago\n" +
" Information elements from Probe Response frame:\n" +
" SSID: Flex-Skynet\n" +
" Supported rates: 1.0* 2.0* 5.5* 6.0 9.0 11.0* 12.0 18.0 \n" +
" DS Parameter set: channel 1\n" +
" Country: US Environment: Indoor/Outdoor\n" +
" Channels [1 - 11] @ 30 dBm\n" +
" BSS Load:\n" +
" * station count: 2\n" +
" * channel utilisation: 201/255\n" +
" * available admission capacity: 23437 [*32us]\n" +
" ERP: <no flags>\n" +
" HT capabilities:\n" +
" Capabilities: 0x19ac\n" +
" HT20\n" +
" SM Power Save disabled\n" +
" RX HT20 SGI\n" +
" TX STBC\n" +
" RX STBC 1-stream\n" +
" Max AMSDU length: 7935 bytes\n" +
" DSSS/CCK HT40\n" +
" Maximum RX AMPDU length 65535 bytes (exponent: 0x003)\n" +
" Minimum RX AMPDU time spacing: 8 usec (0x06)\n" +
" HT RX MCS rate indexes supported: 0-23\n" +
" HT TX MCS rate indexes are undefined\n" +
" RSN: * Version: 1\n" +
" * Group cipher: CCMP\n" +
" * Pairwise ciphers: CCMP\n" +
" * Authentication suites: IEEE 802.1X\n" +
" * Capabilities: 4-PTKSA-RC 4-GTKSA-RC (0x0028)\n" +
" Extended supported rates: 24.0 36.0 48.0 54.0 \n" +
" HT operation:\n" +
" * primary channel: 1\n" +
" * secondary channel offset: no secondary\n" +
" * STA channel width: 20 MHz\n" +
" * RIFS: 0\n" +
" * HT protection: nonmember\n" +
" * non-GF present: 1\n" +
" * OBSS non-GF present: 0\n" +
" * dual beacon: 0\n" +
" * dual CTS protection: 0\n" +
" * STBC beacon: 0\n" +
" * L-SIG TXOP Prot: 0\n" +
" * PCO active: 0\n" +
" * PCO phase: 0\n" +
" Extended capabilities: Proxy ARP Service, WNM-Notification\n" +
" WMM: * Parameter version 1\n" +
" * u-APSD\n" +
" * BE: CW 15-1023, AIFSN 3\n" +
" * BK: CW 15-1023, AIFSN 7\n" +
" * VI: CW 7-15, AIFSN 2, TXOP 3008 usec\n" +
" * VO: CW 3-7, AIFSN 2, TXOP 1504 usec\n" +
"BSS cc:46:d6:3c:91:04(on wlan0)\n" +
" TSF: 337644462 usec (0d, 00:05:37)\n" +
" freq: 2412\n" +
" beacon interval: 102 TUs\n" +
" capability: ESS ShortPreamble ShortSlotTime RadioMeasure (0x1421)\n" +
" signal: -90.00 dBm\n" +
" last seen: 0 ms ago\n" +
" SSID: \\x00\n" +
" Supported rates: 1.0* 2.0* 5.5* 6.0 9.0 11.0* 12.0 18.0 \n" +
" DS Parameter set: channel 1\n" +
" TIM: DTIM Count 0 DTIM Period 1 Bitmap Control 0x0 Bitmap[0] 0x0\n" +
" Country: US Environment: Indoor/Outdoor\n" +
" Channels [1 - 11] @ 30 dBm\n" +
" BSS Load:\n" +
" * station count: 1\n" +
" * channel utilisation: 190/255\n" +
" * available admission capacity: 23437 [*32us]\n" +
" ERP: <no flags>\n" +
" HT capabilities:\n" +
" Capabilities: 0x19ac\n" +
" HT20\n" +
" SM Power Save disabled\n" +
" RX HT20 SGI\n" +
" TX STBC\n" +
" RX STBC 1-stream\n" +
" Max AMSDU length: 7935 bytes\n" +
" DSSS/CCK HT40\n" +
" Maximum RX AMPDU length 65535 bytes (exponent: 0x003)\n" +
" Minimum RX AMPDU time spacing: 8 usec (0x06)\n" +
" HT RX MCS rate indexes supported: 0-23\n" +
" HT TX MCS rate indexes are undefined\n" +
" Extended supported rates: 24.0 36.0 48.0 54.0 \n" +
" HT operation:\n" +
" * primary channel: 1\n" +
" * secondary channel offset: no secondary\n" +
" * STA channel width: 20 MHz\n" +
" * RIFS: 0\n" +
" * HT protection: nonmember\n" +
" * non-GF present: 1\n" +
" * OBSS non-GF present: 0\n" +
" * dual beacon: 0\n" +
" * dual CTS protection: 0\n" +
" * STBC beacon: 0\n" +
" * L-SIG TXOP Prot: 0\n" +
" * PCO active: 0\n" +
" * PCO phase: 0\n" +
" Extended capabilities: Proxy ARP Service, WNM-Notification\n" +
" WMM: * Parameter version 1\n" +
" * u-APSD\n" +
" * BE: CW 15-1023, AIFSN 3\n" +
" * BK: CW 15-1023, AIFSN 7\n" +
" * VI: CW 7-15, AIFSN 2, TXOP 3008 usec\n" +
" * VO: CW 3-7, AIFSN 2, TXOP 1504 usec\n" +
"BSS 14:91:82:bd:15:61(on wlan0)\n" +
" TSF: 337644716 usec (0d, 00:05:37)\n" +
" freq: 2457\n" +
" beacon interval: 100 TUs\n" +
" capability: ESS Privacy ShortSlotTime (0x0411)\n" +
" signal: -88.00 dBm\n" +
" last seen: 1070 ms ago\n" +
" Information elements from Probe Response frame:\n" +
" SSID: beast10\n" +
" Supported rates: 1.0* 2.0* 5.5* 11.0* 22.0 6.0 9.0 12.0 \n" +
" DS Parameter set: channel 10\n" +
" TIM: DTIM Count 1 DTIM Period 2 Bitmap Control 0x0 Bitmap[0] 0x0\n" +
" ERP: <no flags>\n" +
" Extended supported rates: 18.0 24.0 36.0 48.0 54.0 \n" +
" Extended capabilities: 6\n" +
" VHT capabilities:\n" +
" VHT Capabilities (0x33801831):\n" +
" Max MPDU length: 7991\n" +
" Supported Channel Width: neither 160 nor 80+80\n" +
" RX LDPC\n" +
" short GI (80 MHz)\n" +
" SU Beamformer\n" +
" SU Beamformee\n" +
" RX antenna pattern consistency\n" +
" TX antenna pattern consistency\n" +
" VHT RX MCS set:\n" +
" 1 streams: MCS 0-9\n" +
" 2 streams: MCS 0-9\n" +
" 3 streams: MCS 0-9\n" +
" 4 streams: not supported\n" +
" 5 streams: not supported\n" +
" 6 streams: not supported\n" +
" 7 streams: not supported\n" +
" 8 streams: not supported\n" +
" VHT RX highest supported: 0 Mbps\n" +
" VHT TX MCS set:\n" +
" 1 streams: MCS 0-9\n" +
" 2 streams: MCS 0-9\n" +
" 3 streams: MCS 0-9\n" +
" 4 streams: not supported\n" +
" 5 streams: not supported\n" +
" 6 streams: not supported\n" +
" 7 streams: not supported\n" +
" 8 streams: not supported\n" +
" VHT TX highest supported: 0 Mbps\n" +
" VHT operation:\n" +
" * channel width: 0 (20 or 40 MHz)\n" +
" * center freq segment 1: 0\n" +
" * center freq segment 2: 0\n" +
" * VHT basic MCS set: 0xfffc\n" +
" WMM: * Parameter version 1\n" +
" * BE: CW 15-1023, AIFSN 3, TXOP 2048 usec\n" +
" * BK: CW 15-1023, AIFSN 7\n" +
" * VI: CW 7-15, AIFSN 2, TXOP 3008 usec\n" +
" * VO: CW 3-7, AIFSN 2, TXOP 1504 usec\n"
describe('iw', function() {
describe('iw.scan(interface, callback)', function() {
it('should scan the specified interface', function(done) {
iw.exec = function(command, callback) {
should(command).eql('iw dev wlan0 scan');
callback(null, IW_SCAN_LINUX, '');
};
iw.scan('wlan0', function(err, status) {
should(status).eql([
{ frequency: 5260,
address: "f4:0f:1b:b5:5b:4d",
signal: -59,
lastSeenMs: 4530,
ssid: 'Wink-Visitor',
channel: 52,
security: 'wpa' },
{ frequency: 5260,
address: "f4:0f:1b:b5:5b:4e",
signal: -59,
lastSeenMs: 4530,
ssid: 'Flex-Visitor',
channel: 52,
security: 'open' },
{ frequency: 2437,
address: "2c:30:33:ec:4b:24",
signal: -68,
lastSeenMs: 0,
ssid: 'NETGEAR03',
channel: 6,
security: 'wpa2' },
{ frequency: 5180,
address: "6c:70:9f:e7:d8:b3",
signal: -77,
lastSeenMs: 2110,
ssid: 'QA Lab 5GHz',
channel: 36,
security: 'wpa2' },
{ frequency: 2412,
address: "7c:0e:ce:b7:d7:90",
signal: -77,
lastSeenMs: 10,
ssid: 'Flex-Skynet',
channel: 1,
security: 'wpa2' },
{ frequency: 2412,
address: "14:91:82:c7:76:b9",
signal: -87,
lastSeenMs: 0,
ssid: 'creamcorn',
channel: 1,
security: 'wpa2' },
{ frequency: 2457,
address: "14:91:82:bd:15:61",
signal: -88,
lastSeenMs: 1070,
ssid: 'beast10',
channel: 10,
security: 'wep' },
]);
done();
});
})
it('should scan the specified interface and show hidden ssid networks', function(done) {
iw.exec = function(command, callback) {
should(command).eql('iw dev wlan0 scan');
callback(null, IW_SCAN_LINUX, '');
};
var options = {
iface: 'wlan0',
show_hidden: true
};
iw.scan(options, function(err, status) {
should(status).eql([
{ frequency: 5260,
address: "f4:0f:1b:b5:5b:4d",
signal: -59,
lastSeenMs: 4530,
ssid: 'Wink-Visitor',
channel: 52,
security: 'wpa' },
{ frequency: 5260,
address: "f4:0f:1b:b5:5b:4e",
signal: -59,
lastSeenMs: 4530,
ssid: 'Flex-Visitor',
channel: 52,
security: 'open' },
{ frequency: 2437,
address: "2c:30:33:ec:4b:24",
signal: -68,
lastSeenMs: 0,
ssid: 'NETGEAR03',
channel: 6,
security: 'wpa2' },
{ frequency: 5180,
address: "6c:70:9f:e7:d8:b3",
signal: -77,
lastSeenMs: 2110,
ssid: 'QA Lab 5GHz',
channel: 36,
security: 'wpa2' },
{ frequency: 2412,
address: "7c:0e:ce:b7:d7:90",
signal: -77,
lastSeenMs: 10,
ssid: 'Flex-Skynet',
channel: 1,
security: 'wpa2' },
{ frequency: 2412,
address: "14:91:82:c7:76:b9",
signal: -87,
lastSeenMs: 0,
ssid: 'creamcorn',
channel: 1,
security: 'wpa2' },
{ frequency: 2457,
address: "14:91:82:bd:15:61",
signal: -88,
lastSeenMs: 1070,
ssid: 'beast10',
channel: 10,
security: 'wep' },
{ frequency: 2412,
address: "cc:46:d6:3c:91:04",
signal: -90,
lastSeenMs: 0,
channel: 1,
security: 'open' },
]);
done();
});
})
it('should scan the specified interface and not show hidden ssid networks', function(done) {
iw.exec = function(command, callback) {
should(command).eql('iw dev wlan0 scan');
callback(null, IW_SCAN_LINUX, '');
};
var options = {
iface: 'wlan0'
};
iw.scan(options, function(err, status) {
should(status).eql([
{ frequency: 5260,
address: "f4:0f:1b:b5:5b:4d",
signal: -59,
lastSeenMs: 4530,
ssid: 'Wink-Visitor',
channel: 52,
security: 'wpa' },
{ frequency: 5260,
address: "f4:0f:1b:b5:5b:4e",
signal: -59,
lastSeenMs: 4530,
ssid: 'Flex-Visitor',
channel: 52,
security: 'open' },
{ frequency: 2437,
address: "2c:30:33:ec:4b:24",
signal: -68,
lastSeenMs: 0,
ssid: 'NETGEAR03',
channel: 6,
security: 'wpa2' },
{ frequency: 5180,
address: "6c:70:9f:e7:d8:b3",
signal: -77,
lastSeenMs: 2110,
ssid: 'QA Lab 5GHz',
channel: 36,
security: 'wpa2' },
{ frequency: 2412,
address: "7c:0e:ce:b7:d7:90",
signal: -77,
lastSeenMs: 10,
ssid: 'Flex-Skynet',
channel: 1,
security: 'wpa2' },
{ frequency: 2412,
address: "14:91:82:c7:76:b9",
signal: -87,
lastSeenMs: 0,
ssid: 'creamcorn',
channel: 1,
security: 'wpa2' },
{ frequency: 2457,
address: "14:91:82:bd:15:61",
signal: -88,
lastSeenMs: 1070,
ssid: 'beast10',
channel: 10,
security: 'wep' },
]);
done();
});
})
it('should handle errors', function(done) {
iw.exec = function(command, callback) {
callback('error');
};
iw.scan('wlan0', function(err, status) {
should(err).eql('error');
done();
});
})
})
})

201
tests/node_modules/wireless-tools/test/iwconfig.js generated vendored Normal file
View File

@ -0,0 +1,201 @@
/*
* Copyright (c) 2015 Christopher M. Baker
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
var should = require('should');
var iwconfig = require('../iwconfig');
var IWCONFIG_STATUS_LINUX = [
'wlan0 IEEE 802.11bg ESSID:"RaspberryPi" Nickname:"<WIFI@REALTEK>"',
' Mode:Master Frequency:2.437 GHz Access Point: 00:0B:81:95:12:21',
' Bit Rate:54 Mb/s Sensitivity:0/0',
' Retry:off RTS thr:off Fragment thr:off',
' Power Management:off',
' Link Quality=18/100 Signal level=11/100 Noise level=0/100',
' Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0',
' Tx excessive retries:0 Invalid misc:0 Missed beacon:0',
'',
'',
'',
'wlan1 unassociated Nickname:"<WIFI@REALTEK>"',
' Mode:Auto Frequency=2.412 GHz Access Point: Not-Associated',
' Sensitivity:0/0',
' Retry:off RTS thr:off Fragment thr:off',
' Power Management:off',
' Link Quality:0 Signal level:0 Noise level:0',
' Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0',
' Tx excessive retries:0 Invalid misc:0 Missed beacon:0',
'',
'lo no wireless extensions.',
''
].join('\n');
var IWCONFIG_STATUS_INTERFACE_LINUX = [
'wlan0 IEEE 802.11bg ESSID:"RaspberryPi" Nickname:"<WIFI@REALTEK>"',
' Mode:Master Frequency:2.437 GHz Access Point: 00:0B:81:95:12:21',
' Bit Rate:54 Mb/s Sensitivity:0/0',
' Retry:off RTS thr:off Fragment thr:off',
' Power Management:off',
' Link Quality=18/100 Signal level=11/100 Noise level=0/100',
' Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0',
' Tx excessive retries:0 Invalid misc:0 Missed beacon:0',
''
].join('\n');
var IWCONFIG_STATUS_INTERFACE_LINUX2 = [
'wlan0 IEEE 802.11abgn ESSID:"FAKE-Wifi"',
' Mode:Managed Frequency:2.412 GHz Access Point: 00:0B:81:95:12:21',
' Bit Rate=36 Mb/s Tx-Power=22 dBm',
' Retry short limit:7 RTS thr:off Fragment thr:off',
' Encryption key:off',
' Power Management:on',
' Link Quality=63/70 Signal level=-47 dBm',
' Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0',
' Tx excessive retries:0 Invalid misc:0 Missed beacon:0',
''
].join('\n');
describe('iwconfig', function() {
describe('iwconfig.status(callback)', function() {
it('should get the status for each interface', function(done) {
iwconfig.exec = function(command, callback) {
should(command).eql('iwconfig');
callback(null, IWCONFIG_STATUS_LINUX, '');
};
iwconfig.status(function(err, status) {
should(status).eql([
{
interface: 'wlan0',
ssid: 'RaspberryPi',
access_point: '00:0b:81:95:12:21',
ieee: '802.11bg',
mode: 'master',
frequency: 2.437,
sensitivity: 0,
quality: 18,
signal: 11,
noise: 0
},
{
interface: 'wlan1',
unassociated: true,
mode: 'auto',
frequency: 2.412,
sensitivity: 0,
quality: 0,
signal: 0,
noise: 0
},
{
interface: 'lo'
}
]);
done();
});
})
it('should handle errors', function(done) {
iwconfig.exec = function(command, callback) {
callback('error');
};
iwconfig.status(function(err, status) {
should(err).eql('error');
done();
});
})
})
describe('iwconfig.status(interface, callback)', function() {
it('should get the status for the specified interface', function(done) {
iwconfig.exec = function(command, callback) {
should(command).eql('iwconfig wlan0');
callback(null, IWCONFIG_STATUS_INTERFACE_LINUX, '');
};
iwconfig.status('wlan0', function(err, status) {
should(status).eql({
interface: 'wlan0',
ssid: 'RaspberryPi',
access_point: '00:0b:81:95:12:21',
ieee: '802.11bg',
mode: 'master',
frequency: 2.437,
sensitivity: 0,
quality: 18,
signal: 11,
noise: 0
});
done();
});
})
it('should handle errors', function(done) {
iwconfig.exec = function(command, callback) {
callback('error');
};
iwconfig.status('wlan0', function(err, status) {
should(err).eql('error');
done();
});
})
})
describe('iwconfig.status(interface, callback)', function() {
it('should get the status for the specified interface', function(done) {
iwconfig.exec = function(command, callback) {
should(command).eql('iwconfig wlan0');
callback(null, IWCONFIG_STATUS_INTERFACE_LINUX2, '');
};
iwconfig.status('wlan0', function(err, status) {
should(status).eql({
interface: 'wlan0',
ssid: 'FAKE-Wifi',
access_point: '00:0b:81:95:12:21',
ieee: '802.11abgn',
mode: 'managed',
frequency: 2.412,
quality: 63,
signal: -47
});
done();
});
})
it('should handle errors', function(done) {
iwconfig.exec = function(command, callback) {
callback('error');
};
iwconfig.status('wlan0', function(err, status) {
should(err).eql('error');
done();
});
})
})
})

368
tests/node_modules/wireless-tools/test/iwlist.js generated vendored Normal file
View File

@ -0,0 +1,368 @@
/*
* Copyright (c) 2015 Christopher M. Baker
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
var should = require('should');
var iwlist = require('../iwlist');
var IWLIST_SCAN_LINUX = [
'Cell 01 - Address: 00:0B:81:95:12:21',
' ESSID:"RaspberryPi"',
' Protocol:IEEE 802.11bgn',
' Mode:Master',
' Frequency:2.437 GHz (Channel 6)',
' Encryption key:on',
' Bit Rates:144 Mb/s',
' Extra:rsn_ie=00000000000000000000000000000000000000000000',
' IE: IEEE 802.11i/WPA2 Version 1',
' Group Cipher : CCMP',
' Pairwise Ciphers (1) : CCMP',
' Authentication Suites (1) : PSK',
' IE: Unknown: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
' Quality=58/100 Signal level=83/100',
'Cell 02 - Address: 00:0B:81:AB:14:22',
' ESSID:"BlueberryPi"',
' Protocol:IEEE 802.11bgn',
' Mode:Master',
' Frequency:2.437 GHz (Channel 6)',
' Encryption key:on',
' Bit Rates:144 Mb/s',
' IE: WPA Version 1',
' Group Cipher : TKIP',
' Pairwise Ciphers (2) : CCMP TKIP',
' Authentication Suites (1) : PSK',
' Extra:rsn_ie=0000000000000000000000000000000000000000000000000000',
' Quality=48/100 Signal level=87/100',
'Cell 03 - Address: 00:0B:81:CD:F2:04',
' ESSID:"BlackberryPi"',
' Protocol:IEEE 802.11bgn',
' Mode:Master',
' Frequency:2.437 GHz (Channel 6)',
' Encryption key:on',
' Bit Rates:144 Mb/s',
' IE: Unknown: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
' Extra:rsn_ie=0000000000000000000000000000000000000000000000000000',
' Quality=48/100 Signal level=80/100',
'Cell 04 - Address: 00:0B:81:FD:42:14',
' ESSID:"CranberryPi"',
' Protocol:IEEE 802.11bgn',
' Mode:Master',
' Frequency:2.437 GHz (Channel 6)',
' Encryption key:off',
' Bit Rates:144 Mb/s',
' IE: Unknown: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
' Quality:4/5 Signal level:-60 dBm Noise level:-92 dBm',
'Cell 05 - Address: 2C:C5:D3:02:AE:4C',
' Channel:100',
' Frequency:5.5 GHz (Channel 100)',
' Quality=65/70 Signal level=-45 dBm',
' Encryption key:on',
' ESSID:""',
' Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s',
' Mode:Master',
' Extra:tsf=0000003d2a54d03b',
' Extra: Last beacon: 3360ms ago',
' IE: Unknown: DD180050F20201018E0003A4000027A4000042435E0062322F00',
' IE: Unknown: 2D1AAD091BF8FE000000000000000000001000000000000000000000',
' IE: Unknown: 3D1664000000000000000000000000000000000000000000',
' IE: IEEE 802.11i/WPA2 Version 1',
' Group Cipher : CCMP',
' Pairwise Ciphers (1) : CCMP',
' Authentication Suites (1) : PSK'
].join('\n');
var IWLIST_SCAN_LINUX_ACTIVE_SCAN = [
'Cell 01 - Address: 00:0B:81:95:12:21',
' ESSID:"RaspberryPi"',
' Protocol:IEEE 802.11bgn',
' Mode:Master',
' Frequency:2.437 GHz (Channel 6)',
' Encryption key:on',
' Bit Rates:144 Mb/s',
' Extra:rsn_ie=00000000000000000000000000000000000000000000',
' IE: IEEE 802.11i/WPA2 Version 1',
' Group Cipher : CCMP',
' Pairwise Ciphers (1) : CCMP',
' Authentication Suites (1) : PSK',
' IE: Unknown: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
' Quality=58/100 Signal level=83/100',
'Cell 02 - Address: 00:0B:81:AB:14:22',
' ESSID:"BlueberryPi"',
' Protocol:IEEE 802.11bgn',
' Mode:Master',
' Frequency:2.437 GHz (Channel 6)',
' Encryption key:on',
' Bit Rates:144 Mb/s',
' IE: WPA Version 1',
' Group Cipher : TKIP',
' Pairwise Ciphers (2) : CCMP TKIP',
' Authentication Suites (1) : PSK',
' Extra:rsn_ie=0000000000000000000000000000000000000000000000000000',
' Quality=48/100 Signal level=87/100',
'Cell 03 - Address: 00:0B:81:CD:F2:04',
' ESSID:"BlackberryPi"',
' Protocol:IEEE 802.11bgn',
' Mode:Master',
' Frequency:2.437 GHz (Channel 6)',
' Encryption key:on',
' Bit Rates:144 Mb/s',
' IE: Unknown: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
' Extra:rsn_ie=0000000000000000000000000000000000000000000000000000',
' Quality=48/100 Signal level=80/100',
'Cell 04 - Address: 00:0B:81:FD:42:14',
' ESSID:"CranberryPi"',
' Protocol:IEEE 802.11bgn',
' Mode:Master',
' Frequency:2.437 GHz (Channel 6)',
' Encryption key:off',
' Bit Rates:144 Mb/s',
' IE: Unknown: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
' Quality=32/100 Signal level=71/100',
'Cell 05 - Address: 2C:C5:D3:02:AE:4C',
' Channel:100',
' Frequency:5.5 GHz (Channel 100)',
' Quality=65/70 Signal level=-45 dBm',
' Encryption key:on',
' ESSID:"hidden-ssid"',
' Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s',
' Mode:Master',
' Extra:tsf=0000003d2a54d03b',
' Extra: Last beacon: 3360ms ago',
' IE: Unknown: DD180050F20201018E0003A4000027A4000042435E0062322F00',
' IE: Unknown: 2D1AAD091BF8FE000000000000000000001000000000000000000000',
' IE: Unknown: 3D1664000000000000000000000000000000000000000000',
' IE: IEEE 802.11i/WPA2 Version 1',
' Group Cipher : CCMP',
' Pairwise Ciphers (1) : CCMP',
' Authentication Suites (1) : PSK'
].join('\n');
describe('iwlist', function() {
describe('iwlist.scan(interface, callback)', function() {
it('should scan the specified interface', function(done) {
iwlist.exec = function(command, callback) {
should(command).eql('iwlist wlan0 scan');
callback(null, IWLIST_SCAN_LINUX, '');
};
iwlist.scan('wlan0', function(err, status) {
should(status).eql([
{
address: '00:0b:81:ab:14:22',
ssid: 'BlueberryPi',
mode: 'master',
frequency: 2.437,
channel: 6,
security: 'wpa',
quality: 48,
signal: 87
},
{
address: '00:0b:81:95:12:21',
ssid: 'RaspberryPi',
mode: 'master',
frequency: 2.437,
channel: 6,
security: 'wpa2',
quality: 58,
signal: 83
},
{
address: '00:0b:81:cd:f2:04',
ssid: 'BlackberryPi',
mode: 'master',
frequency: 2.437,
channel: 6,
security: 'wep',
quality: 48,
signal: 80
},
{
address: '00:0b:81:fd:42:14',
ssid: 'CranberryPi',
mode: 'master',
frequency: 2.437,
channel: 6,
security: 'open',
quality: 4,
signal: -60,
noise: -92
}
]);
done();
});
})
it('should scan the specified interface and show hidden ssid networks', function(done) {
iwlist.exec = function(command, callback) {
should(command).eql('iwlist wlan0 scan');
callback(null, IWLIST_SCAN_LINUX, '');
};
var options = {
iface: 'wlan0',
show_hidden: true
};
iwlist.scan(options, function(err, status) {
should(status).eql(
[
{
address: '00:0b:81:ab:14:22',
channel: 6,
frequency: 2.437,
mode: 'master',
quality: 48,
signal: 87,
ssid: 'BlueberryPi',
security: 'wpa'
},
{
address: '00:0b:81:95:12:21',
channel: 6,
frequency: 2.437,
mode: 'master',
quality: 58,
signal: 83,
ssid: 'RaspberryPi',
security: 'wpa2'
},
{
address: '00:0b:81:cd:f2:04',
channel: 6,
frequency: 2.437,
mode: 'master',
quality: 48,
signal: 80,
ssid: 'BlackberryPi',
security: 'wep'
},
{
address: '2c:c5:d3:02:ae:4c',
channel: 100,
frequency: 5.5,
mode: 'master',
quality: 65,
signal: -45,
security: 'wpa2'
},
{
address: '00:0b:81:fd:42:14',
channel: 6,
frequency: 2.437,
mode: 'master',
quality: 4,
signal: -60,
noise: -92,
ssid: 'CranberryPi',
security: 'open'
}
]);
done();
});
})
it('should scan the specified interface looking for hidden ssid', function(done) {
iwlist.exec = function(command, callback) {
should(command).eql('iwlist wlan0 scan essid hidden-ssid');
callback(null, IWLIST_SCAN_LINUX_ACTIVE_SCAN, '');
};
var options = {
iface: 'wlan0',
show_hidden: false,
ssid: 'hidden-ssid'
};
iwlist.scan(options, function(err, status) {
should(status).eql(
[
{
address: '00:0b:81:ab:14:22',
channel: 6,
frequency: 2.437,
mode: 'master',
quality: 48,
signal: 87,
ssid: 'BlueberryPi',
security: 'wpa'
},
{
address: '00:0b:81:95:12:21',
channel: 6,
frequency: 2.437,
mode: 'master',
quality: 58,
signal: 83,
ssid: 'RaspberryPi',
security: 'wpa2'
},
{
address: '00:0b:81:cd:f2:04',
channel: 6,
frequency: 2.437,
mode: 'master',
quality: 48,
signal: 80,
ssid: 'BlackberryPi',
security: 'wep'
},
{
address: '00:0b:81:fd:42:14',
channel: 6,
frequency: 2.437,
mode: 'master',
quality: 32,
signal: 71,
ssid: 'CranberryPi',
security: 'open'
},
{
address: '2c:c5:d3:02:ae:4c',
channel: 100,
frequency: 5.5,
mode: 'master',
quality: 65,
signal: -45,
ssid: 'hidden-ssid',
security: 'wpa2'
}
]);
done();
});
})
it('should handle errors', function(done) {
iwlist.exec = function(command, callback) {
callback('error');
};
iwlist.scan('wlan0', function(err, status) {
should(err).eql('error');
done();
});
})
})
})

87
tests/node_modules/wireless-tools/test/udhcpc.js generated vendored Normal file
View File

@ -0,0 +1,87 @@
/*
* Copyright (c) 2015 Christopher M. Baker
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
var should = require('should');
var udhcpc = require('../udhcpc');
describe('udhcpc', function() {
describe('udhcpc.disable(options, callback)', function() {
it('should stop the daemons', function(done) {
udhcpc.exec = function(command, callback) {
should(command).eql(
'kill `pgrep -f "^udhcpc -i wlan0"` || true');
callback(null, '', '');
};
udhcpc.disable('wlan0', function(err) {
should(err).not.be.ok;
done();
});
})
it('should handle errors', function(done) {
udhcpc.exec = function(command, callback) {
callback('error');
};
udhcpc.disable('wlan0', function(err) {
should(err).eql('error');
done();
});
})
})
describe('udhcpc.enable(options, callback)', function() {
it('should start the daemon', function(done) {
udhcpc.exec = function(command, callback) {
should(command).eql('udhcpc -i wlan0 -n');
callback(null, '', '');
};
var options = {
interface: 'wlan0'
};
udhcpc.enable(options, function(err) {
should(err).not.be.ok;
done();
});
})
it('should handle errors', function(done) {
udhcpc.exec = function(command, callback) {
callback('error');
};
var options = {
interface: 'wlan0'
};
udhcpc.enable(options, function(err) {
should(err).eql('error');
done();
});
})
})
})

111
tests/node_modules/wireless-tools/test/udhcpd.js generated vendored Normal file
View File

@ -0,0 +1,111 @@
/*
* Copyright (c) 2015 Christopher M. Baker
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
var should = require('should');
var udhcpd = require('../udhcpd');
describe('udhcpd', function() {
describe('udhcpd.disable(options, callback)', function() {
it('should stop the daemons', function(done) {
udhcpd.exec = function(command, callback) {
should(command).eql(
'kill `pgrep -f "^udhcpd wlan0-udhcpd.conf"` || true');
callback(null, '', '');
};
udhcpd.disable('wlan0', function(err) {
should(err).not.be.ok;
done();
});
})
it('should handle errors', function(done) {
udhcpd.exec = function(command, callback) {
callback('error');
};
udhcpd.disable('wlan0', function(err) {
should(err).eql('error');
done();
});
})
})
describe('udhcpd.enable(options, callback)', function() {
it('should start the daemon', function(done) {
udhcpd.exec = function(command, callback) {
should(command).eql('cat <<EOF >wlan0-udhcpd.conf' +
' && udhcpd wlan0-udhcpd.conf' +
' && rm -f wlan0-udhcpd.conf\n' +
'interface wlan0\n' +
'start 192.168.10.100\n' +
'end 192.168.10.200\n' +
'option router 192.168.10.1\n' +
'option subnet 255.255.255.0\n' +
'option dns 4.4.4.4\n' +
'option dns 8.8.8.8');
callback(null, '', '');
};
var options = {
interface: 'wlan0',
start: '192.168.10.100',
end: '192.168.10.200',
option: {
router: '192.168.10.1',
subnet: '255.255.255.0',
dns: [ '4.4.4.4', '8.8.8.8' ]
}
};
udhcpd.enable(options, function(err) {
should(err).not.be.ok;
done();
});
})
it('should handle errors', function(done) {
udhcpd.exec = function(command, callback) {
callback('error');
};
var options = {
interface: 'wlan0',
start: '192.168.10.100',
end: '192.168.10.200',
option: {
router: '192.168.10.1',
subnet: '255.255.255.0',
dns: [ '4.4.4.4', '8.8.8.8' ]
}
};
udhcpd.enable(options, function(err) {
should(err).eql('error');
done();
});
})
})
})

660
tests/node_modules/wireless-tools/test/wpa_cli.js generated vendored Normal file
View File

@ -0,0 +1,660 @@
/*
* Copyright (c) 2015 Christopher M. Baker
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
var should = require('should');
var wpa_cli = require('../wpa_cli');
var WPA_CLI_STATUS_SILENCE = '';
var WPA_CLI_STATUS_COMPLETED = [
'bssid=2c:f5:d3:02:ea:d9',
'freq=2412',
'ssid=Fake-Wifi',
'id=0',
'mode=station',
'pairwise_cipher=CCMP',
'group_cipher=CCMP',
'key_mgmt=WPA2-PSK',
'wpa_state=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'
].join('\n');
var WPA_CLI_STATUS_4WAY_HANDSHAKE = [
'bssid=2c:f5:d3:02:ea:d9',
'freq=2412',
'ssid=Fake-Wifi',
'id=0',
'mode=station',
'pairwise_cipher=CCMP',
'group_cipher=CCMP',
'key_mgmt=WPA2-PSK',
'wpa_state=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'
].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'
].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'
].join('\n');
var WPA_CLI_SCAN_NORESULTS = [
''
].join('\n');
var WPA_CLI_COMMAND_OK = 'OK\n';
var WPA_CLI_COMMAND_FAIL = 'FAIL\n';
var WPA_CLI_COMMAND_ID = '0\n';
describe('wpa_cli', function() {
describe('wpa_cli.status(iface, callback)', function() {
before(function() {
this.OUTPUT = '';
var self = this;
wpa_cli.exec = function(command, callback) {
should(command).eql('wpa_cli -i wlan0 status');
callback(null, self.OUTPUT);
};
});
it('status SILENCE', function (done) {
this.OUTPUT = WPA_CLI_STATUS_SILENCE;
wpa_cli.status('wlan0', function(err, status) {
should(status).eql({ });
done();
});
});
it('status COMPLETED', function(done) {
this.OUTPUT = WPA_CLI_STATUS_COMPLETED;
wpa_cli.status('wlan0', function(err, status) {
should(status).eql({
bssid: '2c:f5:d3:02:ea:d9',
frequency: 2412,
mode: 'station',
key_mgmt: 'wpa2-psk',
ssid: 'Fake-Wifi',
pairwise_cipher: 'CCMP',
group_cipher: 'CCMP',
p2p_device_address: 'e4:28:9c:a8:53:72',
wpa_state: 'COMPLETED',
ip: '10.34.141.168',
mac: 'e4:28:9c:a8:53:72',
uuid: 'e1cda789-8c88-53e8-ffff-31c304580c1e',
id: 0
});
done();
});
});
it('status 4WAY_HANDSHAKE', function(done) {
this.OUTPUT = WPA_CLI_STATUS_4WAY_HANDSHAKE;
wpa_cli.status('wlan0', function(err, status) {
should(status).eql({
bssid: '2c:f5:d3:02:ea:d9',
frequency: 2412,
mode: 'station',
key_mgmt: 'wpa2-psk',
ssid: 'Fake-Wifi',
pairwise_cipher: 'CCMP',
group_cipher: 'CCMP',
p2p_device_address: 'e4:28:9c:a8:53:72',
wpa_state: '4WAY_HANDSHAKE',
ip: '10.34.141.168',
mac: 'e4:28:9c:a8:53:72',
uuid: 'e1cda789-8c88-53e8-ffff-31c304580c1e',
id: 0
});
done();
});
});
it('status SCANNING', function(done) {
this.OUTPUT = WPA_CLI_STATUS_SCANNING;
wpa_cli.status('wlan0', function(err, status) {
should(status).eql({
p2p_device_address: 'e4:28:9c:a8:53:72',
wpa_state: 'SCANNING',
ip: '10.34.141.168',
mac: 'e4:28:9c:a8:53:72',
uuid: 'e1cda789-8c88-53e8-ffff-31c304580c1e' });
});
done();
});
it('should handle errors', function(done) {
wpa_cli.exec = function(command, callback) {
callback('error');
};
wpa_cli.status('wlan0', function(err, status) {
should(err).eql('error');
done();
});
});
});
describe('wpa_cli.bssid(iface, ap, ssid, callback)', function(){
it('OK result', function(done) {
wpa_cli.exec = function(command, callback) {
should(command).eql('wpa_cli -i wlan0 bssid Fake-Wifi 2c:f5:d3:02:ea:89');
callback(null, WPA_CLI_COMMAND_OK);
};
wpa_cli.bssid('wlan0', '2c:f5:d3:02:ea:89', 'Fake-Wifi', function(err, status) {
should(status).eql({
result: 'OK'
});
done();
});
});
it('FAIL result', function(done) {
wpa_cli.exec = function(command, callback) {
should(command).eql('wpa_cli -i wlan0 bssid 2c:f5:d3:02:ea:89 Fake-Wifi');
callback(null, WPA_CLI_COMMAND_FAIL);
};
wpa_cli.bssid('wlan0', 'Fake-Wifi', '2c:f5:d3:02:ea:89', function(err, status) {
should(err.message).eql('FAIL');
done();
});
});
it('Handle errors', function(done) {
wpa_cli.exec = function(command, callback) {
callback('error');
};
wpa_cli.bssid('wlan0', '2c:f5:d3:02:ea:89', 'Fake-Wifi', function(err, status) {
should(err).eql('error');
done();
});
});
});
describe('wpa_cli.reassociate(iface, callback)', function(){
it('OK result', function(done) {
wpa_cli.exec = function(command, callback) {
should(command).eql('wpa_cli -i wlan0 reassociate');
callback(null, WPA_CLI_COMMAND_OK);
};
wpa_cli.reassociate('wlan0', function(err, status) {
should(status).eql({
result: 'OK'
});
done();
});
});
it('FAIL result', function(done) {
wpa_cli.exec = function(command, callback) {
should(command).eql('wpa_cli -i wlan0 reassociate');
callback(null, WPA_CLI_COMMAND_FAIL);
};
wpa_cli.reassociate('wlan0', function(err, status) {
should(err.message).eql('FAIL');
done();
});
});
it('should handle errors', function(done) {
wpa_cli.exec = function(command, callback) {
callback('error');
};
wpa_cli.reassociate('wlan0', function(err, status) {
should(err).eql('error');
done();
});
});
});
describe('wpa_cli.set(iface, variable, value, callback)', function(){
it('OK result', function(done) {
wpa_cli.exec = function(command, callback) {
should(command).eql('wpa_cli -i wlan0 set ap_scan 1');
callback(null, WPA_CLI_COMMAND_OK);
};
wpa_cli.set('wlan0','ap_scan', 1, function(err, status) {
should(status).eql({
result: 'OK'
});
done();
});
});
it('FAIL result', function(done) {
wpa_cli.exec = function(command, callback) {
should(command).eql('wpa_cli -i wlan0 set ap_scan 1');
callback(null, WPA_CLI_COMMAND_FAIL);
};
wpa_cli.set('wlan0','ap_scan', 1, function(err, status) {
should(err.message).eql('FAIL');
done();
});
});
it('should handle errors', function(done) {
wpa_cli.exec = function(command, callback) {
callback('error');
};
wpa_cli.set('wlan0','ap_scan', 1, function(err, status) {
should(err).eql('error');
done();
});
});
});
describe('wpa_cli.add_network(iface, callback)', function(){
it('OK result', function(done) {
wpa_cli.exec = function(command, callback) {
should(command).eql('wpa_cli -i wlan0 add_network');
callback(null, WPA_CLI_COMMAND_ID);
};
wpa_cli.add_network('wlan0', function(err, status) {
should(status).eql({
result: '0'
});
done();
});
});
it('FAIL result', function(done) {
wpa_cli.exec = function(command, callback) {
should(command).eql('wpa_cli -i wlan0 add_network');
callback(null, WPA_CLI_COMMAND_FAIL);
};
wpa_cli.add_network('wlan0', function(err, status) {
should(err.message).eql('FAIL');
done();
});
});
it('should handle errors', function(done) {
wpa_cli.exec = function(command, callback) {
callback('error');
};
wpa_cli.add_network('wlan0', function(err, status) {
should(err).eql('error');
done();
});
});
});
describe('wpa_cli.set_network(iface, id, variable, value, callback)', function(){
it('OK result', function(done) {
wpa_cli.exec = function(command, callback) {
should(command).eql('wpa_cli -i wlan0 set_network 0 scan_ssid 1');
callback(null, WPA_CLI_COMMAND_OK);
};
wpa_cli.set_network('wlan0', 0, 'scan_ssid', 1, function(err, status) {
should(status).eql({
result: 'OK'
});
done();
});
});
it('FAIL result', function(done) {
wpa_cli.exec = function(command, callback) {
should(command).eql('wpa_cli -i wlan0 set_network 0 fake_variable 1');
callback(null, WPA_CLI_COMMAND_FAIL);
};
wpa_cli.set_network('wlan0', 0, 'fake_variable', 1, function(err, status) {
should(err.message).eql('FAIL');
done();
});
});
it('should handle errors', function(done) {
wpa_cli.exec = function(command, callback) {
callback('error');
};
wpa_cli.set_network('wlan0', 0, 'fake_variable', 1, function(err, status) {
should(err).eql('error');
done();
});
});
});
describe('wpa_cli.enable_network(iface, id, callback)', function(){
it('OK result', function(done) {
wpa_cli.exec = function(command, callback) {
should(command).eql('wpa_cli -i wlan0 enable_network 0');
callback(null, WPA_CLI_COMMAND_OK);
};
wpa_cli.enable_network('wlan0', 0, function(err, status) {
should(status).eql({
result: 'OK'
});
done();
});
});
it('FAIL result', function(done) {
wpa_cli.exec = function(command, callback) {
should(command).eql('wpa_cli -i wlan0 enable_network 28');
callback(null, WPA_CLI_COMMAND_FAIL);
};
wpa_cli.enable_network('wlan0', 28, function(err, status) {
should(err.message).eql('FAIL');
done();
});
});
it('should handle errors', function(done) {
wpa_cli.exec = function(command, callback) {
callback('error');
};
wpa_cli.enable_network('wlan0', 28, function(err, status) {
should(err).eql('error');
done();
});
});
});
describe('wpa_cli.disable_network(iface, id, callback)', function(){
it('OK result', function(done) {
wpa_cli.exec = function(command, callback) {
should(command).eql('wpa_cli -i wlan0 disable_network 0');
callback(null, WPA_CLI_COMMAND_OK);
};
wpa_cli.disable_network('wlan0', 0, function(err, status) {
should(status).eql({
result: 'OK'
});
done();
});
});
it('FAIL result', function(done) {
wpa_cli.exec = function(command, callback) {
should(command).eql('wpa_cli -i wlan0 disable_network 28');
callback(null, WPA_CLI_COMMAND_FAIL);
};
wpa_cli.disable_network('wlan0', 28, function(err, status) {
should(err.message).eql('FAIL');
done();
});
});
it('should handle errors', function(done) {
wpa_cli.exec = function(command, callback) {
callback('error');
};
wpa_cli.disable_network('wlan0', 28, function(err, status) {
should(err).eql('error');
done();
});
});
});
describe('wpa_cli.remove_network(iface, id, callback)', function(){
it('OK result', function(done) {
wpa_cli.exec = function(command, callback) {
should(command).eql('wpa_cli -i wlan0 remove_network 0');
callback(null, WPA_CLI_COMMAND_OK);
};
wpa_cli.remove_network('wlan0', 0, function(err, status) {
should(status).eql({
result: 'OK'
});
done();
});
});
it('FAIL result', function(done) {
wpa_cli.exec = function(command, callback) {
should(command).eql('wpa_cli -i wlan0 remove_network 28');
callback(null, WPA_CLI_COMMAND_FAIL);
};
wpa_cli.remove_network('wlan0', 28, function(err, status) {
should(err.message).eql('FAIL');
done();
});
});
it('should handle errors', function(done) {
wpa_cli.exec = function(command, callback) {
callback('error');
};
wpa_cli.remove_network('wlan0', 28, function(err, status) {
should(err).eql('error');
done();
});
});
});
describe('wpa_cli.select_network(iface, id, callback)', function(){
it('OK result', function(done) {
wpa_cli.exec = function(command, callback) {
should(command).eql('wpa_cli -i wlan0 select_network 0');
callback(null, WPA_CLI_COMMAND_OK);
};
wpa_cli.select_network('wlan0', 0, function(err, status) {
should(status).eql({
result: 'OK'
});
done();
});
});
it('FAIL result', function(done) {
wpa_cli.exec = function(command, callback) {
should(command).eql('wpa_cli -i wlan0 select_network 28');
callback(null, WPA_CLI_COMMAND_FAIL);
};
wpa_cli.select_network('wlan0', 28, function(err, status) {
should(err.message).eql('FAIL');
done();
});
});
it('should handle errors', function(done) {
wpa_cli.exec = function(command, callback) {
callback('error');
};
wpa_cli.select_network('wlan0', 28, function(err, status) {
should(err).eql('error');
done();
});
});
});
describe('wpa_cli.scan(iface, callback)', function(){
it('OK result', function(done) {
wpa_cli.exec = function(command, callback) {
should(command).eql('wpa_cli -i wlan0 scan');
callback(null, WPA_CLI_COMMAND_OK);
};
wpa_cli.scan('wlan0', function(err, scan) {
should(scan).eql({
result: 'OK'
});
done();
});
});
it('should handle errors', function(done) {
wpa_cli.exec = function(command, callback) {
callback('error');
};
wpa_cli.scan('wlan0', function(err, scan) {
should(err).eql('error');
done();
});
});
});
describe('wpa_cli.scan_results(iface, callback)', function(){
before(function() {
this.OUTPUT = '';
var self = this;
wpa_cli.exec = function(command, callback) {
should(command).eql('wpa_cli -i wlan0 scan_results');
callback(null, self.OUTPUT);
};
});
it('scan_results NORESULTS', function (done) {
this.OUTPUT = WPA_CLI_SCAN_NORESULTS;
wpa_cli.scan_results('wlan0', function(err, results) {
should(results).eql([]);
done();
});
});
it('scan_results COMPLETED', function(done) {
this.OUTPUT = WPA_CLI_SCAN_RESULTS;
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'
}
]);
done();
});
});
it('should handle errors', function(done) {
wpa_cli.exec = function(command, callback) {
callback('error');
};
wpa_cli.scan_results('wlan0', function(err, results) {
should(err).eql('error');
done();
});
});
});
describe('wpa_cli.save_config(iface, callback)', function(){
it('OK result', function(done) {
wpa_cli.exec = function(command, callback) {
should(command).eql('wpa_cli -i wlan0 save_config');
callback(null, WPA_CLI_COMMAND_OK);
};
wpa_cli.save_config('wlan0', function(err, status) {
should(status).eql({
result: 'OK'
});
done();
});
});
it('FAIL result', function(done) {
wpa_cli.exec = function(command, callback) {
should(command).eql('wpa_cli -i wlan0 save_config');
callback(null, WPA_CLI_COMMAND_FAIL);
};
wpa_cli.save_config('wlan0', function(err, status) {
should(err.message).eql('FAIL');
done();
});
});
it('should handle errors', function(done) {
wpa_cli.exec = function(command, callback) {
callback('error');
};
wpa_cli.scan('wlan0', function(err, status) {
should(err).eql('error');
done();
});
});
});
});

View File

@ -0,0 +1,136 @@
/*
* Copyright (c) 2015 Christopher M. Baker
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
var should = require('should');
var wpa_supplicant = require('../wpa_supplicant');
describe('wpa_supplicant', function() {
describe('wpa_supplicant.disable(options, callback)', function() {
it('should stop the daemons', function(done) {
wpa_supplicant.exec = function(command, callback) {
should(command).eql(
'kill `pgrep -f "wpa_supplicant -i wlan0 .*"` || true');
callback(null, '', '');
};
wpa_supplicant.disable('wlan0', function(err) {
should(err).not.be.ok;
done();
});
})
it('should handle errors', function(done) {
wpa_supplicant.exec = function(command, callback) {
callback('error');
};
wpa_supplicant.disable('wlan0', function(err) {
should(err).eql('error');
done();
});
})
})
describe('wpa_supplicant.enable(options, callback)', function() {
it('should start the daemon', function(done) {
wpa_supplicant.exec = function(command, callback) {
should(command).eql('wpa_passphrase "RaspberryPi" "raspberry"' +
' > wlan0-wpa_supplicant.conf &&' +
' wpa_supplicant -i wlan0 -B -D wext -c wlan0-wpa_supplicant.conf' +
' && rm -f wlan0-wpa_supplicant.conf');
callback(null, '', '');
};
var options = {
interface: 'wlan0',
ssid: 'RaspberryPi',
passphrase: 'raspberry',
driver: 'wext'
};
wpa_supplicant.enable(options, function(err) {
should(err).not.be.ok;
done();
});
})
it('should handle errors', function(done) {
wpa_supplicant.exec = function(command, callback) {
callback('error');
};
var options = {
interface: 'wlan0',
ssid: 'RaspberryPi',
passphrase: 'raspberry',
driver: 'wext'
};
wpa_supplicant.enable(options, function(err) {
should(err).eql('error');
done();
});
})
})
describe('wpa_supplicant.manual(options, callback)', function() {
it('should start the daemon', function(done) {
wpa_supplicant.exec = function(command, callback) {
should(command).eql([
'wpa_supplicant -i wlan0 -s -B -P /run/wpa_supplicant/wlan0.pid',
'-D nl80211,wext -C /run/wpa_supplicant'
].join(' '));
callback(null, '', '');
};
var options = {
interface: 'wlan0',
drivers: [ 'nl80211', 'wext' ]
};
wpa_supplicant.manual(options, function(err) {
should(err).not.be.ok;
done();
});
})
it('should handle errors', function(done) {
wpa_supplicant.exec = function(command, callback) {
callback('error');
};
var options = {
interface: 'wlan0',
drivers: [ 'nl80211', 'wext' ]
};
wpa_supplicant.manual(options, function(err) {
should(err).eql('error');
done();
});
})
})
})