本文整理匯總了Golang中github.com/backstage/maestro/account.User.Delete方法的典型用法代碼示例。如果您正苦於以下問題:Golang User.Delete方法的具體用法?Golang User.Delete怎麽用?Golang User.Delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/backstage/maestro/account.User
的用法示例。
在下文中一共展示了User.Delete方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestAppInfoNotMember
func (s *S) TestAppInfoNotMember(c *C) {
alice := account.User{Name: "alice", Email: "[email protected]", Password: "secret"}
alice.Create()
t := account.Team{Name: "example"}
t.Create(alice)
app.Create(alice, t)
defer func() {
ap, _ := s.store.FindAppByClientId(app.ClientId)
s.store.DeleteApp(ap)
s.store.DeleteTeamByAlias(t.Alias)
alice.Delete()
}()
headers, code, body, _ := httpClient.MakeRequest(requests.Args{
AcceptableCode: http.StatusForbidden,
Method: "GET",
Path: fmt.Sprintf("/api/apps/%s", app.ClientId),
Headers: http.Header{"Authorization": {s.authHeader}},
})
c.Assert(code, Equals, http.StatusForbidden)
c.Assert(headers.Get("Content-Type"), Equals, "application/json")
c.Assert(string(body), Equals, `{"error":"access_denied","error_description":"You do not belong to this team!"}`)
}
示例2: TestUpdateServiceNotMember
func (s *S) TestUpdateServiceNotMember(c *C) {
alice := account.User{Name: "alice", Email: "[email protected]", Password: "secret"}
alice.Create()
t := account.Team{Name: "example"}
t.Create(alice)
service.Create(alice, t)
defer func() {
serv, _ := s.store.FindServiceBySubdomain(service.Subdomain)
s.store.DeleteService(serv)
s.store.DeleteTeamByAlias(t.Alias)
alice.Delete()
}()
headers, code, body, _ := httpClient.MakeRequest(requests.Args{
AcceptableCode: http.StatusOK,
Method: "PUT",
Path: fmt.Sprintf("/api/services/%s", service.Subdomain),
Body: `{}`,
Headers: http.Header{"Authorization": {s.authHeader}},
})
c.Assert(code, Equals, http.StatusForbidden)
c.Assert(headers.Get("Content-Type"), Equals, "application/json")
c.Assert(string(body), Equals, `{"error":"access_denied","error_description":"You do not belong to this team!"}`)
}
示例3: TestAuthenticateWithInvalidCredentials
func (s *AuthenticatableSuite) TestAuthenticateWithInvalidCredentials(c *C) {
user := account.User{Name: "Alice", Email: "[email protected]", Password: "123"}
user.Create()
defer user.Delete()
_, ok := s.Auth.Authenticate(user.Email, "invalid-password")
c.Assert(ok, Equals, false)
}
示例4: TestDeleteAppWithoutPermission
func (s *S) TestDeleteAppWithoutPermission(c *C) {
alice := account.User{Name: "alice", Email: "[email protected]", Password: "secret"}
alice.Create()
defer alice.Delete()
app.Create(alice, team)
defer func() {
ap, _ := s.store.FindAppByClientId(app.ClientId)
s.store.DeleteApp(ap)
}()
headers, code, body, _ := httpClient.MakeRequest(requests.Args{
AcceptableCode: http.StatusForbidden,
Method: "DELETE",
Path: fmt.Sprintf("/api/apps/%s", app.ClientId),
Headers: http.Header{"Authorization": {s.authHeader}},
})
c.Assert(code, Equals, http.StatusForbidden)
c.Assert(headers.Get("Content-Type"), Equals, "application/json")
c.Assert(string(body), Equals, `{"error":"access_denied","error_description":"Only the owner has permission to perform this operation."}`)
}
示例5: TestTeamInfoWithoutPermission
func (s *S) TestTeamInfoWithoutPermission(c *C) {
alice := account.User{Name: "alice", Email: "[email protected]", Password: "secret"}
alice.Create()
defer alice.Delete()
team := account.Team{Name: "Backstage Team", Alias: "backstage"}
team.Create(alice)
defer func() {
s.store.DeleteTeamByAlias(team.Alias)
}()
headers, code, body, _ := httpClient.MakeRequest(requests.Args{
AcceptableCode: http.StatusForbidden,
Method: "GET",
Path: fmt.Sprintf("/api/teams/%s", team.Alias),
Headers: http.Header{"Authorization": {s.authHeader}},
})
c.Assert(code, Equals, http.StatusForbidden)
c.Assert(headers.Get("Content-Type"), Equals, "application/json")
c.Assert(string(body), Equals, `{"error":"access_denied","error_description":"You do not belong to this team!"}`)
}
示例6: TestRemoveUser
func (s *S) TestRemoveUser(c *C) {
alice := account.User{Name: "alice", Email: "[email protected]", Password: "secret"}
alice.Create()
defer alice.Delete()
team := account.Team{Name: "Backstage Team", Alias: "backstage", Users: []string{alice.Email}}
team.Create(user)
defer func() {
s.store.DeleteTeamByAlias(team.Alias)
}()
headers, code, body, _ := httpClient.MakeRequest(requests.Args{
AcceptableCode: http.StatusOK,
Method: "DELETE",
Path: fmt.Sprintf("/api/teams/%s/users", team.Alias),
Headers: http.Header{"Authorization": {s.authHeader}},
Body: fmt.Sprintf(`{"users": ["%s"]}`, alice.Email),
})
c.Assert(code, Equals, http.StatusOK)
c.Assert(headers.Get("Content-Type"), Equals, "application/json")
c.Assert(string(body), Equals, `{"name":"Backstage Team","alias":"backstage","users":["[email protected]"],"owner":"[email protected]"}`)
}