func TestUsers(t *testing.T) { params := utils.GetGlobalConfig() user := utils.GetGlobalConfig() user.UserName, user.Password = "******", "test" user.AppName = params.AppName utils.Execute(t, authRegisterCmd, user, false, "") usersListTest(t, params, user) }
func authCancel(t *testing.T, params *utils.DeisTestConfig) { utils.Execute(t, authCancelCmd, params, false, "Account cancelled") user := utils.GetGlobalConfig() // Admins can delete other users. user.UserName, user.Password = "******", "test" utils.Execute(t, authRegisterCmd, user, false, "") admin := utils.GetGlobalConfig() utils.Execute(t, authLoginCmd, admin, false, "") utils.Execute(t, authCancelAdminCmd, user, false, "Account cancelled") // Make sure the user's config was not purged after auth:cancel --username utils.Execute(t, authWhoamiCmd, admin, false, "You are "+admin.UserName) }
func authCancel(t *testing.T, params *utils.DeisTestConfig) { utils.Execute(t, authCancelCmd, params, false, "Account cancelled") user := utils.GetGlobalConfig() // Admins can delete other users. user.UserName, user.Password = "******", "test" utils.Execute(t, authRegisterCmd, user, false, "") admin := utils.GetGlobalConfig() utils.Execute(t, authLoginCmd, admin, false, "") utils.Execute(t, authCancelAdminCmd, user, false, "Account cancelled") // Make sure the admin is still logged in utils.CheckList(t, authWhoamiCmd, admin, admin.UserName, false) }
func appsSetup(t *testing.T) *utils.DeisTestConfig { cfg := utils.GetGlobalConfig() cfg.AppName = "appssample" utils.Execute(t, authLoginCmd, cfg, false, "") utils.Execute(t, gitCloneCmd, cfg, false, "") return cfg }
// TestSmokeExampleApp updates a Vagrant instance to run Deis with docker // containers using the current codebase, then registers a user, pushes an // example app, and looks for "Powered by Deis" in the HTTP response. func TestSmokeExampleApp(t *testing.T) { cfg := utils.GetGlobalConfig() for _, tt := range smokeTests { runTest(t, &tt, cfg) } }
func configSetup(t *testing.T) *utils.DeisTestConfig { cfg := utils.GetGlobalConfig() cfg.AppName = "configsample" utils.Execute(t, authLoginCmd, cfg, false, "") utils.Execute(t, gitCloneCmd, cfg, false, "") if err := utils.Chdir(cfg.ExampleApp); err != nil { t.Fatal(err) } utils.Execute(t, appsCreateCmd, cfg, false, "") // ensure envvars with spaces work fine on `git push` // https://github.com/deis/deis/issues/2477 utils.Execute(t, configSet3Cmd, cfg, false, "the Deis team") // ensure custom buildpack URLs are in order url := buildpacks[cfg.ExampleApp] if url == "" { // set url anyway so example-dockerfile apps create a build url = buildpacks["example-go"] } cmd := strings.Replace(configSetBuildpackCmd, "$BUILDPACK_URL", url, 1) utils.Execute(t, cmd, cfg, false, url) utils.Execute(t, gitPushCmd, cfg, false, "") utils.CurlApp(t, *cfg) utils.CheckList(t, "run env --app={{.AppName}}", cfg, "DEIS_APP", false) utils.CheckList(t, "run env --app={{.AppName}}", cfg, "DEIS_RELEASE", false) if err := utils.Chdir(".."); err != nil { t.Fatal(err) } return cfg }
func TestGlobal(t *testing.T) { params := utils.GetGlobalConfig() cookieTest(t, params) utils.Execute(t, authRegisterCmd, params, false, "") utils.Execute(t, keysAddCmd, params, false, "") utils.Execute(t, clustersCreateCmd, params, false, "") }
func TestPerms(t *testing.T) { params := permsSetup(t) user := utils.GetGlobalConfig() user.UserName, user.Password = "******", "test1" user.AppName = params.AppName utils.Execute(t, authRegisterCmd, user, false, "") permsCreateAppTest(t, params, user) permsDeleteAppTest(t, params, user) permsCreateAdminTest(t, params) permsDeleteAdminTest(t, params) utils.AppsDestroyTest(t, params) }
func authRegenerateTest(t *testing.T) { params := utils.GetGlobalConfig() regenCmd := authRegenerateUsrCmd loginCmd := authLoginCmd utils.Execute(t, loginCmd, params, false, "") utils.Execute(t, authRegenerateCmd, params, false, "") utils.Execute(t, loginCmd, params, false, "") utils.Execute(t, regenCmd, params, false, "") utils.Execute(t, checkTokenCmd, params, true, "401 UNAUTHORIZED") utils.Execute(t, loginCmd, params, false, "") utils.Execute(t, authRegenerateAllCmd, params, false, "") utils.Execute(t, checkTokenCmd, params, true, "401 UNAUTHORIZED") }
func appsTransferTest(t *testing.T, params *utils.DeisTestConfig) { user := utils.GetGlobalConfig() user.UserName, user.Password = "******", "test" user.AppName = "transfer-test" user.NewOwner = params.UserName utils.Execute(t, authRegisterCmd, user, false, "") utils.Execute(t, authLoginCmd, user, false, "") utils.Execute(t, appsCreateCmdNoRemote, user, false, "") utils.Execute(t, appsTransferCmd, user, false, "") utils.Execute(t, appsInfoCmd, user, true, "403 FORBIDDEN") utils.Execute(t, authLoginCmd, params, false, "") params.AppName = user.AppName utils.CheckList(t, appsInfoCmd, params, params.UserName, false) }
func psSetup(t *testing.T) *utils.DeisTestConfig { cfg := utils.GetGlobalConfig() cfg.AppName = "pssample" utils.Execute(t, authLoginCmd, cfg, false, "") utils.Execute(t, gitCloneCmd, cfg, false, "") if err := utils.Chdir(cfg.ExampleApp); err != nil { t.Fatal(err) } utils.Execute(t, appsCreateCmd, cfg, false, "") utils.Execute(t, gitPushCmd, cfg, false, "") if err := utils.Chdir(".."); err != nil { t.Fatal(err) } return cfg }
func buildSetup(t *testing.T) *utils.DeisTestConfig { cfg := utils.GetGlobalConfig() cfg.AppName = "buildsample" utils.Execute(t, authLoginCmd, cfg, false, "") utils.Execute(t, gitCloneCmd, cfg, false, "") if err := utils.Chdir(cfg.ExampleApp); err != nil { t.Fatal(err) } utils.Execute(t, appsCreateCmd, cfg, false, "") utils.Execute(t, gitPushCmd, cfg, false, "") utils.Execute(t, "git commit --allow-empty -m bump", cfg, false, "") utils.Execute(t, gitPushCmd, cfg, false, "") if err := utils.Chdir(".."); err != nil { t.Fatal(err) } return cfg }
func configSetup(t *testing.T) *utils.DeisTestConfig { cfg := utils.GetGlobalConfig() cfg.AppName = "configsample" utils.Execute(t, authLoginCmd, cfg, false, "") utils.Execute(t, gitCloneCmd, cfg, false, "") if err := utils.Chdir(cfg.ExampleApp); err != nil { t.Fatal(err) } utils.Execute(t, appsCreateCmd, cfg, false, "") // ensure envvars with spaces work fine on `git push` // https://github.com/deis/deis/issues/2477 utils.Execute(t, configSet3Cmd, cfg, false, "the Deis team") utils.Execute(t, gitPushCmd, cfg, false, "") utils.CurlWithFail(t, cfg, false, "the Deis team") if err := utils.Chdir(".."); err != nil { t.Fatal(err) } return cfg }
func clustersSetup(t *testing.T) *utils.DeisTestConfig { cfg := utils.GetGlobalConfig() cfg.ClusterName = "devtest" utils.Execute(t, authLoginCmd, cfg, false, "") return cfg }
func TestGlobal(t *testing.T) { params := utils.GetGlobalConfig() utils.Execute(t, authRegisterCmd, params, false, "") clientTest(t, params) utils.Execute(t, keysAddCmd, params, false, "") }
// Requires a ~/.ssh/deis-testkey to be set up: // $ ssh-keygen -q -t rsa -f ~/.ssh/deiskey -N '' -C deiskey func keysSetup(t *testing.T) *utils.DeisTestConfig { cfg := utils.GetGlobalConfig() utils.Execute(t, authLoginCmd, cfg, false, "") return cfg }
func authSetup(t *testing.T) *utils.DeisTestConfig { user := utils.GetGlobalConfig() user.UserName, user.Password = utils.NewID(), utils.NewID() return user }