Remove required user_id param when sending messages
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"blackforestbytes.com/simplecloudnotifier/api/apierr"
|
||||
"blackforestbytes.com/simplecloudnotifier/models"
|
||||
"blackforestbytes.com/simplecloudnotifier/push"
|
||||
tt "blackforestbytes.com/simplecloudnotifier/test/util"
|
||||
"fmt"
|
||||
"git.blackforestbytes.com/BlackForestBytes/goext/langext"
|
||||
"github.com/gin-gonic/gin"
|
||||
"math/rand/v2"
|
||||
"net/url"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"blackforestbytes.com/simplecloudnotifier/api/apierr"
|
||||
"blackforestbytes.com/simplecloudnotifier/push"
|
||||
tt "blackforestbytes.com/simplecloudnotifier/test/util"
|
||||
"git.blackforestbytes.com/BlackForestBytes/goext/langext"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func TestSendSimpleMessageJSON(t *testing.T) {
|
||||
@@ -28,27 +28,23 @@ func TestSendSimpleMessageJSON(t *testing.T) {
|
||||
"fcm_token": "DUMMY_FCM",
|
||||
})
|
||||
|
||||
uid := r0["user_id"].(string)
|
||||
admintok := r0["admin_key"].(string)
|
||||
readtok := r0["read_key"].(string)
|
||||
sendtok := r0["send_key"].(string)
|
||||
|
||||
msg1 := tt.RequestPost[gin.H](t, baseUrl, "/", gin.H{
|
||||
"key": sendtok,
|
||||
"user_id": uid,
|
||||
"title": "HelloWorld_001",
|
||||
"key": sendtok,
|
||||
"title": "HelloWorld_001",
|
||||
})
|
||||
|
||||
tt.RequestPostShouldFail(t, baseUrl, "/", gin.H{
|
||||
"key": readtok,
|
||||
"user_id": uid,
|
||||
"title": "HelloWorld_001",
|
||||
"key": readtok,
|
||||
"title": "HelloWorld_001",
|
||||
}, 401, apierr.USER_AUTH_FAILED)
|
||||
|
||||
tt.RequestPostShouldFail(t, baseUrl, "/", gin.H{
|
||||
"key": "asdf",
|
||||
"user_id": uid,
|
||||
"title": "HelloWorld_001",
|
||||
"key": "asdf",
|
||||
"title": "HelloWorld_001",
|
||||
}, 401, apierr.USER_AUTH_FAILED)
|
||||
|
||||
tt.AssertEqual(t, "messageCount", 1, len(pusher.Data))
|
||||
@@ -117,14 +113,12 @@ func TestSendSimpleMessageForm(t *testing.T) {
|
||||
"fcm_token": "DUMMY_FCM",
|
||||
})
|
||||
|
||||
uid := r0["user_id"].(string)
|
||||
admintok := r0["admin_key"].(string)
|
||||
sendtok := r0["send_key"].(string)
|
||||
|
||||
msg1 := tt.RequestPost[gin.H](t, baseUrl, "/", tt.FormData{
|
||||
"key": sendtok,
|
||||
"user_id": uid,
|
||||
"title": "Hello World 9999 [$$$]",
|
||||
"key": sendtok,
|
||||
"title": "Hello World 9999 [$$$]",
|
||||
})
|
||||
|
||||
tt.AssertEqual(t, "messageCount", 1, len(pusher.Data))
|
||||
@@ -189,9 +183,8 @@ func TestSendSimpleMessageJSONAndQuery(t *testing.T) {
|
||||
|
||||
// query overwrite body
|
||||
msg1 := tt.RequestPost[gin.H](t, baseUrl, fmt.Sprintf("/?user_id=%s&key=%s&title=%s", uid, sendtok, url.QueryEscape("1111111")), gin.H{
|
||||
"key": "ERR",
|
||||
"user_id": models.NewUserID(),
|
||||
"title": "2222222",
|
||||
"key": "ERR",
|
||||
"title": "2222222",
|
||||
})
|
||||
|
||||
tt.AssertEqual(t, "messageCount", 1, len(pusher.Data))
|
||||
@@ -212,21 +205,18 @@ func TestSendSimpleMessageAlt1(t *testing.T) {
|
||||
"fcm_token": "DUMMY_FCM",
|
||||
})
|
||||
|
||||
uid := r0["user_id"].(string)
|
||||
admintok := r0["admin_key"].(string)
|
||||
readtok := r0["read_key"].(string)
|
||||
sendtok := r0["send_key"].(string)
|
||||
|
||||
msg1 := tt.RequestPost[gin.H](t, baseUrl, "/send", gin.H{
|
||||
"key": sendtok,
|
||||
"user_id": uid,
|
||||
"title": "HelloWorld_001",
|
||||
"key": sendtok,
|
||||
"title": "HelloWorld_001",
|
||||
})
|
||||
|
||||
tt.RequestPostShouldFail(t, baseUrl, "/send", gin.H{
|
||||
"key": readtok,
|
||||
"user_id": uid,
|
||||
"title": "HelloWorld_001",
|
||||
"key": readtok,
|
||||
"title": "HelloWorld_001",
|
||||
}, 401, apierr.USER_AUTH_FAILED)
|
||||
|
||||
tt.AssertEqual(t, "messageCount", 1, len(pusher.Data))
|
||||
@@ -259,13 +249,11 @@ func TestSendContentMessage(t *testing.T) {
|
||||
"fcm_token": "DUMMY_FCM",
|
||||
})
|
||||
|
||||
uid := r0["user_id"].(string)
|
||||
admintok := r0["admin_key"].(string)
|
||||
sendtok := r0["send_key"].(string)
|
||||
|
||||
msg1 := tt.RequestPost[gin.H](t, baseUrl, "/", gin.H{
|
||||
"key": sendtok,
|
||||
"user_id": uid,
|
||||
"title": "HelloWorld_042",
|
||||
"content": "I am Content\nasdf",
|
||||
})
|
||||
@@ -304,13 +292,11 @@ func TestSendWithSendername(t *testing.T) {
|
||||
"fcm_token": "DUMMY_FCM",
|
||||
})
|
||||
|
||||
uid := r0["user_id"].(string)
|
||||
sendtok := r0["send_key"].(string)
|
||||
admintok := r0["admin_key"].(string)
|
||||
|
||||
msg1 := tt.RequestPost[gin.H](t, baseUrl, "/", gin.H{
|
||||
"key": sendtok,
|
||||
"user_id": uid,
|
||||
"title": "HelloWorld_xyz",
|
||||
"content": "Unicode: 日本 - yäy\000\n\t\x00...",
|
||||
"sender_name": "localhorst",
|
||||
@@ -353,7 +339,6 @@ func TestSendLongContent(t *testing.T) {
|
||||
"fcm_token": "DUMMY_FCM",
|
||||
})
|
||||
|
||||
uid := r0["user_id"].(string)
|
||||
admintok := r0["admin_key"].(string)
|
||||
sendtok := r0["send_key"].(string)
|
||||
|
||||
@@ -364,7 +349,6 @@ func TestSendLongContent(t *testing.T) {
|
||||
|
||||
msg1 := tt.RequestPost[gin.H](t, baseUrl, "/", gin.H{
|
||||
"key": sendtok,
|
||||
"user_id": uid,
|
||||
"title": "HelloWorld_042",
|
||||
"content": longContent,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user