feat(web02): Switch to nix-pkgs for python modules

This commit is contained in:
Tom Hubrecht 2024-07-07 13:56:10 +02:00
parent 61b2408564
commit adf62b0534
7 changed files with 30 additions and 269 deletions

View file

@ -11,7 +11,21 @@ let
port = 9889;
python3 = pkgs.python312.override {
packageOverrides = _: _: {
inherit
(import sources.nix-pkgs {
inherit pkgs;
python3 = pkgs.python312;
})
django-browser-reload
django-bulma-forms
django-cas-server
loadcredential
;
};
};
pythonEnv = python3.withPackages (ps: [
ps.django
ps.ldap3
@ -19,10 +33,10 @@ let
ps.psycopg
# Local packages
(ps.callPackage ./packages/django-browser-reload { })
(ps.callPackage ./packages/django-bulma-forms { })
(ps.callPackage ./packages/django-cas-server { })
(ps.callPackage ./packages/loadcredential { })
ps.django-browser-reload
ps.django-bulma-forms
ps.django-cas-server
ps.loadcredential
]);
staticDrv = pkgs.stdenv.mkDerivation {

View file

@ -1,42 +0,0 @@
{
lib,
buildPythonPackage,
fetchFromGitHub,
setuptools,
wheel,
asgiref,
django,
}:
buildPythonPackage rec {
pname = "django-browser-reload";
version = "1.12.1";
pyproject = true;
src = fetchFromGitHub {
owner = "adamchainz";
repo = "django-browser-reload";
rev = version;
hash = "sha256-IDIkAl6YYI3isDvpzCtAu4fLSr2gbjEvVW+K1WBDPbo=";
};
nativeBuildInputs = [
setuptools
wheel
];
propagatedBuildInputs = [
asgiref
django
];
pythonImportsCheck = [ "django_browser_reload" ];
meta = with lib; {
description = "Automatically reload your browser in development";
homepage = "https://github.com/adamchainz/django-browser-reload";
changelog = "https://github.com/adamchainz/django-browser-reload/blob/${src.rev}/CHANGELOG.rst";
license = licenses.mit;
maintainers = [ ]; # with maintainers; [ thubrecht ];
};
}

View file

@ -1,36 +0,0 @@
{
lib,
buildPythonPackage,
fetchgit,
setuptools,
setuptools-scm,
wheel,
django,
}:
buildPythonPackage rec {
pname = "django-bulma-forms";
version = "0.1.4";
pyproject = true;
src = fetchgit {
url = "https://git.hubrecht.ovh/hubrecht/django-bulma-forms";
rev = "v${version}";
hash = "sha256-4KTMXx3YxDxB4/YH14pJnNYtpOGXeDmD+gcbrUHwD/w=";
};
nativeBuildInputs = [
setuptools
setuptools-scm
wheel
];
propagatedBuildInputs = [ django ];
meta = with lib; {
description = "";
homepage = "https://git.hubrecht.ovh/hubrecht/django-bulma-forms";
license = licenses.eupl12;
maintainers = [ ]; # with maintainers; [ thubrecht ];
};
}

View file

@ -1,88 +0,0 @@
diff --git a/cas_server/tests/test_federate.py b/cas_server/tests/test_federate.py
index 2b389d3..dcdfafd 100644
--- a/cas_server/tests/test_federate.py
+++ b/cas_server/tests/test_federate.py
@@ -16,6 +16,7 @@ from cas_server.default_settings import settings
import django
from django.test import TestCase, Client
from django.test.utils import override_settings
+import pytest
from six.moves import reload_module
@@ -64,6 +65,7 @@ class FederateAuthLoginLogoutTestCase(
) in response.content.decode("utf-8"))
self.assertEqual(response.context['post_url'], '/federate')
+ @pytest.mark.skip(reason="Address already in use")
def test_login_post_provider(self, remember=False):
"""test a successful login wrokflow"""
tickets = []
@@ -159,6 +161,7 @@ class FederateAuthLoginLogoutTestCase(
self.assertTrue(response["Location"].startswith("%s?ticket=" % self.service))
return tickets
+ @pytest.mark.skip(reason="Address already in use")
def test_login_twice(self):
"""Test that user id db is used for the second login (cf coverage)"""
self.test_login_post_provider()
@@ -253,6 +256,7 @@ class FederateAuthLoginLogoutTestCase(
self.assertEqual(response.status_code, 200)
self.assertIn(b"Invalid response from your identity provider CAS", response.content)
+ @pytest.mark.skip(reason="Address already in use")
def test_auth_federate_slo(self):
"""test that SLO receive from backend CAS log out the users"""
# get tickets and connected clients
@@ -301,6 +305,7 @@ class FederateAuthLoginLogoutTestCase(
client, response, username=provider.build_username(settings.CAS_TEST_USER)
)
+ @pytest.mark.skip(reason="Address already in use")
def test_federate_logout(self):
"""
test the logout function: the user should be log out
@@ -340,6 +345,7 @@ class FederateAuthLoginLogoutTestCase(
response = client.get("/login")
self.assert_login_failed(client, response)
+ @pytest.mark.skip(reason="Address already in use")
def test_remember_provider(self):
"""
If the user check remember, next login should not offer the chose of the backend CAS
@@ -355,6 +361,7 @@ class FederateAuthLoginLogoutTestCase(
provider.suffix
))
+ @pytest.mark.skip(reason="Address already in use")
def test_forget_provider(self):
"""Test the logout option to forget remembered provider"""
tickets = self.test_login_post_provider(remember=True)
@@ -365,6 +372,7 @@ class FederateAuthLoginLogoutTestCase(
client.get("/logout?forget_provider=1")
self.assertEqual(client.cookies["remember_provider"]["max-age"], 0)
+ @pytest.mark.skip(reason="Address already in use")
def test_renew(self):
"""
Test authentication renewal with federation mode
diff --git a/cas_server/tests/test_utils.py b/cas_server/tests/test_utils.py
index d690724..73ee761 100644
--- a/cas_server/tests/test_utils.py
+++ b/cas_server/tests/test_utils.py
@@ -17,6 +17,7 @@ from django.db import connection
import six
import warnings
import datetime
+import pytest
from cas_server import utils
@@ -61,6 +62,7 @@ class CheckPasswordCase(TestCase):
)
)
+ @pytest.mark.skip(reason="crypt is broken somehow")
def test_crypt(self):
"""test the crypt auth method"""
salts = ["$6$UVVAQvrMyXMF3FF3", "aa"]

View file

@ -1,64 +0,0 @@
{
lib,
buildPythonPackage,
pytestCheckHook,
fetchFromGitHub,
setuptools,
wheel,
django,
lxml,
requests,
requests-futures,
six,
pytest-django,
pytest-env,
pytest-runner,
mock,
}:
buildPythonPackage rec {
pname = "django-cas-server";
version = "unstable-2024-04-13";
format = "pyproject";
src = fetchFromGitHub {
owner = "nitmir";
repo = "django-cas-server";
rev = "a04477d34eedba4fcc91f00a22689defd3f22a7f";
hash = "sha256-K6SKnYBiA1TrSdDSodYJoz1Bk20PsNo2g0dvs4XdmY0=";
};
patches = [ ./01-pytest.patch ];
nativeBuildInputs = [
setuptools
wheel
];
propagatedBuildInputs = [
django
lxml
requests
requests-futures
setuptools
six
];
nativeCheckInputs = [
mock
pytestCheckHook
pytest-django
pytest-env
pytest-runner
];
pythonImportsCheck = [ "cas_server" ];
meta = with lib; {
description = "A Django Central Authentication Service server implementing the CAS Protocol 3.0 Specification";
homepage = "https://github.com/nitmir/django-cas-server";
changelog = "https://github.com/nitmir/django-cas-server/blob/${src.rev}/CHANGELOG.rst";
license = licenses.gpl3Only;
maintainers = [ ];
};
}

View file

@ -1,34 +0,0 @@
{
lib,
buildPythonPackage,
fetchFromGitHub,
setuptools,
wheel,
}:
buildPythonPackage rec {
pname = "loadcredential";
version = "1.1";
pyproject = true;
src = fetchFromGitHub {
owner = "Tom-Hubrecht";
repo = "loadcredential";
rev = "v${version}";
hash = "sha256-GXpMqGLDmDnTGa9cBYe0CP3Evm5sQ3AK9u6k3mLAW34=";
};
build-system = [
setuptools
wheel
];
pythonImportsCheck = [ "loadcredential" ];
meta = {
description = "A simple python package to read credentials passed through systemd's LoadCredential, with a fallback on env variables ";
homepage = "https://github.com/Tom-Hubrecht/loadcredential";
license = lib.licenses.mit;
maintainers = [ ]; # with lib.maintainers; [ thubrecht ];
};
}

View file

@ -175,6 +175,17 @@
"url": null,
"hash": "1c6cc44pwlg3ky6cnwhkml8ci77fw3sgjhwvqg0f6igxxf2fqv9v"
},
"nix-pkgs": {
"type": "Git",
"repository": {
"type": "Git",
"url": "https://git.hubrecht.ovh/hubrecht/nix-pkgs"
},
"branch": "main",
"revision": "1a0f0ad29565db768db52d92973f92993c7c16ed",
"url": null,
"hash": "14yiyh6zg3kybnqh1dfmwcm7hydc1xvapsamf4hzbnfssfgzvvwk"
},
"nixos-23.11": {
"type": "Channel",
"name": "nixos-23.11",