| 135 | } |
| 136 | |
| 137 | func initStsTestServer(expireOn string) *httptest.Server { |
| 138 | server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 139 | if err := r.ParseForm(); err != nil { |
| 140 | http.Error(w, err.Error(), http.StatusBadRequest) |
| 141 | return |
| 142 | } |
| 143 | required := []string{"RoleArn", "RoleSessionName", "WebIdentityToken", "Version"} |
| 144 | for _, field := range required { |
| 145 | if _, ok := r.Form[field]; !ok { |
| 146 | http.Error(w, fmt.Sprintf("%s missing", field), http.StatusBadRequest) |
| 147 | return |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | fmt.Fprintf(w, credsRespStsImpl, expireOn) |
| 152 | })) |
| 153 | |
| 154 | return server |
| 155 | } |
| 156 | |
| 157 | func TestIAMMalformedEndpoint(t *testing.T) { |
| 158 | creds := NewIAM("%%%%") |