Created
March 26, 2015 14:16
-
-
Save liggitt/602ad5b5cfab6d156c90 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// +build integration,!no-etcd | |
package integration | |
import ( | |
"crypto/tls" | |
"net/http" | |
"testing" | |
testutil "github.com/openshift/origin/test/util" | |
) | |
func TestRootRedirect(t *testing.T) { | |
masterConfig, _, err := testutil.StartTestMaster() | |
if err != nil { | |
t.Fatalf("unexpected error: %v", err) | |
} | |
transport := &http.Transport{ | |
TLSClientConfig: &tls.Config{ | |
InsecureSkipVerify: true, | |
}, | |
} | |
req, err := http.NewRequest("GET", masterConfig.AssetConfig.MasterPublicURL, nil) | |
req.Header.Set("Accept", "*/*") | |
resp, err := transport.RoundTrip(req) | |
if err != nil { | |
t.Errorf("Unexpected error: %v", err) | |
} | |
if resp.StatusCode != http.StatusOK { | |
t.Errorf("Expected %d, got %d", http.StatusOK, resp.StatusCode) | |
} | |
if resp.Header.Get("Content-Type") != "application/json" { | |
t.Errorf("Expected %s, got %s", "application/json", resp.Header.Get("Content-Type")) | |
} | |
req, err = http.NewRequest("GET", masterConfig.AssetConfig.MasterPublicURL, nil) | |
req.Header.Set("Accept", "text/html") | |
resp, err = transport.RoundTrip(req) | |
if err != nil { | |
t.Errorf("Unexpected error: %v", err) | |
} | |
if resp.StatusCode != http.StatusFound { | |
t.Errorf("Expected %d, got %d", http.StatusFound, resp.StatusCode) | |
} | |
if resp.Header.Get("Location") != masterConfig.AssetConfig.PublicURL { | |
t.Errorf("Expected %s, got %s", masterConfig.AssetConfig.PublicURL, resp.Header.Get("Location")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment