本文整理汇总了Golang中testhelpers/configuration.FakeConfigRepository.Login方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeConfigRepository.Login方法的具体用法?Golang FakeConfigRepository.Login怎么用?Golang FakeConfigRepository.Login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testhelpers/configuration.FakeConfigRepository
的用法示例。
在下文中一共展示了FakeConfigRepository.Login方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestUpdateEndpointWhenUrlIsAlreadyTargeted
func TestUpdateEndpointWhenUrlIsAlreadyTargeted(t *testing.T) {
configRepo := testconfig.FakeConfigRepository{}
configRepo.Delete()
configRepo.Login()
ts, repo := createEndpointRepoForUpdate(configRepo, validApiInfoEndpoint)
defer ts.Close()
org := cf.OrganizationFields{}
org.Name = "my-org"
org.Guid = "my-org-guid"
space := cf.SpaceFields{}
space.Name = "my-space"
space.Guid = "my-space-guid"
config, _ := configRepo.Get()
config.Target = ts.URL
config.AccessToken = "some access token"
config.RefreshToken = "some refresh token"
config.OrganizationFields = org
config.SpaceFields = space
repo.UpdateEndpoint(ts.URL)
assert.Equal(t, config.OrganizationFields, org)
assert.Equal(t, config.SpaceFields, space)
assert.Equal(t, config.AccessToken, "some access token")
assert.Equal(t, config.RefreshToken, "some refresh token")
}
示例2: TestUpdateEndpointWhenUrlIsValidHttpsInfoEndpoint
func TestUpdateEndpointWhenUrlIsValidHttpsInfoEndpoint(t *testing.T) {
configRepo := testconfig.FakeConfigRepository{}
configRepo.Delete()
configRepo.Login()
ts, repo := createEndpointRepoForUpdate(configRepo, validApiInfoEndpoint)
defer ts.Close()
org := cf.OrganizationFields{}
org.Name = "my-org"
org.Guid = "my-org-guid"
space := cf.SpaceFields{}
space.Name = "my-space"
space.Guid = "my-space-guid"
config, _ := configRepo.Get()
config.OrganizationFields = org
config.SpaceFields = space
repo.UpdateEndpoint(ts.URL)
savedConfig := testconfig.SavedConfiguration
assert.Equal(t, savedConfig.AccessToken, "")
assert.Equal(t, savedConfig.AuthorizationEndpoint, "https://login.example.com")
assert.Equal(t, savedConfig.Target, ts.URL)
assert.Equal(t, savedConfig.ApiVersion, "42.0.0")
assert.False(t, savedConfig.HasOrganization())
assert.False(t, savedConfig.HasSpace())
}
示例3: TestUpdateEndpointWhenEndpointReturnsInvalidJson
func TestUpdateEndpointWhenEndpointReturnsInvalidJson(t *testing.T) {
configRepo := testconfig.FakeConfigRepository{}
configRepo.Login()
ts, repo := createEndpointRepoForUpdate(configRepo, invalidJsonResponseApiEndpoint)
defer ts.Close()
_, apiResponse := repo.UpdateEndpoint(ts.URL)
assert.True(t, apiResponse.IsNotSuccessful())
}
示例4: TestUpdateEndpointWhenEndpointReturns404
func TestUpdateEndpointWhenEndpointReturns404(t *testing.T) {
configRepo := testconfig.FakeConfigRepository{}
configRepo.Login()
ts, repo := createEndpointRepoForUpdate(configRepo, func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotFound)
})
defer ts.Close()
_, apiResponse := repo.UpdateEndpoint(ts.URL)
assert.True(t, apiResponse.IsNotSuccessful())
}
示例5: TestUpdateEndpointWhenUrlIsMissingSchemeAndHttpsEndpointExists
func TestUpdateEndpointWhenUrlIsMissingSchemeAndHttpsEndpointExists(t *testing.T) {
configRepo := testconfig.FakeConfigRepository{}
configRepo.Delete()
configRepo.Login()
ts, repo := createEndpointRepoForUpdate(configRepo, validApiInfoEndpoint)
defer ts.Close()
schemelessURL := strings.Replace(ts.URL, "https://", "", 1)
endpoint, apiResponse := repo.UpdateEndpoint(schemelessURL)
assert.Equal(t, "https://"+schemelessURL, endpoint)
assert.True(t, apiResponse.IsSuccessful())
savedConfig := testconfig.SavedConfiguration
assert.Equal(t, savedConfig.AccessToken, "")
assert.Equal(t, savedConfig.AuthorizationEndpoint, "https://login.example.com")
assert.Equal(t, savedConfig.Target, ts.URL)
assert.Equal(t, savedConfig.ApiVersion, "42.0.0")
}