@@ -55,8 +55,21 @@ function TestUpdateConfig.test_update()
5555 local networkFile = io.open (config_dir .. ' network' )
5656 luaunit .assertNotNil (networkFile )
5757 local networkContents = networkFile :read (' *all' )
58+ -- ensure interface added is present
5859 luaunit .assertNotNil (string.find (networkContents , " config interface 'added'" ))
5960 luaunit .assertNotNil (string.find (networkContents , " option ifname 'added0'" ))
61+ -- ensure wg1 added via remote previously is present
62+ luaunit .assertNotNil (string.find (networkContents , " config interface 'wg1'" ))
63+ luaunit .assertNotNil (string.find (networkContents , " option proto 'static'" ))
64+ -- ensure network file is stored for backup
65+ local storedNetworkFile = io.open (stored_dir .. ' /etc/config/network' )
66+ luaunit .assertNotNil (storedNetworkFile )
67+ local storedNetworkContents = storedNetworkFile :read (' *all' )
68+ -- ensure wg1 is not added that is downloaded from remote
69+ luaunit .assertNil (string.find (storedNetworkContents , " config interface 'wg1'" ))
70+ -- ensure wan and wg0 are present
71+ luaunit .assertNotNil (string.find (storedNetworkContents , " config interface 'wan'" ))
72+ luaunit .assertNotNil (string.find (storedNetworkContents , " config interface 'wg0'" ))
6073 -- check system
6174 local systemFile = io.open (config_dir .. ' system' )
6275 luaunit .assertNotNil (systemFile )
@@ -69,6 +82,16 @@ function TestUpdateConfig.test_update()
6982 -- ensure rest of config options are present
7083 luaunit .assertNotNil (string.find (systemContents , " config timeserver 'ntp'" ))
7184 luaunit .assertNotNil (string.find (systemContents , " list server '3.openwrt.pool.ntp.org'" ))
85+ -- ensure system file is stored for backup
86+ local storedSystemFile = io.open (stored_dir .. ' /etc/config/network' )
87+ luaunit .assertNotNil (storedSystemFile )
88+ local storedSystemContents = storedSystemFile :read (' *all' )
89+ -- ensure hostname is not added that is updated from remote
90+ luaunit .assertNil (string.find (storedSystemContents , " option hostname" ))
91+ -- ensure custom is not added that is downloaded from remote
92+ luaunit .assertNil (string.find (storedSystemContents , " option custom 'custom'" ))
93+ -- ensure new is not added that is downloaded from remote
94+ luaunit .assertNil (string.find (storedSystemContents , " config new 'new'" ))
7295 -- ensure test file is present
7396 local testFile = io.open (write_dir .. ' etc/test' )
7497 luaunit .assertNotNil (testFile )
@@ -109,7 +132,7 @@ function TestUpdateConfig.test_update()
109132 local modifiedListFile = io.open (openwisp_dir .. ' /modified.list' )
110133 luaunit .assertNotNil (modifiedListFile )
111134 luaunit .assertEquals (modifiedListFile :read (' *all' ), ' /etc/existing\n ' )
112- local storedExisitngFile = io.open (openwisp_dir .. ' /stored /etc/existing' )
135+ local storedExisitngFile = io.open (stored_dir .. ' /etc/existing' )
113136 luaunit .assertNotNil (storedExisitngFile )
114137 luaunit .assertEquals (storedExisitngFile :read (' *all' ), ' original\n ' )
115138 -- ensure it has been modified
@@ -122,12 +145,7 @@ function TestUpdateConfig.test_update()
122145 local restoreFile = io.open (write_dir .. ' /etc/restore-me' )
123146 luaunit .assertNotNil (restoreFile )
124147 luaunit .assertEquals (restoreFile :read (' *all' ), ' restore-me\n ' )
125- luaunit .assertNil (io.open (openwisp_dir .. ' /stored/etc/restore-me' ))
126- -- ensure network and configuration file is not backed up as it is overwritten by remote
127- local storedNetworkFile = io.open (openwisp_dir .. ' /etc/config/network' )
128- luaunit .assertNil (storedNetworkFile )
129- local storedSystemFile = io.open (openwisp_dir .. ' /etc/config/system' )
130- luaunit .assertNil (storedSystemFile )
148+ luaunit .assertNil (io.open (stored_dir .. ' /etc/restore-me' ))
131149end
132150
133151function TestUpdateConfig .test_update_conf_arg ()
0 commit comments