github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/acceptance/openstack/apigw/v2/app_auth_test.go (about) 1 package v2 2 3 import ( 4 "os" 5 "testing" 6 7 "github.com/opentelekomcloud/gophertelekomcloud/acceptance/clients" 8 "github.com/opentelekomcloud/gophertelekomcloud/acceptance/tools" 9 "github.com/opentelekomcloud/gophertelekomcloud/openstack/apigw/v2/api" 10 "github.com/opentelekomcloud/gophertelekomcloud/openstack/apigw/v2/app" 11 "github.com/opentelekomcloud/gophertelekomcloud/openstack/apigw/v2/app_auth" 12 "github.com/opentelekomcloud/gophertelekomcloud/openstack/apigw/v2/group" 13 th "github.com/opentelekomcloud/gophertelekomcloud/testhelper" 14 ) 15 16 func TestAppAuthLifecycle(t *testing.T) { 17 gatewayID := os.Getenv("GATEWAY_ID") 18 19 if gatewayID == "" { 20 t.Skip("`GATEWAY_ID`needs to be defined") 21 } 22 23 client, err := clients.NewAPIGWClient() 24 th.AssertNoErr(t, err) 25 26 _, createAppResp := CreateApp(client, t, gatewayID) 27 28 t.Cleanup(func() { 29 th.AssertNoErr(t, app.Delete(client, gatewayID, createAppResp.ID)) 30 }) 31 32 groupResp := CreateGroup(client, t, gatewayID) 33 t.Cleanup(func() { 34 th.AssertNoErr(t, group.Delete(client, gatewayID, groupResp.ID)) 35 }) 36 37 groupID := groupResp.ID 38 39 _, createApiResp := CreateAPI(client, t, gatewayID, groupID) 40 41 t.Cleanup(func() { 42 th.AssertNoErr(t, api.Delete(client, gatewayID, createApiResp.ID)) 43 }) 44 45 createAuthResp, err := app_auth.Create(client, app_auth.CreateAuthOpts{ 46 GatewayID: gatewayID, 47 EnvID: "DEFAULT_ENVIRONMENT_RELEASE_ID", 48 AppIDs: []string{ 49 createAppResp.ID, 50 }, 51 ApiIDs: []string{ 52 createApiResp.ID, 53 }, 54 }) 55 th.AssertNoErr(t, err) 56 57 t.Cleanup(func() { 58 th.AssertNoErr(t, app_auth.Delete(client, gatewayID, createAuthResp[0].ID)) 59 }) 60 61 tools.PrintResource(t, createAuthResp) 62 63 }