@@ -53,16 +53,20 @@ def setUp(self):
5353 )
5454 self .conn .chunk_size = 3
5555
56- self .remote_user = self ._setUpServer ()
56+ self .remote_user , self . root_cert_id = self ._setUpServer ()
5757 self .filter = Filter ("{}:user" .format (self .remote_user .id ))
58- self .client = self ._setUpClient (self .remote_user . id )
58+ self .client = self ._setUpClient (self .root_cert_id )
5959 self .session = self .client .sync_session
6060 self .last_session_activity = self .session .last_activity_timestamp
6161 self .last_transfer_activity = None
6262
63- self .local_user = MyUser .objects .create (
64- id = self .remote_user .id , username = "bob" , is_superuser = True
65- )
63+ # perform an initial sync to ensure the user is on both sides
64+ client = self .client .get_pull_client ()
65+ client .initialize (self .filter )
66+ client .run ()
67+ client .finalize ()
68+
69+ self .local_user = MyUser .objects .first ()
6670
6771 def _setUpCertScopes (self ):
6872 root_scope = ScopeDefinition .objects .create (
@@ -90,37 +94,37 @@ def _setUpCertScopes(self):
9094
9195 def _setUpServer (self ):
9296 with second_environment ():
93- root_scope , subset_scope = self ._setUpCertScopes ()
94- root_cert = Certificate .generate_root_certificate (root_scope .id )
97+ self . server_root_scope , self . server_subset_scope = self ._setUpCertScopes ()
98+ root_cert = Certificate .generate_root_certificate (self . server_root_scope .id )
9599
96100 remote_user = MyUser .objects .create (
97- id = root_cert .id , username = "bob" , is_superuser = True
101+ _morango_source_id = root_cert .id , username = "bob" , is_superuser = True
98102 )
99103 remote_user .set_password ("password" )
100104 remote_user .save ()
101105
102106 subset_cert = Certificate (
103107 parent = root_cert ,
104108 profile = self .profile ,
105- scope_definition = subset_scope ,
106- scope_version = subset_scope .version ,
109+ scope_definition = self . server_subset_scope ,
110+ scope_version = self . server_subset_scope .version ,
107111 scope_params = json .dumps ({"user" : remote_user .id , "sub" : "user" }),
108112 private_key = Key (),
109113 )
110114 root_cert .sign_certificate (subset_cert )
111115 subset_cert .save ()
112- return remote_user
116+ return remote_user , root_cert . id
113117
114118 def _setUpClient (self , primary_partition ):
115- root_scope , subset_scope = self ._setUpCertScopes ()
119+ self . client_root_scope , self . client_subset_scope = self ._setUpCertScopes ()
116120
117121 server_certs = self .conn .get_remote_certificates (
118- primary_partition , root_scope .id
122+ primary_partition , self . client_root_scope .id
119123 )
120124 server_cert = server_certs [0 ]
121125 client_cert = self .conn .certificate_signing_request (
122126 server_cert ,
123- subset_scope .id ,
127+ self . client_subset_scope .id ,
124128 {"user" : primary_partition , "sub" : "user" },
125129 userargs = "bob" ,
126130 password = "password" ,
0 commit comments