def form_valid(self, form): create_ssh_config( name=form.cleaned_data.get('name'), private_key_text=form.cleaned_data.get('private_key'), public_key_text=form.cleaned_data.get('public_key'), remote_user=form.cleaned_data.get('remote_user'), ) return super(SSHKeysCreate, self).form_valid(form)
def post(self, *args, **kwargs): """Create the SSH file & then return the normal get method...""" existing_ssh = models.SSHConfig.objects.all() if existing_ssh.exists(): return self.get_view() remote_user = self.request.POST.get('remote_user', 'root') create_ssh_config(remote_user=remote_user) return self.get_view()
def test_create_ssh_config(self): ssh_config = create_ssh_config(remote_user='******') self.assertEquals('test_user', ssh_config.remote_user)
def _create_ssh_config(self): self.ssh_config = create_ssh_config()