2022-12-31 10:22:38 +01:00
|
|
|
package tests
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
2023-10-24 09:27:34 +02:00
|
|
|
"testing"
|
|
|
|
|
2022-12-31 10:22:38 +01:00
|
|
|
"github.com/google/uuid"
|
2023-01-30 19:59:42 +01:00
|
|
|
"github.com/twofas/2fas-server/tests"
|
2022-12-31 10:22:38 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func Test_BrowserExtensionLogging(t *testing.T) {
|
|
|
|
browserExtension := tests.CreateBrowserExtension(t, "go-ext")
|
|
|
|
|
|
|
|
log := &struct {
|
|
|
|
Level string `json:"level"`
|
|
|
|
Message string `json:"message"`
|
|
|
|
}{
|
|
|
|
Level: "info",
|
|
|
|
Message: "test log",
|
|
|
|
}
|
|
|
|
|
|
|
|
payload, _ := json.Marshal(log)
|
2023-10-24 09:27:34 +02:00
|
|
|
tests.DoAPISuccessPost(t, "/browser_extensions/"+browserExtension.Id+"/commands/store_log", payload, nil)
|
2022-12-31 10:22:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func Test_NotExistingBrowserExtensionLogging(t *testing.T) {
|
|
|
|
someId := uuid.New()
|
|
|
|
|
|
|
|
log := &struct {
|
|
|
|
Level string `json:"level"`
|
|
|
|
Message string `json:"message"`
|
|
|
|
}{
|
|
|
|
Level: "info",
|
|
|
|
Message: "test log",
|
|
|
|
}
|
|
|
|
|
|
|
|
payload, _ := json.Marshal(log)
|
2023-10-24 09:27:34 +02:00
|
|
|
tests.DoAPISuccessPost(t, "/browser_extensions/"+someId.String()+"/commands/store_log", payload, nil)
|
2022-12-31 10:22:38 +01:00
|
|
|
}
|