mirror of
https://github.com/optim-enterprises-bv/databunker.git
synced 2025-11-01 18:38:06 +00:00
fix messages
This commit is contained in:
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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"}`)
|
||||
|
||||
Reference in New Issue
Block a user