Example #1
0
 async def GET(self) -> IdentityData:
     data = IdentityData()
     if self.model.user is not None:
         data.username = self.model.user.username
         data.realname = self.model.user.realname
     if self.model.hostname:
         data.hostname = self.model.hostname
     return data
Example #2
0
 def make_ui(self):
     data = IdentityData()
     if self.model.user is not None:
         data.username = self.model.user.username
         data.realname = self.model.user.realname
     if self.model.hostname:
         data.hostname = self.model.hostname
     return IdentityView(self, data)
Example #3
0
 def done(self, result):
     self.controller.done(
         IdentityData(
             hostname=self.form.hostname.value,
             realname=self.form.realname.value,
             username=self.form.username.value,
             crypted_password=crypt_password(self.form.password.value),
         ))
Example #4
0
 def run_answers(self):
     if all(elem in self.answers
            for elem in ['realname', 'username', 'password', 'hostname']):
         identity = IdentityData(realname=self.answers['realname'],
                                 username=self.answers['username'],
                                 hostname=self.answers['hostname'],
                                 crypted_password=self.answers['password'])
         self.done(identity)
Example #5
0
 def load_autoinstall_data(self, data):
     if data is not None:
         identity_data = IdentityData(
             realname=data.get('realname', ''),
             username=data['username'],
             hostname=data['hostname'],
             crypted_password=data['password'],
             )
         self.model.add_user(identity_data)
Example #6
0
 def test_click_done(self):
     view = self.make_view()
     CRYPTED = '<crypted>'
     with mock.patch('subiquity.ui.views.identity.crypt_password') as cp:
         cp.side_effect = lambda p: CRYPTED
         view_helpers.enter_data(view.form, valid_data)
         done_btn = view_helpers.find_button_matching(view, "^Done$")
         view_helpers.click(done_btn)
     expected = IdentityData(realname=valid_data['realname'],
                             username=valid_data['username'],
                             hostname=valid_data['hostname'],
                             crypted_password=CRYPTED)
     view.controller.done.assert_called_once_with(expected)
Example #7
0
 def make_view(self):
     controller = mock.create_autospec(spec=IdentityController)
     controller.signal = mock.create_autospec(spec=Signal)
     return IdentityView(controller, IdentityData())