diff --git a/examples/docker/README.md b/examples/docker/basic/README.md similarity index 100% rename from examples/docker/README.md rename to examples/docker/basic/README.md diff --git a/examples/docker/config/bffh.dhall b/examples/docker/basic/config/bffh.dhall similarity index 100% rename from examples/docker/config/bffh.dhall rename to examples/docker/basic/config/bffh.dhall diff --git a/examples/docker/config/pass.toml b/examples/docker/basic/config/pass.toml similarity index 100% rename from examples/docker/config/pass.toml rename to examples/docker/basic/config/pass.toml diff --git a/examples/docker/config/roles.toml b/examples/docker/basic/config/roles.toml similarity index 100% rename from examples/docker/config/roles.toml rename to examples/docker/basic/config/roles.toml diff --git a/examples/docker/config/users.toml b/examples/docker/basic/config/users.toml similarity index 100% rename from examples/docker/config/users.toml rename to examples/docker/basic/config/users.toml diff --git a/examples/docker/docker-compose.yaml b/examples/docker/basic/docker-compose.yaml similarity index 100% rename from examples/docker/docker-compose.yaml rename to examples/docker/basic/docker-compose.yaml diff --git a/examples/docker/integration/README.md b/examples/docker/integration/README.md new file mode 100644 index 0000000..2588e6e --- /dev/null +++ b/examples/docker/integration/README.md @@ -0,0 +1,11 @@ +# Integration tests with Docker + +## How it works +* spawns 2 instances of our bffh container and required mqqt broker +* spawns an additional debian to run a shell +* the containers can reach each other by their hostname + +## How to start + +* run `docker-compose up --exit-code-from test-manager` in this directory +* this will kill all containers when \ No newline at end of file diff --git a/examples/docker/integration/config_a/bffh.dhall b/examples/docker/integration/config_a/bffh.dhall new file mode 100644 index 0000000..cb5cf78 --- /dev/null +++ b/examples/docker/integration/config_a/bffh.dhall @@ -0,0 +1,20 @@ +{ actor_connections = [{ _1 = "Testmachine", _2 = "Actor" }] +, actors = + { Actor = { module = "Shelly", params = {=} } + } +, init_connections = [{ _1 = "Initiator", _2 = "Testmachine" }] +, initiators = + { Initiator = { module = "Dummy", params = {=} } + } +, listens = [{ address = "::", port = Some 59661 }] +, machines = + { Testmachine = + { description = Some "A test machine" + , disclose = "lab.test.read" + , manage = "lab.test.admin" + , name = "Testmachine" + , read = "lab.test.read" + , write = "lab.test.write" + } } +, mqtt_url = "tcp://mqtt-a:1883" +} diff --git a/examples/docker/integration/config_a/pass.toml b/examples/docker/integration/config_a/pass.toml new file mode 100644 index 0000000..6d4855d --- /dev/null +++ b/examples/docker/integration/config_a/pass.toml @@ -0,0 +1 @@ +Testuser = "secret" diff --git a/examples/docker/integration/config_a/roles.toml b/examples/docker/integration/config_a/roles.toml new file mode 100644 index 0000000..cc61b71 --- /dev/null +++ b/examples/docker/integration/config_a/roles.toml @@ -0,0 +1,20 @@ +[testrole] +name = "Testrole" +permissions = [ + "lab.test.*" +] + +[somerole] +name = "Somerole" +parents = ["testparent%lmdb"] +permissions = [ + "lab.some.admin" +] + +[testparent] +name = "Testparent" +permissions = [ + "lab.some.write", + "lab.some.read", + "lab.some.disclose", +] diff --git a/examples/docker/integration/config_a/users.toml b/examples/docker/integration/config_a/users.toml new file mode 100644 index 0000000..46c4a67 --- /dev/null +++ b/examples/docker/integration/config_a/users.toml @@ -0,0 +1,11 @@ +[Testuser] +# Define them in roles.toml as well +roles = [] + +# If two or more users want to use the same machine at once the higher prio +# wins +priority = 0 + +# You can add whatever random data you want. +# It will get stored in the `kv` field in UserData. +noot = "noot!" diff --git a/examples/docker/integration/config_b/bffh.dhall b/examples/docker/integration/config_b/bffh.dhall new file mode 100644 index 0000000..5a70bd0 --- /dev/null +++ b/examples/docker/integration/config_b/bffh.dhall @@ -0,0 +1,20 @@ +{ actor_connections = [{ _1 = "Testmachine", _2 = "Actor" }] +, actors = + { Actor = { module = "Shelly", params = {=} } + } +, init_connections = [{ _1 = "Initiator", _2 = "Testmachine" }] +, initiators = + { Initiator = { module = "Dummy", params = {=} } + } +, listens = [{ address = "::", port = Some 59661 }] +, machines = + { Testmachine = + { description = Some "A test machine" + , disclose = "lab.test.read" + , manage = "lab.test.admin" + , name = "Testmachine" + , read = "lab.test.read" + , write = "lab.test.write" + } } +, mqtt_url = "tcp://mqtt-b:1883" +} diff --git a/examples/docker/integration/config_b/pass.toml b/examples/docker/integration/config_b/pass.toml new file mode 100644 index 0000000..6d4855d --- /dev/null +++ b/examples/docker/integration/config_b/pass.toml @@ -0,0 +1 @@ +Testuser = "secret" diff --git a/examples/docker/integration/config_b/roles.toml b/examples/docker/integration/config_b/roles.toml new file mode 100644 index 0000000..cc61b71 --- /dev/null +++ b/examples/docker/integration/config_b/roles.toml @@ -0,0 +1,20 @@ +[testrole] +name = "Testrole" +permissions = [ + "lab.test.*" +] + +[somerole] +name = "Somerole" +parents = ["testparent%lmdb"] +permissions = [ + "lab.some.admin" +] + +[testparent] +name = "Testparent" +permissions = [ + "lab.some.write", + "lab.some.read", + "lab.some.disclose", +] diff --git a/examples/docker/integration/config_b/users.toml b/examples/docker/integration/config_b/users.toml new file mode 100644 index 0000000..46c4a67 --- /dev/null +++ b/examples/docker/integration/config_b/users.toml @@ -0,0 +1,11 @@ +[Testuser] +# Define them in roles.toml as well +roles = [] + +# If two or more users want to use the same machine at once the higher prio +# wins +priority = 0 + +# You can add whatever random data you want. +# It will get stored in the `kv` field in UserData. +noot = "noot!" diff --git a/examples/docker/integration/docker-compose.yaml b/examples/docker/integration/docker-compose.yaml new file mode 100644 index 0000000..94118a0 --- /dev/null +++ b/examples/docker/integration/docker-compose.yaml @@ -0,0 +1,26 @@ +version: "3.8" +services: + bffh-a: + image: registry.gitlab.com/fabinfra/fabaccess/bffh:dev-latest + command: ["sh", "-c", "diflouroborane -c /etc/bffh/bffh.dhall --load=/etc/bffh; diflouroborane -c /etc/bffh/bffh.dhall"] + volumes: + # generate a sample config.toml by running "docker run registry.gitlab.com/fabinfra/fabaccess/bffh:dev-latest --print-default > examples/config.toml" from the project root. You may have to delete the ipv6 listen section. + - "./config_a:/etc/bffh" + links: + - mqtt-a + mqtt-a: + image: eclipse-mosquitto + bffh-b: + image: registry.gitlab.com/fabinfra/fabaccess/bffh:dev-latest + command: ["sh", "-c", "diflouroborane -c /etc/bffh/bffh.dhall --load=/etc/bffh; diflouroborane -c /etc/bffh/bffh.dhall"] + volumes: + # generate a sample config.toml by running "docker run registry.gitlab.com/fabinfra/fabaccess/bffh:dev-latest --print-default > examples/config.toml" from the project root. You may have to delete the ipv6 listen section. + - "./config_b:/etc/bffh" + links: + - mqtt-b + mqtt-b: + image: eclipse-mosquitto + + test-manager: + image: debian + tty: true \ No newline at end of file