2626import testhelper as testhelper
2727
2828class IntegrationTests :
29- def __init__ (self , installation_type = "normal" ):
29+ def __init__ (self , installation_type = "normal" , test_type = "install" ):
3030 self .testhelper = testhelper .TestHelper ()
3131 self .installation_type = installation_type
32+ self .test_type = test_type
3233 self .result = True
3334 self .result &= self .test_version ()
3435 self .result &= self .test_files_exist ()
@@ -39,6 +40,10 @@ def __init__(self, installation_type="normal"):
3940 self .result &= self .test_service_groups_and_memberships ()
4041 if self .installation_type == "test_acct_mgr_login" :
4142 self .result &= self .test_acct_mgr_login ()
43+ if self .installation_type == "test_client_auth_file" :
44+ self .result &= self .test_client_auth_file ()
45+ if self .test_type == "install" :
46+ self .result &= self .test_boinc_master_user_only_exists ()
4247
4348 def _get_test_executable_file_path (self , filename ):
4449 return pathlib .Path ("C:\\ Program Files\\ BOINC\\ " ) / filename
@@ -146,6 +151,12 @@ def test_service_users_exist(self):
146151 ts .expect_true (self ._check_user_exists ("boinc_project" ), "Test 'boinc_project' user exists" )
147152 return ts .result ()
148153
154+ def test_boinc_master_user_only_exists (self ):
155+ ts = testset .TestSet ("Test 'boinc_master' user only exists" )
156+ ts .expect_true (self ._check_user_exists ("boinc_master" ), "Test 'boinc_master' user exists" )
157+ ts .expect_false (self ._check_user_exists ("boinc_project" ), "Test 'boinc_project' user does not exist" )
158+ return ts .result ()
159+
149160 def test_service_groups_and_memberships (self ):
150161 ts = testset .TestSet ("Test BOINC service groups and memberships" )
151162 ts .expect_true (self ._check_group_exists ("boinc_admins" ), "Test 'boinc_admins' group exists" )
@@ -186,16 +197,57 @@ def test_acct_mgr_login(self):
186197
187198 return ts .result ()
188199
200+ def test_client_auth_file (self ):
201+ ts = testset .TestSet ("Test client auth file" )
202+ client_auth_file = self ._get_test_data_file_path ("client_auth.xml" )
203+ ts .expect_true (os .path .exists (client_auth_file ), "Test 'client_auth.xml' file exists in 'C:\\ ProgramData\\ BOINC\\ '" )
204+
205+ if os .path .exists (client_auth_file ):
206+ try :
207+ tree = ET .parse (client_auth_file )
208+ root = tree .getroot ()
209+
210+ ts .expect_equal ("client_authorization" , root .tag , "Test root element is 'client_authorization'" )
211+
212+ boinc_project_element = root .find ("boinc_project" )
213+ ts .expect_true (boinc_project_element is not None , "Test 'boinc_project' element exists" )
214+
215+ if boinc_project_element is not None :
216+ username_element = boinc_project_element .find ("username" )
217+ password_element = boinc_project_element .find ("password" )
218+
219+ ts .expect_true (username_element is not None , "Test 'username' element exists" )
220+ ts .expect_true (password_element is not None , "Test 'password' element exists" )
221+
222+ if username_element is not None :
223+ ts .expect_equal ("test_user" , username_element .text , "Test 'username' element contains 'test_user'" )
224+
225+ if password_element is not None :
226+ ts .expect_equal ("cXdlcnR5MTIzNDU2IUAjJCVe" , password_element .text .strip (), "Test 'password' element contains 'cXdlcnR5MTIzNDU2IUAjJCVe'" )
227+
228+ except ET .ParseError as e :
229+ ts .expect_true (False , f"Test XML file is well-formed (Parse error: { e } )" )
230+ except Exception as e :
231+ ts .expect_true (False , f"Test XML file can be processed (Error: { e } )" )
232+
233+ return ts .result ()
234+
189235if __name__ == "__main__" :
190236 parser = argparse .ArgumentParser (description = "BOINC Windows Installer Integration Tests" )
191237 parser .add_argument (
192238 "--installation-type" ,
193239 type = str ,
194240 default = "normal" ,
195- help = "Installation type (normal or service), default is 'normal'"
241+ help = "Installation type: 'normal' (default), 'service', 'test_acct_mgr_login', or 'test_client_auth_file'"
242+ )
243+ parser .add_argument (
244+ "--type" ,
245+ type = str ,
246+ default = "install" ,
247+ help = "Test type: 'install' (default) or 'upgrade_from_alpha' or 'upgrade_from_stable'"
196248 )
197249 args = parser .parse_args ()
198250
199- if not IntegrationTests (installation_type = args .installation_type ).result :
251+ if not IntegrationTests (installation_type = args .installation_type , test_type = args . type ).result :
200252 sys .exit (1 )
201253 sys .exit (0 )
0 commit comments