def test_create_and_delete_key(self, mocked_task): # Create SSH key ssh_key = structure_factories.SshPublicKeyFactory(user=self.owner) self.assert_task_called(mocked_task, 'nodeconductor.structure.push_ssh_public_key', ssh_key.uuid.hex) # Delete SSH key self.client.force_authenticate(self.owner) self.client.delete( structure_factories.SshPublicKeyFactory.get_url(ssh_key)) self.assert_task_called( mocked_task, 'nodeconductor.structure.remove_ssh_public_key', serialize_ssh_key(ssh_key))
def test_grant_and_revoke_user_from_project(self, mocked_task): user = structure_factories.UserFactory() ssh_key = structure_factories.SshPublicKeyFactory(user=user) # Grant user in project self.project.add_user(user, ProjectRole.ADMINISTRATOR) self.assert_task_called(mocked_task, 'nodeconductor.structure.push_ssh_public_key', ssh_key.uuid.hex) self.assert_task_called(mocked_task, 'nodeconductor.structure.add_user', user.uuid.hex) # Revoke user in project self.project.remove_user(user) self.assert_task_called( mocked_task, 'nodeconductor.structure.remove_ssh_public_key', serialize_ssh_key(ssh_key)) self.assert_task_called(mocked_task, 'nodeconductor.structure.remove_user', serialize_user(user))
def remove_key(self, key): send_task('structure', 'remove_ssh_public_key')(serialize_ssh_key(key), self.link)
def test_remove_ssh_public_key_skips_if_link_is_gone(self, mock_backend): self.link.delete() structure_tasks.remove_ssh_public_key(serialize_ssh_key(self.ssh_key), self.link_str) self.assertFalse(mock_backend().remove_ssh_key.called)
def test_remove_ssh_public_key_calls_backend(self, mock_backend): structure_tasks.remove_ssh_public_key(serialize_ssh_key(self.ssh_key), self.link_str) self.assertTrue(mock_backend().remove_ssh_key.called)