예제 #1
0
func TestServerFQDN(t *testing.T) {
	resp := fixtures.Servers()
	server := testHelper.ValidHTTPServer(resp)
	defer server.Close()

	var httpClient http.Client
	to := client.Session{
		URL:       server.URL,
		UserAgent: &httpClient,
	}

	shortName := "edge-alb-01"
	testHelper.Context(t, "Given the need to test a successful Traffic Ops request for the FQDN of Server: \"%s\"", shortName)

	s, err := to.ServersFqdn("edge-alb-01")
	if err != nil {
		testHelper.Error(t, "Should be able to make a request to Traffic Ops")
	} else {
		testHelper.Success(t, "Should be able to make a request to Traffic Ops")
	}

	if s != "edge-alb-01.albuquerque.nm.albuq.kabletown.com" {
		testHelper.Error(t, "Should get back \"edge-alb-01.albuquerque.nm.albuq.kabletown.com\", got: %s", s)
	} else {
		testHelper.Success(t, "Should get back \"edge-alb-01.albuquerque.nm.albuq.kabletown.com\"")
	}
}
예제 #2
0
func TestServerFQDNUnauthorized(t *testing.T) {
	server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
	defer server.Close()

	var httpClient http.Client
	to := client.Session{
		URL:       server.URL,
		UserAgent: &httpClient,
	}

	shortName := "edge-alb-01"
	testHelper.Context(t, "Given the need to test a failed Traffic Ops request for the FQDN of Server: \"%s\"", shortName)

	_, err := to.ServersFqdn(shortName)
	if err == nil {
		testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
	} else {
		testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
	}
}