mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 19:13:26 +03:00
parent
41ff93c1d8
commit
dd7cee4f04
2 changed files with 87 additions and 86 deletions
|
@ -903,7 +903,7 @@ in {
|
||||||
phylactery = handleTest ./web-apps/phylactery.nix {};
|
phylactery = handleTest ./web-apps/phylactery.nix {};
|
||||||
pict-rs = handleTest ./pict-rs.nix {};
|
pict-rs = handleTest ./pict-rs.nix {};
|
||||||
pingvin-share = handleTest ./pingvin-share.nix {} ;
|
pingvin-share = handleTest ./pingvin-share.nix {} ;
|
||||||
pinnwand = handleTest ./pinnwand.nix {};
|
pinnwand = runTest ./pinnwand.nix;
|
||||||
plantuml-server = handleTest ./plantuml-server.nix {};
|
plantuml-server = handleTest ./plantuml-server.nix {};
|
||||||
plasma-bigscreen = handleTest ./plasma-bigscreen.nix {};
|
plasma-bigscreen = handleTest ./plasma-bigscreen.nix {};
|
||||||
plasma5 = handleTest ./plasma5.nix {};
|
plasma5 = handleTest ./plasma5.nix {};
|
||||||
|
|
|
@ -1,102 +1,103 @@
|
||||||
import ./make-test-python.nix (
|
{
|
||||||
{ pkgs, ... }:
|
pkgs,
|
||||||
let
|
...
|
||||||
port = 8000;
|
}:
|
||||||
baseUrl = "http://server:${toString port}";
|
let
|
||||||
in
|
port = 8000;
|
||||||
{
|
baseUrl = "http://server:${toString port}";
|
||||||
name = "pinnwand";
|
in
|
||||||
meta = with pkgs.lib.maintainers; {
|
{
|
||||||
maintainers = [ hexa ];
|
name = "pinnwand";
|
||||||
};
|
meta = with pkgs.lib.maintainers; {
|
||||||
|
maintainers = [ hexa ];
|
||||||
|
};
|
||||||
|
|
||||||
nodes = {
|
nodes = {
|
||||||
server =
|
server =
|
||||||
{ config, ... }:
|
{ config, ... }:
|
||||||
{
|
{
|
||||||
networking.firewall.allowedTCPPorts = [
|
networking.firewall.allowedTCPPorts = [
|
||||||
port
|
port
|
||||||
];
|
];
|
||||||
|
|
||||||
services.pinnwand = {
|
services.pinnwand = {
|
||||||
enable = true;
|
enable = true;
|
||||||
port = port;
|
port = port;
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
client =
|
client =
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
{
|
{
|
||||||
environment.systemPackages = [
|
environment.systemPackages = [
|
||||||
pkgs.steck
|
pkgs.steck
|
||||||
|
|
||||||
(pkgs.writers.writePython3Bin "setup-steck.py"
|
(pkgs.writers.writePython3Bin "setup-steck.py"
|
||||||
{
|
{
|
||||||
libraries = with pkgs.python3.pkgs; [
|
libraries = with pkgs.python3.pkgs; [
|
||||||
appdirs
|
appdirs
|
||||||
toml
|
toml
|
||||||
];
|
];
|
||||||
flakeIgnore = [
|
flakeIgnore = [
|
||||||
"E501"
|
"E501"
|
||||||
];
|
];
|
||||||
|
}
|
||||||
|
''
|
||||||
|
import appdirs
|
||||||
|
import toml
|
||||||
|
import os
|
||||||
|
|
||||||
|
CONFIG = {
|
||||||
|
"base": "${baseUrl}/",
|
||||||
|
"confirm": False,
|
||||||
|
"magic": True,
|
||||||
|
"ignore": True
|
||||||
}
|
}
|
||||||
''
|
|
||||||
import appdirs
|
|
||||||
import toml
|
|
||||||
import os
|
|
||||||
|
|
||||||
CONFIG = {
|
os.makedirs(appdirs.user_config_dir('steck'))
|
||||||
"base": "${baseUrl}/",
|
with open(os.path.join(appdirs.user_config_dir('steck'), 'steck.toml'), "w") as fd:
|
||||||
"confirm": False,
|
toml.dump(CONFIG, fd)
|
||||||
"magic": True,
|
''
|
||||||
"ignore": True
|
)
|
||||||
}
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
os.makedirs(appdirs.user_config_dir('steck'))
|
testScript = ''
|
||||||
with open(os.path.join(appdirs.user_config_dir('steck'), 'steck.toml'), "w") as fd:
|
start_all()
|
||||||
toml.dump(CONFIG, fd)
|
|
||||||
''
|
|
||||||
)
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
testScript = ''
|
server.wait_for_unit("pinnwand.service")
|
||||||
start_all()
|
client.wait_for_unit("network.target")
|
||||||
|
|
||||||
server.wait_for_unit("pinnwand.service")
|
# create steck.toml config file
|
||||||
client.wait_for_unit("network.target")
|
client.succeed("setup-steck.py")
|
||||||
|
|
||||||
# create steck.toml config file
|
# wait until the server running pinnwand is reachable
|
||||||
client.succeed("setup-steck.py")
|
client.wait_until_succeeds("ping -c1 server")
|
||||||
|
|
||||||
# wait until the server running pinnwand is reachable
|
# make sure pinnwand is listening
|
||||||
client.wait_until_succeeds("ping -c1 server")
|
server.wait_for_open_port(${toString port})
|
||||||
|
|
||||||
# make sure pinnwand is listening
|
# send the contents of /etc/machine-id
|
||||||
server.wait_for_open_port(${toString port})
|
response = client.succeed("steck paste /etc/machine-id")
|
||||||
|
|
||||||
# send the contents of /etc/machine-id
|
# parse the steck response
|
||||||
response = client.succeed("steck paste /etc/machine-id")
|
raw_url = None
|
||||||
|
removal_link = None
|
||||||
|
for line in response.split("\n"):
|
||||||
|
if line.startswith("View link:"):
|
||||||
|
raw_url = f"${baseUrl}/raw/{line.split('/')[-1]}"
|
||||||
|
if line.startswith("Removal link:"):
|
||||||
|
removal_link = line.split(":", 1)[1]
|
||||||
|
|
||||||
# parse the steck response
|
# check whether paste matches what we sent
|
||||||
raw_url = None
|
client.succeed(f"curl {raw_url} > /tmp/machine-id")
|
||||||
removal_link = None
|
client.succeed("diff /tmp/machine-id /etc/machine-id")
|
||||||
for line in response.split("\n"):
|
|
||||||
if line.startswith("View link:"):
|
|
||||||
raw_url = f"${baseUrl}/raw/{line.split('/')[-1]}"
|
|
||||||
if line.startswith("Removal link:"):
|
|
||||||
removal_link = line.split(":", 1)[1]
|
|
||||||
|
|
||||||
# check whether paste matches what we sent
|
# remove paste and check that it's not available any more
|
||||||
client.succeed(f"curl {raw_url} > /tmp/machine-id")
|
client.succeed(f"curl {removal_link}")
|
||||||
client.succeed("diff /tmp/machine-id /etc/machine-id")
|
client.fail(f"curl --fail {raw_url}")
|
||||||
|
|
||||||
# remove paste and check that it's not available any more
|
server.log(server.execute("systemd-analyze security pinnwand | grep '✗'")[1])
|
||||||
client.succeed(f"curl {removal_link}")
|
'';
|
||||||
client.fail(f"curl --fail {raw_url}")
|
}
|
||||||
|
|
||||||
server.log(server.execute("systemd-analyze security pinnwand | grep '✗'")[1])
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue