本文整理汇总了Golang中github.com/cloudfoundry-incubator/cf-test-helpers/workflowhelpers.AsUser函数的典型用法代码示例。如果您正苦于以下问题:Golang AsUser函数的具体用法?Golang AsUser怎么用?Golang AsUser使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AsUser函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Destroy
func (b ServiceBroker) Destroy() {
workflowhelpers.AsUser(b.TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), func() {
Expect(cf.Cf("purge-service-offering", b.Service.Name, "-f").Wait(Config.DefaultTimeoutDuration())).To(Exit(0))
})
b.Delete()
Expect(cf.Cf("delete", b.Name, "-f", "-r").Wait(Config.DefaultTimeoutDuration())).To(Exit(0))
}
示例2: PublicizePlan
func (b ServiceBroker) PublicizePlan(url string) {
jsonMap := make(map[string]bool)
jsonMap["public"] = true
planJson, _ := json.Marshal(jsonMap)
workflowhelpers.AsUser(b.TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), func() {
Expect(cf.Cf("curl", url, "-X", "PUT", "-d", string(planJson)).Wait(Config.DefaultTimeoutDuration())).To(Exit(0))
})
}
示例3: Delete
func (b ServiceBroker) Delete() {
workflowhelpers.AsUser(b.TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), func() {
Expect(cf.Cf("delete-service-broker", b.Name, "-f").Wait(Config.DefaultTimeoutDuration())).To(Exit(0))
brokers := cf.Cf("service-brokers").Wait(Config.DefaultTimeoutDuration())
Expect(brokers).To(Exit(0))
Expect(brokers.Out.Contents()).ToNot(ContainSubstring(b.Name))
})
}
示例4: LastPageUsageEvents
func LastPageUsageEvents(TestSetup *workflowhelpers.ReproducibleTestSuiteSetup) []AppUsageEvent {
var response AppUsageEvents
workflowhelpers.AsUser(TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), func() {
workflowhelpers.ApiRequest("GET", "/v2/app_usage_events?order-direction=desc&page=1", &response, Config.DefaultTimeoutDuration())
})
return response.Resources
}
示例5: createDummyBuildpack
func createDummyBuildpack() string {
buildpack := random_name.CATSRandomName("BPK")
buildpackZip := assets.NewAssets().SecurityGroupBuildpack
workflowhelpers.AsUser(TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), func() {
Expect(cf.Cf("create-buildpack", buildpack, buildpackZip, "999").Wait(Config.DefaultTimeoutDuration())).To(Exit(0))
})
return buildpack
}
示例6: createSecurityGroup
func createSecurityGroup(allowedDestinations ...Destination) string {
file, _ := ioutil.TempFile(os.TempDir(), "CATS-sg-rules")
defer os.Remove(file.Name())
Expect(json.NewEncoder(file).Encode(allowedDestinations)).To(Succeed())
rulesPath := file.Name()
securityGroupName := random_name.CATSRandomName("SG")
workflowhelpers.AsUser(TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), func() {
Expect(cf.Cf("create-security-group", securityGroupName, rulesPath).Wait(Config.DefaultTimeoutDuration())).To(Exit(0))
})
return securityGroupName
}
示例7: lastAppUsageEvent
func lastAppUsageEvent(appName string, state string) (bool, AppUsageEvent) {
var response AppUsageEvents
workflowhelpers.AsUser(TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), func() {
workflowhelpers.ApiRequest("GET", "/v2/app_usage_events?order-direction=desc&page=1&results-per-page=150", &response, Config.DefaultTimeoutDuration())
})
for _, event := range response.Resources {
if event.Entity.AppName == appName && event.Entity.State == state {
return true, event
}
}
return false, AppUsageEvent{}
}
示例8: createServiceBroker
func createServiceBroker(brokerName, brokerAppName, serviceName string) {
serviceBrokerAsset := assets.NewAssets().ServiceBroker
PushApp(brokerAppName, serviceBrokerAsset, Config.GetRubyBuildpackName(), Config.GetAppsDomain(), Config.CfPushTimeoutDuration(), DEFAULT_MEMORY_LIMIT)
initiateBrokerConfig(serviceName, brokerAppName)
brokerUrl := helpers.AppUri(brokerAppName, "", Config)
workflowhelpers.AsUser(TestSetup.AdminUserContext(), TestSetup.ShortTimeout(), func() {
session := cf.Cf("create-service-broker", brokerName, "user", "password", brokerUrl)
Expect(session.Wait(Config.DefaultTimeoutDuration())).To(Exit(0))
session = cf.Cf("enable-service-access", serviceName)
Expect(session.Wait(Config.DefaultTimeoutDuration())).To(Exit(0))
})
}
示例9: getCfHomeConfig
func getCfHomeConfig() *cfHomeConfig {
myCfHomeConfig := &cfHomeConfig{}
workflowhelpers.AsUser(TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), 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
}
示例10: PublicizePlans
func (b ServiceBroker) PublicizePlans() {
url := fmt.Sprintf("/v2/services?inline-relations-depth=1&q=label:%s", b.Service.Name)
var session *Session
workflowhelpers.AsUser(b.TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), func() {
session = cf.Cf("curl", url).Wait(Config.DefaultTimeoutDuration())
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)
}
}
}
}
}
示例11: unbindSecurityGroup
func unbindSecurityGroup(securityGroupName, orgName, spaceName string) {
By("Unapplying security group")
workflowhelpers.AsUser(TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), func() {
Expect(cf.Cf("unbind-security-group", securityGroupName, orgName, spaceName).Wait(Config.DefaultTimeoutDuration())).To(Exit(0))
})
}
示例12:
workflowhelpers.AsUser(TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), func() {
BuildpackName = CATSRandomName("BPK")
appName = CATSRandomName("APP")
var err error
tmpdir, err = ioutil.TempDir("", "stack")
Expect(err).ToNot(HaveOccurred())
appPath, err = ioutil.TempDir(tmpdir, "matching-app")
Expect(err).ToNot(HaveOccurred())
buildpackPath, err = ioutil.TempDir(tmpdir, "matching-buildpack")
Expect(err).ToNot(HaveOccurred())
buildpackArchivePath = path.Join(buildpackPath, "buildpack.zip")
archive_helpers.CreateZipArchive(buildpackArchivePath, []archive_helpers.ArchiveFile{
{
Name: "bin/compile",
Body: `#!/usr/bin/env bash
sleep 5
cat /etc/lsb-release
sleep 10
`,
},
{
Name: "bin/detect",
Body: fmt.Sprintf(`#!/bin/bash
if [ -f "${1}/%s" ]; then
echo Simple
else
echo no
exit 1
fi
`, matchingFilename(appName)),
},
{
Name: "bin/release",
Body: `#!/usr/bin/env bash
cat <<EOF
---
config_vars:
PATH: bin:/usr/local/bin:/usr/bin:/bin
FROM_BUILD_PACK: "yes"
default_process_types:
web: while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; echo -e "\$(cat /etc/lsb-release)"; } | nc -l \$PORT; done
EOF
`,
},
})
_, err = os.Create(path.Join(appPath, matchingFilename(appName)))
Expect(err).ToNot(HaveOccurred())
_, err = os.Create(path.Join(appPath, "some-file"))
Expect(err).ToNot(HaveOccurred())
createBuildpack := cf.Cf("create-buildpack", BuildpackName, buildpackArchivePath, "0").Wait(Config.DefaultTimeoutDuration())
Expect(createBuildpack).Should(Exit(0))
Expect(createBuildpack).Should(Say("Creating"))
Expect(createBuildpack).Should(Say("OK"))
Expect(createBuildpack).Should(Say("Uploading"))
Expect(createBuildpack).Should(Say("OK"))
})
示例13: deleteBuildpack
func deleteBuildpack(buildpack string) {
workflowhelpers.AsUser(TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), func() {
Expect(cf.Cf("delete-buildpack", buildpack, "-f").Wait(Config.DefaultTimeoutDuration())).To(Exit(0))
})
}
示例14:
var output []byte
var oldServiceName string
var oldPlanName string
BeforeEach(func() {
broker = NewServiceBroker(
random_name.CATSRandomName("BRKR"),
assets.NewAssets().ServiceBroker,
TestSetup,
)
TestSetup.RegularUserContext().TargetSpace()
broker.Push(Config)
broker.Configure()
workflowhelpers.AsUser(TestSetup.AdminUserContext(), TestSetup.ShortTimeout(), func() {
broker.Create()
})
})
Describe("Updating the catalog", func() {
BeforeEach(func() {
broker.PublicizePlans()
})
It("updates the broker and sees catalog changes", func() {
// Confirming plans show up in the marketplace for regular user
plans := cf.Cf("marketplace").Wait(Config.DefaultTimeoutDuration())
Expect(plans).To(Exit(0))
Expect(plans).To(Say(broker.Service.Name))
Expect(plans).To(Say(broker.SyncPlans[0].Name))
示例15:
},
{
Name: "bin/release",
Body: `#!/usr/bin/env bash
exit 1
`,
},
})
return buildpackArchivePath
}
var fetchEnvironmentVariables = func(groupType string) map[string]string {
var session *Session
workflowhelpers.AsUser(TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), func() {
session = cf.Cf("curl", fmt.Sprintf("/v2/config/environment_variable_groups/%s", groupType)).Wait(Config.DefaultTimeoutDuration())
Expect(session).To(Exit(0))
})
var envMap map[string]string
err := json.Unmarshal(session.Out.Contents(), &envMap)
Expect(err).NotTo(HaveOccurred())
return envMap
}
var marshalUpdatedEnv = func(envMap map[string]string) []byte {
jsonObj, err := json.Marshal(envMap)
Expect(err).NotTo(HaveOccurred())
return jsonObj
}