Simple test
parent
e8b630b23d
commit
aebef85ff6
@ -0,0 +1,25 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1692463654,
|
||||
"narHash": "sha256-F8hZmsQINI+S6UROM4jyxAMbQLtzE44pI8Nk6NtMdao=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "ca3c9ac9f4cdd4bea19f592b32bb59b74ab7d783",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
{
|
||||
version = "v1";
|
||||
subnets = [
|
||||
{
|
||||
name = "simple";
|
||||
endpoints = [
|
||||
{
|
||||
# No match mean match any
|
||||
port = 51820;
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
groups = [
|
||||
# groups field is expected, but can be empty
|
||||
];
|
||||
peers = [
|
||||
{
|
||||
name = "peer1";
|
||||
subnets = {
|
||||
simple = {
|
||||
listenPort = 51820;
|
||||
# empty ipAddresses will auto generate an IPv6 address
|
||||
};
|
||||
};
|
||||
publicKey = "kdyzqV8cBQtDYeW6R1vUug0Oe+KaytHHDS7JoCp/kTE=";
|
||||
privateKey = "MIELhEc0I7BseAanhk/+LlY/+Yf7GK232vKWITExnEI="; # path is relative to the machine
|
||||
endpoints = [
|
||||
{
|
||||
# no match can be any
|
||||
ip = "192.168.1.2";
|
||||
}
|
||||
];
|
||||
}
|
||||
{
|
||||
name = "peer2";
|
||||
subnets = {
|
||||
simple = {
|
||||
listenPort = 51820;
|
||||
};
|
||||
};
|
||||
publicKey = "ztdAXTspQEZUNpxUbUdAhhRWbiL3YYWKSK0ZGdcsMHE=";
|
||||
privateKey = "yG4mJiduoAvzhUJMslRbZwOp1gowSfC+wgY8B/Mul1M=";
|
||||
endpoints = [
|
||||
{
|
||||
# no match can be any
|
||||
ip = "192.168.1.3";
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
connections = [
|
||||
{
|
||||
a = [{type= "subnet"; rule = "is"; value = "simple";}];
|
||||
b = [{type= "subnet"; rule = "is"; value = "simple";}];
|
||||
}
|
||||
];
|
||||
}
|
@ -0,0 +1 @@
|
||||
MIELhEc0I7BseAanhk/+LlY/+Yf7GK232vKWITExnEI=
|
@ -0,0 +1 @@
|
||||
yG4mJiduoAvzhUJMslRbZwOp1gowSfC+wgY8B/Mul1M=
|
@ -0,0 +1 @@
|
||||
mAk4v/O2y3mFwQqsZow52iwOlcfR3wPtd9cVBwS+vVg=
|
@ -0,0 +1 @@
|
||||
aKOVgooO5npcsTrDb2lKXEiOH+XhJTs3/GHICplKmHE=
|
@ -0,0 +1 @@
|
||||
aPMW0ePlRmh3HZ075ArvUHIotrGTGE+nRvqKPtwXClc=
|
@ -0,0 +1 @@
|
||||
IDpYI54t9nGxmj84KUpRaFUnzaD74LVm1y38rGeIVVg=
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
let
|
||||
sharedConfig = {
|
||||
wirenix = {
|
||||
enable = true;
|
||||
keyProviders = ["acl"];
|
||||
aclConfig = import ./acls/simple.nix;
|
||||
};
|
||||
};
|
||||
in
|
||||
(import ./lib.nix)
|
||||
{
|
||||
name = "Null test, should always pass";
|
||||
nodes = {
|
||||
# `self` here is set by using specialArgs in `lib.nix`
|
||||
node1 = { self, pkgs, ... }: sharedConfig // {
|
||||
imports = [ self.nixosModules.default ];
|
||||
wirenix = {
|
||||
enable = true;
|
||||
keyProviders = ["acl"];
|
||||
peerName = "peer1";
|
||||
aclConfig = import ./acls/simple.nix;
|
||||
};
|
||||
networking.interfaces.eth1.ipv4.addresses = [
|
||||
{
|
||||
address = "192.168.1.2";
|
||||
prefixLength = 24;
|
||||
}
|
||||
];
|
||||
environment.systemPackages = [ pkgs.curl ];
|
||||
};
|
||||
|
||||
node2 = { self, pkgs, ... }: sharedConfig // {
|
||||
imports = [ self.nixosModules.default ];
|
||||
wirenix = {
|
||||
enable = true;
|
||||
keyProviders = ["acl"];
|
||||
peerName = "peer2";
|
||||
aclConfig = import ./acls/simple.nix;
|
||||
};
|
||||
networking.interfaces.eth1.ipv4.addresses = [
|
||||
{
|
||||
address = "192.168.1.3";
|
||||
prefixLength = 24;
|
||||
}
|
||||
];
|
||||
environment.systemPackages = [ pkgs.curl ];
|
||||
};
|
||||
};
|
||||
# This is the test code that will check if our service is running correctly:
|
||||
testScript = ''
|
||||
start_all()
|
||||
node1.wait_for_unit("wireguard-simple")
|
||||
node2.wait_for_unit("wireguard-simple")
|
||||
output = node1.succeed("ping -c 1 peer2.simple")
|
||||
# Check if our webserver returns the expected result
|
||||
assert "Hello world" in output, f"'{output}' does not contain 'Hello world'"
|
||||
'';
|
||||
}
|
Loading…
Reference in New Issue