feat(testing02): Init testing vm
Some checks failed
Check meta / check_dns (push) Successful in 19s
Check meta / check_meta (push) Successful in 19s
Run pre-commit on all files / pre-commit (push) Failing after 38s

This commit is contained in:
sinavir 2025-01-04 12:01:29 +01:00
parent e6a5007f65
commit ee34d4465e
No known key found for this signature in database
14 changed files with 457 additions and 18 deletions

View file

@ -120,6 +120,17 @@ jobs:
STORE_USER: admin
name: Build and cache storage01
run: nix-shell -A eval-nodes --run cache-node
testing02:
runs-on: nix
steps:
- uses: actions/checkout@v3
- env:
BUILD_NODE: testing02
STORE_ENDPOINT: https://tvix-store.dgnum.eu/infra-signing/
STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }}
STORE_USER: admin
name: Build and cache testing02
run: nix-shell -A eval-nodes --run cache-node
tower01:
runs-on: nix
steps:

View file

@ -20,7 +20,7 @@ precedence = "closest"
[[annotations]]
SPDX-FileCopyrightText = "2024 Tom Hubrecht <tom.hubrecht@dgnum.eu>"
SPDX-License-Identifier = "EUPL-1.2"
path = ["machines/nixos/compute01/ds-fr/01-smtp-tls.patch", "machines/nixos/compute01/librenms/kanidm.patch", "machines/nixos/compute01/stirling-pdf/*.patch", "machines/nixos/vault01/k-radius/packages/01-python_path.patch", "machines/nixos/web01/crabfit/*.patch", "machines/nixos/web02/cas-eleves/01-pytest-cas.patch", "patches/lix/01-disable-installChecks.patch", "patches/nixpkgs/03-crabfit-karla.patch", "patches/nixpkgs/05-netbird-relay.patch"]
path = ["machines/nixos/compute01/ds-fr/01-smtp-tls.patch", "machines/nixos/compute01/librenms/kanidm.patch", "machines/nixos/compute01/stirling-pdf/*.patch", "machines/nixos/vault01/k-radius/packages/01-python_path.patch", "machines/nixos/web01/crabfit/*.patch", "machines/nixos/web02/cas-eleves/01-pytest-cas.patch", "machines/nixos/testing02/cas-eleves/01-pytest-cas.patch", "patches/lix/01-disable-installChecks.patch", "patches/nixpkgs/03-crabfit-karla.patch", "patches/nixpkgs/05-netbird-relay.patch"]
precedence = "closest"
[[annotations]]

View file

