From 8ce61c8f161f7868367e2a4a872554fa8260cf97 Mon Sep 17 00:00:00 2001 From: Guillaume Giamarchi Date: Mon, 22 May 2017 15:25:30 +0200 Subject: [PATCH] Add test for ssh.insert_key = false --- samples/06_insert_key_false/Vagrantfile | 30 +++++++++++++++++++++++++ samples/06_insert_key_false/ssh_key | 27 ++++++++++++++++++++++ samples/tests.bats | 18 +++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 samples/06_insert_key_false/Vagrantfile create mode 100644 samples/06_insert_key_false/ssh_key diff --git a/samples/06_insert_key_false/Vagrantfile b/samples/06_insert_key_false/Vagrantfile new file mode 100644 index 0000000..c06f065 --- /dev/null +++ b/samples/06_insert_key_false/Vagrantfile @@ -0,0 +1,30 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure('2') do |config| + + config.ssh.username = ENV['OS_SSH_USERNAME'] + config.ssh.insert_key = false + config.ssh.private_key_path = './ssh_key' + + config.vm.provider :openstack do |os| + os.server_name = '06_insert_key_false' + os.openstack_auth_url = ENV['OS_AUTH_URL'] + os.tenant_name = ENV['OS_TENANT_NAME'] + os.username = ENV['OS_USERNAME'] + os.password = ENV['OS_PASSWORD'] + os.region = ENV['OS_REGION_NAME'] + os.floating_ip_pool = ENV['OS_FLOATING_IP_POOL'] + os.floating_ip_pool_always_allocate = true + os.flavor = ENV['OS_FLAVOR'] + os.image = ENV['OS_IMAGE'] + os.networks << ENV['OS_NETWORK'] + os.user_data = """#!/bin/bash + + set -x + mkdir -p /home/ubuntu/.ssh + echo '' >> /home/ubuntu/.ssh/authorized_keys + echo 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDENu9FoAOxYgz2aUc7zF4ODbdLKsSS864AMrSlOnbIrcMuHgsgz23fMIIEoiaw22ztH2CcO5pwCqfEPpQGXhaenv51i6/m8/rGy9sb201eIPDpOd/5BOjK0Da/w3hbfeMcq9VJhhq3C7J04Ds9BVrHBlYDeWN1bZQBt+ut8jWxgnR5hUBJopKgl/ypDP6vLZ2lyCU7MZVbPKwZJKei2UdLGtPrkkBcdSsfj9I+4cBVC7bYA8eEXTtvV44iYPrqQ9Oa1GIFD3clCUBUccI3SGG4RQ8E+Rzmbp1LnKM4tIV3iOMkwumtyaehJjzsYYdzl3H3g85sjliEhMvLKMZyZknv vagrant' >> /home/ubuntu/.ssh/authorized_keys + """ + end +end diff --git a/samples/06_insert_key_false/ssh_key b/samples/06_insert_key_false/ssh_key new file mode 100644 index 0000000..6d05924 --- /dev/null +++ b/samples/06_insert_key_false/ssh_key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAxDbvRaADsWIM9mlHO8xeDg23SyrEkvOuADK0pTp2yK3DLh4L +IM9t3zCCBKImsNts7R9gnDuacAqnxD6UBl4Wnp7+dYuv5vP6xsvbG9tNXiDw6Tnf ++QToytA2v8N4W33jHKvVSYYatwuydOA7PQVaxwZWA3ljdW2UAbfrrfI1sYJ0eYVA +SaKSoJf8qQz+ry2dpcglOzGVWzysGSSnotlHSxrT65JAXHUrH4/SPuHAVQu22APH +hF07b1eOImD66kPTmtRiBQ93JQlAVHHCN0hhuEUPBPkc5m6dS5yjOLSFd4jjJMLp +rcmnoSY87GGHc5dx94PObI5YhITLyyjGcmZJ7wIDAQABAoIBABoP9e44l+T60h/0 +0epmdePF/J+2WY/vYCBUm9wKjPaQ5gj9IptEEiMALXTyGNOLAcfpUArQe+3/7FLL +wRurabO+CKySVlYF+DxpnXvwwDENjRJdhptsBIPT7kHAc/8rFHydcmImtuuzWQvf +MN8lE+61r70cZZKWcH9d76cWMf2Wy4Ut96APBbhwg5+9z5rWVSdLmLplboNKLi6B +/u25dhddk5RelVC7anL7YV8wNBOKgTAFedUee+sW8dotIBTUxQS8rUSdV1Ogz2H/ +VsDW5w/ZfHdeoD5QD2up2oj2LhZ9FSTrTvYP+QVNgkecoF+jJ7bE3I7cZ6hNrVSV +XXYiD7ECgYEA+QCpqKF3D1fB1fGSru0B7dgc4APJFdFwD+JJTJkwLFnTJpjsPmj4 +9PEb+xySeSrL7yw/8aCTRKgKUqVE8dEPPIm9tYqdBeqW9pCJVZAASm/9TTYxIdGH +DEJjTTCXBKGJhAioyeizLlOKSTuktsxKtMH8fbUqa83hPYPv5F6qsTcCgYEAybqD +KslLT05qzwr0lNlgLlRHT4J0JYcDtSlpeTgON3lGLce/dIRUVBuEvWKM0mvXmBKd +snbwbdYRmAiJC3tYeQagzgZTJ0vpNyBCKCBsxB9qeqTIhYI8aubHV+PN5K/onsdk +gF2SfI80JxAzLyoQNNCzH8n6Pr3zpUSVmz896QkCgYAZZizoK5g2c3AtP5gDyd9B +gKLpYtl3JUb2B9IMQy/7xinYrQ6kCxch/Roqki6Kt4fX3L6lCgkbnrx2067lr7qL +JU25n+sGeHhvrCymEqtE7Il8/8MhPPs2j+sLK6Kr8UJSuoNlHRxx5Emd0LyrfMk+ +CO+Vbw5lsrmACd5FgDaPHwKBgQCqpJl8QhbwmTcEuRG4MEGKL0S7X3D8pb9fKg7M +ubxc9LuG0meEGsRy+WxJ/+l7vjn7rBO1+aLcZq8vWlkDW221wwOYBAWnQjGfriwI +YZVgOesKoAX32fldvKZ4FH4Aq0UtuyGq7HyT3VeSi8OgbAaVhs1fYK3NEUXfUar0 +ToUCcQKBgQDCbZZPh2nQKZlTssMNeCWiRkInJkcnzJxGjlAyxN+Wz3UT6VfiYIxA +A/ogm7fsppbIsGh2cl38J6lCcSsWCgu2rNVvuOV8qNjHY8jeQkxZQzmdZgyn41n5 +5W5SQj1DcpzVOH6LGWgBo1FctLzX6j6EXNCgAVVaCRLU+8jHIDtZmw== +-----END RSA PRIVATE KEY----- diff --git a/samples/tests.bats b/samples/tests.bats index be265c8..30abeb9 100755 --- a/samples/tests.bats +++ b/samples/tests.bats @@ -254,3 +254,21 @@ teardown() { flush_out [ "$status" -eq 0 ] } + +@test "06 - With config.ssh.insert_key = false" { + title "$BATS_TEST_DESCRIPTION" + + export VAGRANT_CWD=$BATS_TEST_DIRNAME/06_insert_key_false + + run bundle exec vagrant up + flush_out + [ "$status" -eq 0 ] + + run bundle exec vagrant ssh -c "true" + flush_out + [ "$status" -eq 0 ] + + run bundle exec vagrant destroy + flush_out + [ "$status" -eq 0 ] +}