2016-07-07 18:54:16 -07:00
|
|
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
|
|
|
//
|
2016-07-15 16:54:07 +01:00
|
|
|
// This software (Documize Community Edition) is licensed under
|
2016-07-07 18:54:16 -07:00
|
|
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
|
|
|
//
|
|
|
|
// You can operate outside the AGPL restrictions by purchasing
|
|
|
|
// Documize Enterprise Edition and obtaining a commercial license
|
2016-07-15 16:54:07 +01:00
|
|
|
// by contacting <sales@documize.com>.
|
2016-07-07 18:54:16 -07:00
|
|
|
//
|
|
|
|
// https://documize.com
|
|
|
|
|
|
|
|
package request
|
2016-07-15 16:54:07 +01:00
|
|
|
|
2016-07-07 18:54:16 -07:00
|
|
|
/* TODO(Elliott)
|
|
|
|
import "testing"
|
|
|
|
import "net/http"
|
|
|
|
|
|
|
|
func TestDomain(t *testing.T) {
|
|
|
|
ds(t, "doodahday.documize.com", "doodahday", "doodahday")
|
|
|
|
ds(t, "crud.com", "crud", "crud")
|
|
|
|
ds(t, "badbadbad", "", "")
|
|
|
|
}
|
|
|
|
|
|
|
|
func ds(t *testing.T, in, out1, out2 string) {
|
|
|
|
r, e := http.NewRequest("", in, nil)
|
|
|
|
if e != nil {
|
|
|
|
t.Fatal(e)
|
|
|
|
}
|
|
|
|
r.Host = in
|
|
|
|
r.Header.Set("Referer", in)
|
|
|
|
got1 := GetRequestSubdomain(r)
|
|
|
|
out1 = CheckDomain(out1)
|
|
|
|
if got1 != out1 {
|
|
|
|
t.Errorf("GetRequestSubdomain input `%s` got `%s` expected `%s`\n", in, got1, out1)
|
|
|
|
}
|
|
|
|
got2 := GetSubdomainFromHost(r)
|
|
|
|
out2 = CheckDomain(out2)
|
|
|
|
if got2 != out2 {
|
|
|
|
t.Errorf("GetSubdomainFromHost input `%s` got `%s` expected `%s`\n", in, got2, out2)
|
|
|
|
}
|
|
|
|
}
|
2016-07-15 16:54:07 +01:00
|
|
|
*/
|