@ -5,7 +5,9 @@
{
sources ? import ./npins,
pkgs ? import sources.nixpkgs { },
pkgs ? import sources.nixpkgs {
overlays = [ (import sources.proxmox-nixos).overlays.x86_64-linux ];
},
}:
let
@ -93,6 +95,7 @@ let
"machines/nixos/vault01/k-radius/packages/01-python_path.patch"
"machines/nixos/web01/crabfit/*.patch"
"machines/nixos/web02/cas-eleves/01-pytest-cas.patch"
"machines/nixos/testing02/cas-eleves/01-pytest-cas.patch"
"patches/lix/01-disable-installChecks.patch"
"patches/nixpkgs/03-crabfit-karla.patch"
"patches/nixpkgs/05-netbird-relay.patch"
@ -177,24 +180,30 @@ in
devShell = pkgs.mkShell {
name = "dgnum-infra";
packages = [
(pkgs.nixos-generators.overrideAttrs (_: {
version = "1.8.0-unstable";
src = sources.nixos-generators;
}))
pkgs.npins
packages =
[
(pkgs.nixos-generators.overrideAttrs (_: {
version = "1.8.0-unstable";
src = sources.nixos-generators;
}))
pkgs.npins
# SSO testing
pkgs.kanidm
pkgs.freeradius
pkgs.picocom # for serial access
# deploying on testing hypervisor
pkgs.nixmoxer
(pkgs.callPackage ./lib/colmena {
colmena = pkgs.callPackage "${sources.colmena}/package.nix" { };
})
(pkgs.callPackage "${sources.agenix}/pkgs/agenix.nix" { })
(pkgs.callPackage "${sources.lon}/nix/packages/lon.nix" { })
] ++ git-checks.enabledPackages ++ (builtins.attrValues scripts);
# SSO testing
pkgs.kanidm
pkgs.freeradius
pkgs.picocom # for serial access
(pkgs.callPackage ./lib/colmena {
colmena = pkgs.callPackage "${sources.colmena}/package.nix" { };
})
(pkgs.callPackage "${sources.agenix}/pkgs/agenix.nix" { })
(pkgs.callPackage "${sources.lon}/nix/packages/lon.nix" { })
]
++ git-checks.enabledPackages
++ (builtins.attrValues scripts);
shellHook = builtins.concatStringsSep "\n" [
git-checks.shellHook

View file

@ -0,0 +1,47 @@
# SPDX-FileCopyrightText: 2024 Tom Hubrecht <tom.hubrecht@dgnum.eu>
#
# SPDX-License-Identifier: EUPL-1.2
{ lib, pkgs, ... }:
lib.extra.mkConfig {
enabledModules = [
# List of modules to enable
"dgn-web"
];
enabledServices = [
# List of services to enable
"cas-eleves"
];
extraConfig = {
# Disable monitoring
dgn-node-monitoring.enable = false;
# Enable Postgres databases
services.postgresql = {
enable = true;
package = pkgs.postgresql_16;
};
virtualisation.proxmox = {
node = "krz01";
autoInstall = true;
vmid = 106;
bios = "ovmf";
memory = 4096;
cores = 2;
net = [
{
model = "virtio";
bridge = "vmbr0";
}
];
scsi = [ { file = "zfs-noraid:16"; } ]; # This will create a 16GB volume in 'local'
};
};
root = ./.;
}

View file

@ -0,0 +1,33 @@
# SPDX-FileCopyrightText: 2024 Tom Hubrecht <tom.hubrecht@dgnum.eu>
#
# SPDX-License-Identifier: EUPL-1.2
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ modulesPath, sources, ... }:
{
imports = [
(modulesPath + "/profiles/qemu-guest.nix")
(sources.disko + "/module.nix")
./disko.nix
];
boot = {
initrd = {
availableKernelModules = [
"ata_piix"
"uhci_hcd"
"ehci_pci"
"virtio_pci"
"sr_mod"
"virtio_blk"
];
kernelModules = [ ];
};
kernelModules = [ "kvm-intel" ];
extraModulePackages = [ ];
};
}

View file

@ -0,0 +1,98 @@
diff --git a/setup.py b/setup.py
index 7c7b02d..3f677ff 100644
--- a/setup.py
+++ b/setup.py
@@ -67,6 +67,4 @@ if __name__ == '__main__':
url="https://github.com/nitmir/django-cas-server",
download_url="https://github.com/nitmir/django-cas-server/releases/latest",
zip_safe=False,
- setup_requires=['pytest-runner'],
- tests_require=['pytest', 'pytest-django', 'pytest-pythonpath', 'pytest-warnings', 'mock>=1'],
)
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

@ -0,0 +1,156 @@
# SPDX-FileCopyrightText: 2024 Tom Hubrecht <tom.hubrecht@dgnum.eu>
#
# SPDX-License-Identifier: EUPL-1.2
{
config,
lib,
pkgs,
sources,
...
}:
let
inherit (lib) mapAttrsToList;
host = "cas.eleves.ens.fr";
port = 9889;
python3 =
let
nix-pkgs = import sources.nix-pkgs {
inherit pkgs;
python3 = pkgs.python312;
};
self = pkgs.python312.override {
inherit self;
openssl = pkgs.openssl_3;
packageOverrides = _: _: {
inherit (nix-pkgs) django-browser-reload django-bulma-forms loadcredential;
django-cas-server = nix-pkgs.django-cas-server.overridePythonAttrs (_: {
patches = [ ./01-pytest-cas.patch ];
});
};
};
in
self;
pythonEnv = python3.withPackages (ps: [
ps.django
ps.ldap3
ps.gunicorn
ps.psycopg
# Local packages
ps.django-browser-reload
ps.django-bulma-forms
ps.django-cas-server
ps.loadcredential
]);
staticDrv = pkgs.stdenv.mkDerivation {
name = "cas_eleves-static";
src = sources.cas-eleves;
nativeBuildInputs = [ pythonEnv ];
configurePhase = ''
export CE_STATIC_ROOT=$out/static
export CE_DEBUG=true
export CREDENTIALS_DIRECTORY=$(pwd)/.credentials
'';
doBuild = false;
installPhase = ''
mkdir -p $out/static
python3 manage.py collectstatic
'';
};
in
{
systemd.services = {
django-cas-eleves = {
description = "ENS CAS server";
wantedBy = [ "multi-user.target" ];
after = [
"network.target"
"postgresql.service"
];
serviceConfig = {
DynamicUser = true;
LoadCredential = mapAttrsToList (name: value: "${name}:${value}") {
SECRET_KEY = config.age.secrets."cas_eleves-secret_key_file".path;
};
StateDirectory = "django-cas-eleves";
User = "cas_server";
WorkingDirectory = sources.cas-eleves;
};
environment = {
CE_ALLOWED_HOSTS = builtins.toJSON [
"cas-eleves.dgnum.eu"
"cas.eleves.ens.fr"
];
CE_STATIC_ROOT = staticDrv;
};
path = [ pythonEnv ];
script = ''
python3 manage.py loaddata patterns
python3 manage.py migrate
gunicorn app.wsgi --pythonpath ${sources.cas-eleves} -b 127.0.0.1:${builtins.toString port} --workers=2 --threads=4
'';
};
cas-eleves-cleanup = {
description = "Periodic cleanup of cas_server database";
startAt = "daily";
serviceConfig = {
Type = "oneshot";
LoadCredential = mapAttrsToList (name: value: "${name}:${value}") {
SECRET_KEY = config.age.secrets."cas_eleves-secret_key_file".path;
};
StateDirectory = "django-cas-eleves";
User = "cas_server";
WorkingDirectory = sources.cas-eleves;
};
path = [ pythonEnv ];
script = ''
python3 manage.py clearsessions
python3 manage.py cas_clean_sessions
python3 manage.py cas_clean_tickets
'';
};
};
dgn-redirections.permanent."cas-eleves.dgnum.eu" = "cas.eleves.ens.fr";
dgn-web.simpleProxies.cas-eleves = {
inherit host port;
vhostConfig.locations = {
"/static/".root = staticDrv;
"= /robots.txt".root = "${staticDrv}/static";
};
};
services.postgresql = {
ensureDatabases = [ "cas_server" ];
ensureUsers = [
{
name = "cas_server";
ensureDBOwnership = true;
}
];
};
}

View file

@ -0,0 +1,37 @@
# SPDX-FileCopyrightText: 2024 Maurice Debray <maurice.debray@dgnum.eu>
#
# SPDX-License-Identifier: EUPL-1.2
_: {
disko.devices = {
disk = {
main = {
device = "/dev/sda";
type = "disk";
content = {
type = "gpt";
partitions = {
ESP = {
type = "EF00";
size = "1G";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [ "umask=0077" ];
};
};
root = {
size = "100%";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
};
};
};
};
};
};
};
}

View file

@ -0,0 +1,10 @@
# SPDX-FileCopyrightText: 2024 La Délégation Générale Numérique <contact@dgnum.eu>
#
# SPDX-License-Identifier: EUPL-1.2
(import ../../../../keys).mkSecrets
[ "web02" ]
[
# List of secrets for web02
"cas_eleves-secret_key_file"
]

View file

@ -115,6 +115,10 @@ let
"status" # Uptime Kuma
];
testing02.dual = [
"*.testing"
];
vault01.dual = [
"radius" # FreeRADIUS
];

View file

@ -189,6 +189,25 @@
netbirdIp = "100.80.156.154";
};
testing02 = {
interfaces = {
ens18 = {
ipv4 = [
{
address = "129.199.146.235";
prefixLength = 24;
}
];
gateways = [ "129.199.146.254" ];
enableDefaultDNS = true;
};
};
hostId = "7bb28324";
netbirdIp = null; # testing02 is not to be connected on the VPN
};
tower01 = {
interfaces = {
eno2 = {

View file

@ -182,6 +182,20 @@
];
};
testing02 = {
site = "pav01";
hashedPassword = "$y$j9T$GMdDdUJFS3/.JruWdRjaJ1$7Or5QvWsYQ77swplkQdYAqdyVDmku0t6htBL0r5MT19";
stateVersion = "24.11";
vm-cluster = "Hyperviseur Lab-infra";
nixpkgs = {
version = "24.11";
system = "nixos";
};
};
tower01 = {
site = "oik01";

View file

@ -38,6 +38,7 @@
"${sources.agenix}/modules/age.nix"
"${sources.arkheon}/module.nix"
"${sources."microvm.nix"}/nixos-modules/host"
(import sources.proxmox-nixos).nixosModules.declarative-vms
]
++ ((import sources.nix-modules { inherit lib; }).importModules (
[