(credentials map[string]string)
| 114 | } |
| 115 | |
| 116 | func (uaa UAARepository) Authenticate(credentials map[string]string) error { |
| 117 | data := url.Values{ |
| 118 | "grant_type": {"password"}, |
| 119 | "scope": {""}, |
| 120 | } |
| 121 | for key, val := range credentials { |
| 122 | data[key] = []string{val} |
| 123 | } |
| 124 | |
| 125 | err := uaa.getAuthToken(data) |
| 126 | if err != nil { |
| 127 | httpError, ok := err.(errors.HTTPError) |
| 128 | if ok { |
| 129 | switch { |
| 130 | case httpError.StatusCode() == http.StatusUnauthorized: |
| 131 | return errors.New(T("Credentials were rejected, please try again.")) |
| 132 | case httpError.StatusCode() >= http.StatusInternalServerError: |
| 133 | return errors.New(T("The targeted API endpoint could not be reached.")) |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | return err |
| 138 | } |
| 139 | |
| 140 | return nil |
| 141 | } |
| 142 | |
| 143 | func (uaa UAARepository) DumpRequest(req *http.Request) { |
| 144 | uaa.dumper.DumpRequest(req) |
nothing calls this directly
no test coverage detected