github.com/gust1n/deis@v0.13.1-0.20141009230754-43ff4d95947b/tests/integration_test.go (about) 1 // +build integration 2 3 package tests 4 5 import ( 6 "os" 7 "os/user" 8 "testing" 9 10 "github.com/deis/deis/tests/utils" 11 ) 12 13 var ( 14 gitCloneCmd = "if [ ! -d {{.ExampleApp}} ] ; then git clone https://github.com/deis/{{.ExampleApp}}.git ; fi" 15 gitRemoveCmd = "git remote remove deis" 16 gitPushCmd = "git push deis master" 17 gitAddCmd = "git add ." 18 gitCommitCmd = "git commit -m fake" 19 ) 20 21 func TestGlobal(t *testing.T) { 22 params := utils.GetGlobalConfig() 23 cookieTest(t, params) 24 utils.Execute(t, authRegisterCmd, params, false, "") 25 utils.Execute(t, keysAddCmd, params, false, "") 26 utils.Execute(t, clustersCreateCmd, params, false, "") 27 } 28 29 func cookieTest(t *testing.T, params *utils.DeisTestConfig) { 30 // Regression test for https://github.com/deis/deis/pull/1136 31 // Ensure that cookies are cleared on auth:register and auth:cancel 32 user, err := user.Current() 33 if err != nil { 34 t.Fatal(err) 35 } 36 cookieJar := user.HomeDir + "/.deis/cookies.txt" 37 utils.Execute(t, authRegisterCmd, params, false, "") 38 cmd := "cat " + cookieJar 39 utils.CheckList(t, cmd, params, "csrftoken", false) 40 utils.CheckList(t, cmd, params, "sessionid", false) 41 info, err := os.Stat(cookieJar) 42 if err != nil { 43 t.Fatal(err) 44 } 45 mode := info.Mode().String() 46 expected := "-rw-------" 47 if mode != expected { 48 t.Fatalf("%s has wrong mode:\n current: %s\n expected: %s", 49 cookieJar, mode, expected) 50 } 51 utils.AuthCancel(t, params) 52 utils.CheckList(t, cmd, params, "csrftoken", true) 53 utils.CheckList(t, cmd, params, "sessionid", true) 54 }