func TestReadConfig(t *testing.T) { fmt.Println("\n\n>>>>>>>>>>>>>>>>>>> TestReadConfig <<<<<<<<<<<<<<<<<<<<<<<<<<") // Load Config if err := config.Init("../config.json"); err != nil { t.Errorf("Error %v occurred when loading the config.", err) } fmt.Printf("%v", config.C.Display()) if config.C.Loaded != true { t.Errorf("System configuration is not marked as loaded.") } // Test Auth() ac := "1234567890" if a := config.Auth(ac); !a { t.Errorf("Auth() failed.") } ac = "1111" if a := config.Auth(ac); a { t.Errorf("Auth() passed erroneously for: %q", ac) } }
func (r *Request) auth() (ok bool) { ok = config.Auth(r.ApiAuthKey) return ok }