Merge pull request #72012 from rnhmjoj/magnetico

nixos/magnetico: fixes
This commit is contained in:
Renaud 2019-11-17 10:42:22 +01:00 committed by GitHub
commit 07f5d3bb20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 10 deletions

View file

@ -35,6 +35,7 @@ let
(if (cfg.web.credentialsFile != null || cfg.web.credentials != { }) (if (cfg.web.credentialsFile != null || cfg.web.credentials != { })
then "--credentials=${toString credFile}" then "--credentials=${toString credFile}"
else "--no-auth") else "--no-auth")
"--addr=${address}:${toString port}"
] ++ extraOptions); ] ++ extraOptions);
in { in {
@ -177,7 +178,7 @@ in {
systemd.services.magneticod = { systemd.services.magneticod = {
description = "Magnetico DHT crawler"; description = "Magnetico DHT crawler";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
after = [ "network-online.target" ]; after = [ "network.target" ];
serviceConfig = { serviceConfig = {
User = "magnetico"; User = "magnetico";
@ -189,7 +190,7 @@ in {
systemd.services.magneticow = { systemd.services.magneticow = {
description = "Magnetico web interface"; description = "Magnetico web interface";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
after = [ "network-online.target" "magneticod.service"]; after = [ "network.target" "magneticod.service"];
serviceConfig = { serviceConfig = {
User = "magnetico"; User = "magnetico";
@ -202,7 +203,7 @@ in {
assertions = assertions =
[ [
{ {
assertion = cfg.web.credentialsFile != null || cfg.web.credentials != { }; assertion = cfg.web.credentialsFile == null || cfg.web.credentials == { };
message = '' message = ''
The options services.magnetico.web.credentialsFile and The options services.magnetico.web.credentialsFile and
services.magnetico.web.credentials are mutually exclusives. services.magnetico.web.credentials are mutually exclusives.

View file

@ -148,6 +148,7 @@ in
loki = handleTest ./loki.nix {}; loki = handleTest ./loki.nix {};
#logstash = handleTest ./logstash.nix {}; #logstash = handleTest ./logstash.nix {};
lorri = handleTest ./lorri/default.nix {}; lorri = handleTest ./lorri/default.nix {};
magnetico = handleTest ./magnetico.nix {};
mailcatcher = handleTest ./mailcatcher.nix {}; mailcatcher = handleTest ./mailcatcher.nix {};
mathics = handleTest ./mathics.nix {}; mathics = handleTest ./mathics.nix {};
matomo = handleTest ./matomo.nix {}; matomo = handleTest ./matomo.nix {};

View file

@ -1,4 +1,9 @@
import ./make-test.nix ({ pkgs, ...} : { import ./make-test-python.nix ({ pkgs, ...} :
let
port = 8081;
in
{
name = "magnetico"; name = "magnetico";
meta = with pkgs.stdenv.lib.maintainers; { meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ rnhmjoj ]; maintainers = [ rnhmjoj ];
@ -12,17 +17,24 @@ import ./make-test.nix ({ pkgs, ...} : {
services.magnetico = { services.magnetico = {
enable = true; enable = true;
crawler.port = 9000; crawler.port = 9000;
web.port = port;
web.credentials.user = "$2y$12$P88ZF6soFthiiAeXnz64aOWDsY3Dw7Yw8fZ6GtiqFNjknD70zDmNe"; web.credentials.user = "$2y$12$P88ZF6soFthiiAeXnz64aOWDsY3Dw7Yw8fZ6GtiqFNjknD70zDmNe";
}; };
}; };
testScript = testScript =
'' ''
startAll; start_all()
$machine->waitForUnit("magneticod"); machine.wait_for_unit("magneticod")
$machine->waitForUnit("magneticow"); machine.wait_for_unit("magneticow")
$machine->succeed("${pkgs.curl}/bin/curl -u user:password http://localhost:8080"); machine.succeed(
$machine->succeed("${pkgs.curl}/bin/curl -u user:wrongpwd http://localhost:8080") =~ "Unauthorised." or die; "${pkgs.curl}/bin/curl "
$machine->shutdown(); + "-u user:password http://localhost:${toString port}"
)
assert "Unauthorised." in machine.succeed(
"${pkgs.curl}/bin/curl "
+ "-u user:wrongpwd http://localhost:${toString port}"
)
machine.shutdown()
''; '';
}) })