diff --git a/src/sessions_test.go b/src/sessions_test.go index 21ec40e..69b80f6 100644 --- a/src/sessions_test.go +++ b/src/sessions_test.go @@ -109,19 +109,19 @@ func TestCreateFakeUserSession(t *testing.T) { data := `{"expiration":"1d","cookie":"12345"}` raw, _ := helpCreateSession("token", userTOKEN, data) if _, ok := raw["status"]; ok && raw["status"].(string) == "ok" { - t.Fatalf("Should failed to create session for fake user") + t.Fatalf("Should fail to create session for fake user") } raw, _ = helpCreateSession("token", "faketoken", data) if _, ok := raw["status"]; ok && raw["status"].(string) == "ok" { - t.Fatalf("Should failed to create session for fake user") + t.Fatalf("Should fail to create session for fake user") } raw, _ = helpCreateSession("faketoken", userTOKEN, data) if _, ok := raw["status"]; ok && raw["status"].(string) == "ok" { - t.Fatalf("Should failed to create session for fake user") + t.Fatalf("Should fail to create session for fake user") } raw, _ = helpCreateSession("email", "fakemail23@fake.com", data) if _, ok := raw["status"]; ok && raw["status"].(string) == "ok" { - t.Fatalf("Should failed to create session for fake user") + t.Fatalf("Should fail to create session for fake user") } } diff --git a/src/sharedrecords_api.go b/src/sharedrecords_api.go index f5fd48d..ce41025 100644 --- a/src/sharedrecords_api.go +++ b/src/sharedrecords_api.go @@ -3,6 +3,7 @@ package main import ( "encoding/json" "fmt" + "log" "net/http" "reflect" "strings" @@ -101,7 +102,7 @@ func (e mainEnv) getRecord(w http.ResponseWriter, r *http.Request, ps httprouter if len(recordInfo.token) > 0 { event.Record = recordInfo.token event.App = recordInfo.appName - fmt.Printf("displaying fields: %s, user token: %s\n", recordInfo.fields, recordInfo.token) + log.Printf("field to display: %s, user token: %s\n", recordInfo.fields, recordInfo.token) if len(recordInfo.appName) > 0 { resultJSON, err = e.db.getUserApp(recordInfo.token, recordInfo.appName) @@ -118,7 +119,7 @@ func (e mainEnv) getRecord(w http.ResponseWriter, r *http.Request, ps httprouter returnError(w, r, "not found", 405, err, event) return } - fmt.Printf("Full json: %s\n", resultJSON) + log.Printf("Full json: %s\n", resultJSON) if len(recordInfo.fields) > 0 { raw := make(map[string]interface{}) //var newJSON json @@ -157,6 +158,6 @@ func (e mainEnv) getRecord(w http.ResponseWriter, r *http.Request, ps httprouter str = fmt.Sprintf(`{"status":"ok","data":%s}`, resultJSON) } - fmt.Printf("result: %s\n", str) + log.Printf("result: %s\n", str) w.Write([]byte(str)) } diff --git a/src/sharedrecords_test.go b/src/sharedrecords_test.go index 20dd8ff..b976ea1 100644 --- a/src/sharedrecords_test.go +++ b/src/sharedrecords_test.go @@ -65,7 +65,7 @@ func TestCreateSharedRecordFakeUser(t *testing.T) { data := `{"expiration":"1d","fields":"uuid,name,pass,k1"}` raw, _ := helpCreateSharedRecord("token", userTOKEN, data) if _, ok := raw["status"]; ok && raw["status"].(string) == "ok" { - t.Fatalf("Should failed to create shared record for fake user") + t.Fatalf("Should fail to create shared record for fake user") } } @@ -73,20 +73,20 @@ func TestCreateSharedRecordBadInput(t *testing.T) { userTOKEN, _ := uuid.GenerateUUID() raw, _ := helpCreateSharedRecord("token", userTOKEN, "a=b") if _, ok := raw["status"]; ok && raw["status"].(string) == "ok" { - t.Fatalf("Should failed to create shared record for fake user") + t.Fatalf("Should fail to create shared record for fake user") } data := `{"expiration":"1d","fields":"uuid,name,pass,k1"}` raw, _ = helpCreateSharedRecord("token", userTOKEN, "a=b") if _, ok := raw["status"]; ok && raw["status"].(string) == "ok" { - t.Fatalf("Should failed to create shared record for fake user") + t.Fatalf("Should fail to create shared record for fake user") } raw, _ = helpCreateSharedRecord("faketoken", userTOKEN, data) if _, ok := raw["status"]; ok && raw["status"].(string) == "ok" { - t.Fatalf("Should failed to create shared record for fake user") + t.Fatalf("Should fail to create shared record for fake user") } raw, _ = helpCreateSharedRecord("token", "faketoken", data) if _, ok := raw["status"]; ok && raw["status"].(string) == "ok" { - t.Fatalf("Should failed to create shared record for fake user") + t.Fatalf("Should fail to create shared record for fake user") } } diff --git a/src/userapps_api.go b/src/userapps_api.go index 4f6dd85..ed30b8c 100644 --- a/src/userapps_api.go +++ b/src/userapps_api.go @@ -205,7 +205,6 @@ func (e mainEnv) userappDelete(w http.ResponseWriter, r *http.Request, ps httpro } func (e mainEnv) appList(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { - fmt.Printf("/APPLIST\n") if e.enforceAuth(w, r, nil) == "" { return } diff --git a/src/userapps_test.go b/src/userapps_test.go index 8344a1e..573d4b2 100644 --- a/src/userapps_test.go +++ b/src/userapps_test.go @@ -92,23 +92,23 @@ func TestCreateUserUpdateAppBadData(t *testing.T) { } raw, _ = helpUpdateUserApp(userTOKEN, appName, "a:b") if _, ok := raw["status"]; ok && raw["status"].(string) == "ok" { - t.Fatalf("Should failed to update userapp") + t.Fatalf("Should fail to update userapp") } raw, _ = helpUpdateUserApp(userTOKEN, appName, "{}") if _, ok := raw["status"]; ok && raw["status"].(string) == "ok" { - t.Fatalf("Should failed to update userapp") + t.Fatalf("Should fail to update userapp") } raw, _ = helpUpdateUserApp(userTOKEN, "app!123", `{"a":"b"}`) if _, ok := raw["status"]; ok && raw["status"].(string) == "ok" { - t.Fatalf("Should failed to update userapp") + t.Fatalf("Should fail to update userapp") } raw, _ = helpUpdateUserApp(userTOKEN, "fakeapp", `{"a":"b"}`) if _, ok := raw["status"]; ok && raw["status"].(string) == "ok" { - t.Fatalf("Should failed to update userapp") + t.Fatalf("Should fail to update userapp") } raw, _ = helpUpdateUserApp("faketoken", appName, `{"a":"b"}`) if _, ok := raw["status"]; ok && raw["status"].(string) == "ok" { - t.Fatalf("Should failed to update userapp") + t.Fatalf("Should fail to update userapp") } raw, _ = helpUpdateUserApp(userTOKEN, appName, `{"a":"b"}`) if _, ok := raw["status"]; !ok || raw["status"].(string) != "ok" { @@ -146,6 +146,10 @@ func TestCreateUserAppResetData(t *testing.T) { if _, ok := raw["status"]; !ok || raw["status"].(string) != "ok" { t.Fatalf("Failed to get app detailes for user") } + data := raw["data"].(map[string]interface{}) + if len(data) != 0 { + t.Fatalf("Expected empty data") + } } func TestCreateUserAppFakeToken(t *testing.T) { diff --git a/src/utils.go b/src/utils.go index 47451b9..6f2d907 100644 --- a/src/utils.go +++ b/src/utils.go @@ -412,7 +412,7 @@ func (e mainEnv) enforceAdmin(w http.ResponseWriter, r *http.Request) string { func enforceUUID(w http.ResponseWriter, uuidCode string, event *auditEvent) bool { if isValidUUID(uuidCode) == false { - fmt.Printf("405 bad uuid in : %s\n", uuidCode) + //fmt.Printf("405 bad uuid in : %s\n", uuidCode) w.Header().Set("Content-Type", "application/json; charset=utf-8") w.WriteHeader(405) fmt.Fprintf(w, `{"status":"error","message":"bad uuid"}`)