From f6d8190e8f62ce239158be8ffeb9ca63432c28b3 Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Mon, 5 May 2014 10:49:02 -0700 Subject: [PATCH] test(crlf): Add test that parses user-data with carriage returns --- initialize/user_data_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/initialize/user_data_test.go b/initialize/user_data_test.go index c24d322..c764eb2 100644 --- a/initialize/user_data_test.go +++ b/initialize/user_data_test.go @@ -29,3 +29,21 @@ func TestParseHeaderCRLF(t *testing.T) { } } } + +func TestParseConfigCRLF(t *testing.T) { + contents := "#cloud-config\r\nhostname: foo\r\nssh_authorized_keys:\r\n - foobar\r\n" + ud, err := ParseUserData(contents) + if err != nil { + t.Fatalf("Failed parsing config: %v", err) + } + + cfg := ud.(CloudConfig) + + if cfg.Hostname != "foo" { + t.Error("Failed parsing hostname from config") + } + + if len(cfg.SSHAuthorizedKeys) != 1 { + t.Error("Parsed incorrect number of SSH keys") + } +}