(clientID string)
| 29 | } |
| 30 | |
| 31 | func (repo CloudControllerClientRepository) ClientExists(clientID string) (exists bool, apiErr error) { |
| 32 | exists = false |
| 33 | uaaEndpoint, apiErr := repo.getAuthEndpoint() |
| 34 | if apiErr != nil { |
| 35 | return exists, apiErr |
| 36 | } |
| 37 | |
| 38 | path := fmt.Sprintf("%s/oauth/clients/%s", uaaEndpoint, clientID) |
| 39 | |
| 40 | uaaResponse := new(resources.UAAUserResources) |
| 41 | apiErr = repo.uaaGateway.GetResource(path, uaaResponse) |
| 42 | if apiErr != nil { |
| 43 | if errType, ok := apiErr.(errors.HTTPError); ok { |
| 44 | switch errType.StatusCode() { |
| 45 | case http.StatusNotFound: |
| 46 | return false, errors.NewModelNotFoundError("Client", clientID) |
| 47 | case http.StatusForbidden: |
| 48 | return false, errors.NewAccessDeniedError() |
| 49 | } |
| 50 | } |
| 51 | return false, apiErr |
| 52 | } |
| 53 | return true, nil |
| 54 | } |
| 55 | |
| 56 | func (repo CloudControllerClientRepository) getAuthEndpoint() (string, error) { |
| 57 | uaaEndpoint := repo.config.UaaEndpoint() |
nothing calls this directly
no test coverage detected