mob next [ci-skip] [ci skip] [skip ci]

lastFile:modules/clan/phonebox/tests/vm/default.nix
This commit is contained in:
2025-10-24 16:49:17 +07:00
parent e22fd4e65a
commit 1d0cbbbd94
4 changed files with 185 additions and 3 deletions

View File

@@ -15,9 +15,6 @@
networking.firewall.allowedUDPPorts = [ 5060 ];
services.asterisk = {
enable = lib.mkDefault true;
extraArguments = [
"-vvvddd"
];
confFiles = {
"logger.conf" = ''
[general]

View File

@@ -0,0 +1,128 @@
{ ... }:
{
_class = "clan.service";
manifest.name = "phonebox";
manifest.description = "";
manifest.categories = [ "System" ];
roles.default = {
perInstance.nixosModule =
{
lib,
...
}:
{
networking.firewall.allowedUDPPorts = [ 5060 ];
services.asterisk = {
enable = lib.mkDefault true;
confFiles = {
"logger.conf" = ''
[general]
dateformat = %F %T.%3q ; ISO 8601 date format with milliseconds
use_callids = yes
appendhostname = no
queue_log = yes
queue_log_to_file = no
queue_log_name = queue_log
queue_log_realtime_use_gmt = no
rotatestrategy = rotate
exec_after_rotate=gzip -9 $\{filename\}.2
[logfiles]
console => notice,warning,error
security => security
messages => notice,warning,error
full => notice,warning,error,verbose,dtmf,fax
syslog.local0 => notice,warning,error
'';
# Dial plan config
"extensions.conf" = ''
[from-internal]
exten => 100,1,Answer()
same => n,Wait(1)
same => n,Playback(hello-world)
same => n,Hangup()
exten => 6001,1,Dial(PJSIP/6001,20)
exten => 6002,1,Dial(PJSIP/6002,20)
exten => 8001,1,Dial(PJSIP/8001@kurogeek,20)
'';
"pjsip.conf" = ''
[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0
[transport-udp6]
type=transport
protocol=udp
bind=::
[kurogeek]
type=endpoint
context=from-kurogeek
disallow=all
allow=ulaw
allow=alaw
allow=g722
allow=gsm
aors=kurogeek
direct_media=no
[kurogeek]
type=aor
contact=sip:[fd79:fada:fbe9:8c5d:d899:932b:d36d:b8cc]
[kurogeek]
type=identify
endpoint=kurogeek
match=[fd79:fada:fbe9:8c5d:d899:932b:d36d:b8cc]
[6001]
type=endpoint
context=from-internal
disallow=all
allow=ulaw
allow=alaw
allow=g722
allow=gsm
auth=6001
aors=6001
direct_media=no
[6001]
type=auth
auth_type=userpass
password=unsecurepassword
username=6001
[6001]
type=aor
max_contacts=1
[6002]
type=endpoint
context=from-internal
disallow=all
allow=ulaw
allow=alaw
allow=g722
allow=gsm
auth=6002
aors=6002
direct_media=no
[6002]
type=auth
auth_type=userpass
password=unsecurepassword
username=6002
[6002]
type=aor
max_contacts=1
'';
};
};
};
};
}

View File

@@ -0,0 +1,18 @@
{ lib, ... }:
let
module = lib.modules.importApply ./default.nix { };
in
{
clan.modules = {
phonebox = module;
};
perSystem =
{ ... }:
{
clan.nixosTests.phonebox = {
imports = [ ./tests/vm/default.nix ];
clan.modules."@clan/phonebox" = module;
};
};
}

View File

@@ -0,0 +1,39 @@
{
pkgs,
...
}:
{
name = "service-phonebox";
clan = {
directory = ./.;
inventory = {
machines.server = { };
instances = {
phonebox-test = {
module.name = "@clan/phonebox";
module.input = "self";
roles.default.machines."server".settings = { };
};
};
};
};
nodes = {
server = {
services.asterisk = {
};
};
};
testScript = ''
start_all()
server.wait_for_unit("asterisk")
# Check that garage is running
server.succeed("systemctl status asterisk")
'';
}