@@ -4,15 +4,14 @@ import { chai } from 'meteor/practicalmeteor:chai';
4
4
var assert = chai . assert ,
5
5
expect = chai . expect ;
6
6
7
- const CorrectTable = 'IP address HW type Flags HW address Mask Device\r\n192.168.1.11 0x1 0x2 8c:3a:e3:93:83:93 * br0\r\n192.168.1.50 0x1 0x2 00:26:bb:07:54:80 * br0\r\n192.168.1.18 0x1 0x2 3c:15:c2:cc:dc:2a * br0' ;
8
-
7
+ const ThreeEntries = 'IP address HW type Flags HW address Mask Device\r\n192.168.1.11 0x1 0x2 8c:3a:e3:93:83:93 * br0\r\n192.168.1.50 0x1 0x2 00:26:bb:07:54:80 * br0\r\n192.168.1.18 0x1 0x2 3c:15:c2:cc:dc:2a * br0' ;
8
+ const TwoEntries = 'IP address HW type Flags HW address Mask Device\r\n192.168.1.11 0x1 0x2 8c:3a:e3:93:83:93 * br0\r\n192.168.1.50 0x1 0x2 00:26:bb:07:54:80 * br0' ;
9
9
describe ( 'API' , function ( ) {
10
10
11
11
it ( 'accepts correct call' , function ( ) {
12
12
HTTP . call (
13
13
'POST' ,
14
- Meteor . absoluteUrl ( ) + 'routerapi/v1/arp/candra' ,
15
- { headers : { 'Authorization' : 'Bearer abcd' } , data : { arpTable : CorrectTable } } ,
14
+ Meteor . absoluteUrl ( ) + 'routerapi/v1/arp/candra' , { headers : { 'Authorization' : 'Bearer abcd' } , data : { arpTable : ThreeEntries } } ,
16
15
function ( error , result ) {
17
16
assert ( ! error , 'there was an error: \n' + error ) ;
18
17
assert ( result . statusCode == 200 , 'Status code didn\'t match 200 it was ' + result . statusCode ) ;
@@ -77,4 +76,26 @@ describe('API', function() {
77
76
done ( ) ;
78
77
} ) ;
79
78
} ) ;
79
+
80
+ it ( 'removes old MAC addresses' , function ( ) {
81
+ var entriesBefore ;
82
+ HTTP . call (
83
+ 'POST' ,
84
+ Meteor . absoluteUrl ( ) + 'routerapi/v1/arp/candra' , { headers : { 'Authorization' : 'Bearer abcd' } , data : { arpTable : ThreeEntries } } ,
85
+ function ( error , result ) {
86
+ assert ( ! error , 'there was an error: \n' + error ) ;
87
+ assert ( result . statusCode == 200 , 'Status code didn\'t match 200 it was ' + result . statusCode ) ;
88
+ entriesBefore = App . Collections . ARPEntries . find ( ) . count ( ) ;
89
+ }
90
+ ) ;
91
+ HTTP . call (
92
+ 'POST' ,
93
+ Meteor . absoluteUrl ( ) + 'routerapi/v1/arp/candra' , { headers : { 'Authorization' : 'Bearer abcd' } , data : { arpTable : TwoEntries } } ,
94
+ function ( error , result ) {
95
+ assert ( ! error , 'there was an error: \n' + error ) ;
96
+ assert ( result . statusCode == 200 , 'Status code didn\'t match 200 it was ' + result . statusCode ) ;
97
+ assert ( App . Collections . ARPEntries . find ( ) . count ( ) == entriesBefore - 1 , 'An entry was not removed correctly' ) ;
98
+ }
99
+ ) ;
100
+ } ) ;
80
101
} ) ;
0 commit comments