From 0aa284d0446751df438b25baf7bcad2370fd1788 Mon Sep 17 00:00:00 2001 From: Hidde Beydals Date: Fri, 17 Jan 2020 18:54:41 +0100 Subject: [PATCH] e2e: test SSH key generation --- test/e2e/21_ssh_key_generation.bats | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/e2e/21_ssh_key_generation.bats diff --git a/test/e2e/21_ssh_key_generation.bats b/test/e2e/21_ssh_key_generation.bats new file mode 100644 index 0000000000..025e4c8549 --- /dev/null +++ b/test/e2e/21_ssh_key_generation.bats @@ -0,0 +1,33 @@ +#!/usr/bin/env bats + +function setup() { + load lib/env + load lib/install + load lib/poll + load lib/defer + + kubectl create namespace "$FLUX_NAMESPACE" + + # Installing Flux with the defaults _without_ installing the git + # server (which generates an SSH key used by the server and Flux) + # will cause Flux to generate an SSH key. + install_flux_with_fluxctl +} + +@test "SSH key is generated" { + run fluxctl identity --k8s-fwd-ns "$FLUX_NAMESPACE" + [ "$status" -eq 0 ] + [ "$output" != "" ] + + fingerprint=$(echo "$output" | ssh-keygen -E md5 -lf - | awk '{ print $2 }') + [ "$fingerprint" = "MD5:$(fluxctl identity -l --k8s-fwd-ns "$FLUX_NAMESPACE")" ] +} + +function teardown() { + run_deferred + # Although the namespace delete below takes care of removing most Flux + # elements, the global resources will not be removed without this. + uninstall_flux_with_fluxctl + # Removing the namespace also takes care of removing Flux and gitsrv. + kubectl delete namespace "$FLUX_NAMESPACE" +}