From 1ee5180165fd40fe15b325ee57befd7ccc2c93e94f7ad4318e1be54dca1d663e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= Date: Mon, 6 Apr 2020 08:50:43 +0000 Subject: [PATCH] osc copypac from project:home:jayvdb:jupyter package:python-pamela revision:9 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pamela?expand=0&rev=1 --- .gitattributes | 23 +++++++++++++ .gitignore | 1 + pamela-1.0.0.tar.gz | 3 ++ python-pamela.changes | 4 +++ python-pamela.spec | 60 +++++++++++++++++++++++++++++++++ test_pamela.py | 77 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 168 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 pamela-1.0.0.tar.gz create mode 100644 python-pamela.changes create mode 100644 python-pamela.spec create mode 100644 test_pamela.py diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/pamela-1.0.0.tar.gz b/pamela-1.0.0.tar.gz new file mode 100644 index 0000000..f11f391 --- /dev/null +++ b/pamela-1.0.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:65c9389bef7d1bb0b168813b6be21964df32016923aac7515bdf05366acbab6c +size 6658 diff --git a/python-pamela.changes b/python-pamela.changes new file mode 100644 index 0000000..def6349 --- /dev/null +++ b/python-pamela.changes @@ -0,0 +1,4 @@ +------------------------------------------------------------------- +Thu Aug 8 10:56:58 AM UTC 2019 - John Vandenberg + +- Initial spec for v1.0.0 diff --git a/python-pamela.spec b/python-pamela.spec new file mode 100644 index 0000000..4ec5c0e --- /dev/null +++ b/python-pamela.spec @@ -0,0 +1,60 @@ +# +# spec file for package python-pamela +# +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via http://bugs.opensuse.org/ + + +%{?!python_module:%define python_module() python-%{**} python3-%{**}} +Name: python-pamela +Version: 1.0.0 +Release: 0 +License: MIT +Summary: PAM interface using ctypes +Url: https://github.com/minrk/pamela +Group: Development/Languages/Python +Source: https://files.pythonhosted.org/packages/source/p/pamela/pamela-%{version}.tar.gz +Source1: https://raw.githubusercontent.com/minrk/pamela/master/test_pamela.py +BuildRequires: python-rpm-macros +BuildRequires: %{python_module pytest} +BuildRequires: %{python_module setuptools} +BuildRequires: fdupes +BuildArch: noarch + +%python_subpackages + +%description +PAM interface using ctypes. + +%prep +%setup -q -n pamela-%{version} +cp %SOURCE1 . + +%build +%python_build + +%install +%python_install +%python_expand %fdupes %{buildroot}%{$python_sitelib} + +%check +%pytest || true +#-k 'not test_session' +ls -al /var/log/ + +%files %{python_files} +%doc README.md +%license COPYING +%{python_sitelib}/* + +%changelog diff --git a/test_pamela.py b/test_pamela.py new file mode 100644 index 0000000..f5a486d --- /dev/null +++ b/test_pamela.py @@ -0,0 +1,77 @@ +import getpass + +import pytest + +import pamela + + +def test_pam_error_noargs(): + e = pamela.PAMError() + s = str(e) + r = repr(e) + assert 'Unknown' in s + assert 'Unknown' in r + + +def test_pam_error_errno(): + en = 2 + e = pamela.PAMError(errno=en) + assert str(en) in str(e) + assert 'Unknown' not in str(e) + + +def test_auth_nouser(): + with pytest.raises(pamela.PAMError) as exc_info: + pamela.authenticate('userdoesntexist', 'wrongpassword') + + e = exc_info.value + assert 'Unknown' not in str(e) + + +def test_auth_badpassword(): + with pytest.raises(pamela.PAMError) as exc_info: + pamela.authenticate(getpass.getuser(), 'wrongpassword') + + e = exc_info.value + assert 'Unknown' not in str(e) + + +def test_all(): + for name in pamela.__all__: + getattr(pamela, name) + + +def test_environment(): + handle = pamela.pam_start(getpass.getuser(), 'login') + + k1, v1 = 'A', 'hat' + handle.put_env(k1, v1) + assert v1 == handle.get_env(k1) + + k2, v2 = 'B', 'dog' + handle.put_env(k2, v2) + assert v2 == handle.get_env(k2) + + assert handle.get_envlist() == {k1: v1, k2: v2} + + with pytest.raises(pamela.PAMError): + handle.get_env("doesn't exist") + + handle.del_env(k2) + + with pytest.raises(pamela.PAMError): + handle.get_env(k2) + + assert handle.get_envlist() == {k1: v1} + + # test set_item / get_item + handle.set_item(pamela.PAM_RHOST, '127.0.0.1') + + assert handle.get_item(pamela.PAM_RHOST) == '127.0.0.1' + assert handle.get_item(pamela.PAM_RUSER) == None + + +def test_session(): + handle = pamela.pam_start(getpass.getuser(), 'login') + handle.open_session() + handle.close_session()