本文整理匯總了Golang中github.com/cloudfoundry-incubator/cf-test-helpers/cf.AsUser函數的典型用法代碼示例。如果您正苦於以下問題:Golang AsUser函數的具體用法?Golang AsUser怎麽用?Golang AsUser使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了AsUser函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Destroy
func (b ServiceBroker) Destroy() {
cf.AsUser(b.context.AdminUserContext(), DEFAULT_TIMEOUT, func() {
Expect(cf.Cf("purge-service-offering", b.Service.Name, "-f").Wait(DEFAULT_TIMEOUT)).To(Exit(0))
})
b.Delete()
Expect(cf.Cf("delete", b.Name, "-f", "-r").Wait(DEFAULT_TIMEOUT)).To(Exit(0))
}
示例2: Setup
func (context *ConfiguredContext) Setup() {
cf.AsUser(context.AdminUserContext(), func() {
definition := quotaDefinition{
Name: context.quotaDefinitionName,
TotalServices: "100",
TotalRoutes: "1000",
MemoryLimit: "10G",
NonBasicServicesAllowed: true,
}
args := []string{
"create-quota",
context.quotaDefinitionName,
"-m", definition.MemoryLimit,
"-r", definition.TotalRoutes,
"-s", definition.TotalServices,
}
if definition.NonBasicServicesAllowed {
args = append(args, "--allow-paid-service-plans")
}
Expect(cf.Cf(args...).Wait(CF_API_TIMEOUT)).To(Exit(0))
createUserSession := cf.Cf("create-user", context.regularUserUsername, context.regularUserPassword)
createUserSession.Wait(CF_API_TIMEOUT)
if createUserSession.ExitCode() != 0 {
Expect(createUserSession.Out).To(Say("scim_resource_already_exists"))
}
Expect(cf.Cf("create-org", context.organizationName).Wait(CF_API_TIMEOUT)).To(Exit(0))
Expect(cf.Cf("set-quota", context.organizationName, definition.Name).Wait(CF_API_TIMEOUT)).To(Exit(0))
})
}
示例3: Setup
func (context *ConfiguredContext) Setup() {
cf.AsUser(context.AdminUserContext(), func() {
channel := cf.Cf("create-user", context.regularUserUsername, context.regularUserPassword)
select {
case <-channel.Out.Detect("OK"):
case <-channel.Out.Detect("scim_resource_already_exists"):
case <-time.After(ScaledTimeout(10 * time.Second)):
Fail("failed to create user")
}
definition := quotaDefinition{
Name: context.quotaDefinitionName,
TotalServices: 100,
TotalRoutes: 1000,
MemoryLimit: 10240,
NonBasicServicesAllowed: true,
}
definitionPayload, err := json.Marshal(definition)
Expect(err).ToNot(HaveOccurred())
var response cf.GenericResource
cf.ApiRequest("POST", "/v2/quota_definitions", &response, string(definitionPayload))
context.quotaDefinitionGUID = response.Metadata.Guid
Eventually(cf.Cf("create-org", context.organizationName), ScaledTimeout(60*time.Second)).Should(Exit(0))
Eventually(cf.Cf("set-quota", context.organizationName, definition.Name), ScaledTimeout(60*time.Second)).Should(Exit(0))
})
}
示例4: Teardown
func (c *context) Teardown() {
userOrg := c.RegularUserContext().Org
cf.RestoreUserContext(c.RegularUserContext(), c.shortTimeout, c.originalCfHomeDir, c.currentCfHomeDir)
cf.AsUser(c.AdminUserContext(), c.shortTimeout, func() {
runner.NewCmdRunner(cf.Cf("delete-user", "-f", c.regularUserUsername), c.longTimeout).Run()
// delete-space does not provide an org flag, so we must target the Org first
runner.NewCmdRunner(cf.Cf("target", "-o", userOrg), c.longTimeout).Run()
runner.NewCmdRunner(cf.Cf("delete-space", "-f", c.spaceName), c.longTimeout).Run()
if !c.useExistingOrg {
runner.NewCmdRunner(cf.Cf("delete-org", "-f", c.organizationName), c.longTimeout).Run()
cf.ApiRequest(
"DELETE",
"/v2/quota_definitions/"+c.quotaDefinitionGUID+"?recursive=true",
nil,
c.ShortTimeout(),
)
}
if c.config.CreatePermissiveSecurityGroup {
runner.NewCmdRunner(cf.Cf("delete-security-group", "-f", c.securityGroupName), c.shortTimeout).Run()
}
})
}
示例5: PublicizePlan
func (b ServiceBroker) PublicizePlan(url string) {
jsonMap := make(map[string]bool)
jsonMap["public"] = true
planJson, _ := json.Marshal(jsonMap)
cf.AsUser(b.context.AdminUserContext(), DEFAULT_TIMEOUT, func() {
Expect(cf.Cf("curl", url, "-X", "PUT", "-d", string(planJson)).Wait(DEFAULT_TIMEOUT)).To(Exit(0))
})
}
示例6: deleteServiceBroker
func deleteServiceBroker(brokerName string) {
config = helpers.LoadConfig()
context := helpers.NewContext(config)
cf.AsUser(context.AdminUserContext(), context.ShortTimeout(), func() {
responseBuffer := cf.Cf("delete-service-broker", brokerName, "-f")
Expect(responseBuffer.Wait(DEFAULT_TIMEOUT)).To(Exit(0))
})
}
示例7: Delete
func (b ServiceBroker) Delete() {
cf.AsUser(b.context.AdminUserContext(), DEFAULT_TIMEOUT, func() {
Expect(cf.Cf("delete-service-broker", b.Name, "-f").Wait(DEFAULT_TIMEOUT)).To(Exit(0))
brokers := cf.Cf("service-brokers").Wait(DEFAULT_TIMEOUT)
Expect(brokers).To(Exit(0))
Expect(brokers.Out.Contents()).ToNot(ContainSubstring(b.Name))
})
}
示例8: lastPageUsageEvents
func lastPageUsageEvents(appName string) []AppUsageEvent {
var response AppUsageEvents
cf.AsUser(context.AdminUserContext(), DEFAULT_TIMEOUT, func() {
cf.ApiRequest("GET", "/v2/app_usage_events?order-direction=desc&page=1", &response, DEFAULT_TIMEOUT)
})
return response.Resources
}
示例9: Setup
func (e *Environment) Setup() {
e.context.Setup()
cf.AsUser(e.context.AdminUserContext(), func() {
setUpSpaceWithUserAccess(e.context.RegularUserContext())
})
e.originalCfHomeDir, e.currentCfHomeDir = cf.InitiateUserContext(e.context.RegularUserContext())
cf.TargetSpace(e.context.RegularUserContext())
}
示例10: Teardown
func (context *ConfiguredContext) Teardown() {
cf.AsUser(context.AdminUserContext(), func() {
Expect(cf.Cf("delete-user", "-f", context.regularUserUsername).Wait(CF_API_TIMEOUT)).To(Exit(0))
if !context.isPersistent {
Expect(cf.Cf("delete-org", "-f", context.organizationName).Wait(CF_API_TIMEOUT)).To(Exit(0))
Expect(cf.Cf("delete-quota", "-f", context.quotaDefinitionName).Wait(CF_API_TIMEOUT)).To(Exit(0))
}
})
}
示例11: lastAppUsageEvent
func lastAppUsageEvent(appName string, state string) (bool, AppUsageEvent) {
var response AppUsageEvents
cf.AsUser(context.AdminUserContext(), DEFAULT_TIMEOUT, func() {
cf.ApiRequest("GET", "/v2/app_usage_events?order-direction=desc&page=1&results-per-page=150", &response, DEFAULT_TIMEOUT)
})
for _, event := range response.Resources {
if event.Entity.AppName == appName && event.Entity.State == state {
return true, event
}
}
return false, AppUsageEvent{}
}
示例12: Teardown
func (context *ConfiguredContext) Teardown() {
cf.AsUser(context.AdminUserContext(), func() {
Eventually(cf.Cf("delete-user", "-f", context.regularUserUsername), ScaledTimeout(60*time.Second)).Should(Exit(0))
if !context.isPersistent {
Eventually(cf.Cf("delete-org", "-f", context.organizationName), ScaledTimeout(60*time.Second)).Should(Exit(0))
cf.ApiRequest(
"DELETE",
"/v2/quota_definitions/"+context.quotaDefinitionGUID+"?recursive=true",
nil,
)
}
})
}
示例13: PublicizePlans
func (b ServiceBroker) PublicizePlans() {
url := fmt.Sprintf("/v2/services?inline-relations-depth=1&q=label:%s", b.Service.Name)
var session *Session
cf.AsUser(b.context.AdminUserContext(), DEFAULT_TIMEOUT, func() {
session = cf.Cf("curl", url).Wait(DEFAULT_TIMEOUT)
Expect(session).To(Exit(0))
})
structure := ServicesResponse{}
json.Unmarshal(session.Out.Contents(), &structure)
for _, service := range structure.Resources {
if service.Entity.Label == b.Service.Name {
for _, plan := range service.Entity.ServicePlans {
if b.HasPlan(plan.Entity.Name) {
b.PublicizePlan(plan.Metadata.Url)
}
}
}
}
}
示例14: getCfHomeConfig
func getCfHomeConfig() *cfHomeConfig {
myCfHomeConfig := &cfHomeConfig{}
cf.AsUser(context.AdminUserContext(), DEFAULT_TIMEOUT, func() {
path := filepath.Join(os.Getenv("CF_HOME"), ".cf", "config.json")
configFile, err := os.Open(path)
if err != nil {
panic(err)
}
decoder := json.NewDecoder(configFile)
err = decoder.Decode(myCfHomeConfig)
if err != nil {
panic(err)
}
})
return myCfHomeConfig
}
示例15: Setup
func (c *context) Setup() {
cf.AsUser(c.AdminUserContext(), c.shortTimeout, func() {
runner.NewCmdRunner(cf.Cf("create-user", c.regularUserUsername, c.regularUserPassword), c.shortTimeout).Run()
if c.useExistingOrg == false {
definition := QuotaDefinition{
Name: c.quotaDefinitionName,
TotalServices: 100,
TotalRoutes: 1000,
MemoryLimit: 10240,
NonBasicServicesAllowed: true,
}
definitionPayload, err := json.Marshal(definition)
gomega.Expect(err).ToNot(gomega.HaveOccurred())
var response cf.GenericResource
cf.ApiRequest("POST", "/v2/quota_definitions", &response, c.shortTimeout, string(definitionPayload))
c.quotaDefinitionGUID = response.Metadata.Guid
runner.NewCmdRunner(cf.Cf("create-org", c.organizationName), c.shortTimeout).Run()
runner.NewCmdRunner(cf.Cf("set-quota", c.organizationName, c.quotaDefinitionName), c.shortTimeout).Run()
}
c.setUpSpaceWithUserAccess(c.RegularUserContext())
if c.config.CreatePermissiveSecurityGroup {
c.createPermissiveSecurityGroup()
}
})
c.originalCfHomeDir, c.currentCfHomeDir = cf.InitiateUserContext(c.RegularUserContext(), c.shortTimeout)
cf.TargetSpace(c.RegularUserContext(), c.shortTimeout)
}