MCPcopy
hub / github.com/tsuru/tsuru / TestGrantServiceAccessToTeam

Method TestGrantServiceAccessToTeam

api/service_test.go:935–961  ·  view source on GitHub ↗
(c *check.C)

Source from the content-addressed store, hash-verified

933}
934
935func (s *ProvisionSuite) TestGrantServiceAccessToTeam(c *check.C) {
936 t := &authTypes.Team{Name: "blaaaa"}
937 se := service.Service{
938 Name: "my-service",
939 OwnerTeams: []string{s.team.Name},
940 Endpoint: map[string]string{"production": "http://localhost:1234"},
941 Password: "abcde",
942 }
943 err := service.Create(context.TODO(), se)
944 c.Assert(err, check.IsNil)
945 u := fmt.Sprintf("/services/%s/team/%s", se.Name, t.Name)
946 recorder, request := s.makeRequest(http.MethodPut, u, "", c)
947 s.testServer.ServeHTTP(recorder, request)
948 c.Assert(recorder.Code, check.Equals, http.StatusOK)
949 se, err = service.Get(context.TODO(), "my-service")
950 c.Assert(err, check.IsNil)
951 c.Assert(*t, HasAccessTo, se)
952 c.Assert(eventtest.EventDesc{
953 Target: serviceTarget("my-service"),
954 Owner: s.token.GetUserName(),
955 Kind: "service.update.grant-access",
956 StartCustomData: []map[string]interface{}{
957 {"name": ":service", "value": "my-service"},
958 {"name": ":team", "value": t.Name},
959 },
960 }, eventtest.HasEvent)
961}
962
963func (s *ProvisionSuite) TestGrantAccessToTeamServiceNotFound(c *check.C) {
964 u := fmt.Sprintf("/services/nononono/team/%s", s.team.Name)

Callers

nothing calls this directly

Calls 6

makeRequestMethod · 0.95
CreateFunction · 0.92
GetFunction · 0.92
serviceTargetFunction · 0.85
GetUserNameMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected