2022-11-24 12:53:27 +01:00
|
|
|
package test
|
|
|
|
|
|
|
|
import (
|
2022-11-30 13:57:55 +01:00
|
|
|
"blackforestbytes.com/simplecloudnotifier/api/apierr"
|
|
|
|
tt "blackforestbytes.com/simplecloudnotifier/test/util"
|
2022-11-24 12:53:27 +01:00
|
|
|
"fmt"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCreateUserNoClient(t *testing.T) {
|
2022-12-14 17:02:18 +01:00
|
|
|
_, baseUrl, stop := tt.StartSimpleWebserver(t)
|
2022-11-24 12:53:27 +01:00
|
|
|
defer stop()
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
|
2022-11-24 12:53:27 +01:00
|
|
|
"no_client": true,
|
|
|
|
})
|
|
|
|
|
2022-11-30 13:57:55 +01:00
|
|
|
tt.AssertEqual(t, "len(clients)", 0, len(r0["clients"].([]any)))
|
2022-11-30 10:35:05 +01:00
|
|
|
|
|
|
|
uid := fmt.Sprintf("%v", r0["user_id"])
|
2022-11-30 17:58:04 +01:00
|
|
|
readtok := r0["read_key"].(string)
|
|
|
|
sendtok := r0["send_key"].(string)
|
2022-11-24 12:53:27 +01:00
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
tt.RequestAuthGetShouldFail(t, sendtok, baseUrl, "/api/v2/users/"+uid, 401, apierr.USER_AUTH_FAILED)
|
|
|
|
tt.RequestAuthGetShouldFail(t, "", baseUrl, "/api/v2/users/"+uid, 401, apierr.USER_AUTH_FAILED)
|
2022-11-30 17:58:04 +01:00
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r1 := tt.RequestAuthGet[gin.H](t, readtok, baseUrl, "/api/v2/users/"+uid)
|
2022-11-24 12:53:27 +01:00
|
|
|
|
2022-11-30 13:57:55 +01:00
|
|
|
tt.AssertEqual(t, "uid", uid, fmt.Sprintf("%v", r1["user_id"]))
|
2022-11-30 10:35:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestCreateUserDummyClient(t *testing.T) {
|
2022-12-14 17:02:18 +01:00
|
|
|
_, baseUrl, stop := tt.StartSimpleWebserver(t)
|
2022-11-30 10:35:05 +01:00
|
|
|
defer stop()
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
|
2022-11-30 10:35:05 +01:00
|
|
|
"agent_model": "DUMMY_PHONE",
|
|
|
|
"agent_version": "4X",
|
|
|
|
"client_type": "ANDROID",
|
|
|
|
"fcm_token": "DUMMY_FCM",
|
|
|
|
})
|
|
|
|
|
|
|
|
uid := fmt.Sprintf("%v", r0["user_id"])
|
|
|
|
|
2022-11-30 13:57:55 +01:00
|
|
|
tt.AssertEqual(t, "len(clients)", 1, len(r0["clients"].([]any)))
|
2022-11-30 10:35:05 +01:00
|
|
|
|
|
|
|
admintok := r0["admin_key"].(string)
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r1 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid)
|
2022-11-30 10:35:05 +01:00
|
|
|
|
2022-11-30 13:57:55 +01:00
|
|
|
tt.AssertEqual(t, "uid", uid, fmt.Sprintf("%v", r1["user_id"]))
|
|
|
|
tt.AssertEqual(t, "username", nil, r1["username"])
|
2022-11-30 10:35:05 +01:00
|
|
|
|
|
|
|
type rt2 struct {
|
|
|
|
Clients []gin.H `json:"clients"`
|
|
|
|
}
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r2 := tt.RequestAuthGet[rt2](t, admintok, baseUrl, "/api/v2/users/"+uid+"/clients")
|
2022-11-30 10:35:05 +01:00
|
|
|
|
2022-11-30 13:57:55 +01:00
|
|
|
tt.AssertEqual(t, "len(clients)", 1, len(r2.Clients))
|
2022-11-30 10:35:05 +01:00
|
|
|
|
|
|
|
c0 := r2.Clients[0]
|
|
|
|
|
2022-11-30 13:57:55 +01:00
|
|
|
tt.AssertEqual(t, "agent_model", "DUMMY_PHONE", c0["agent_model"])
|
|
|
|
tt.AssertEqual(t, "agent_version", "4X", c0["agent_version"])
|
|
|
|
tt.AssertEqual(t, "fcm_token", "DUMMY_FCM", c0["fcm_token"])
|
|
|
|
tt.AssertEqual(t, "client_type", "ANDROID", c0["type"])
|
2022-11-30 10:35:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestCreateUserWithUsername(t *testing.T) {
|
2022-12-14 17:02:18 +01:00
|
|
|
_, baseUrl, stop := tt.StartSimpleWebserver(t)
|
2022-11-30 10:35:05 +01:00
|
|
|
defer stop()
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
|
2022-11-30 10:35:05 +01:00
|
|
|
"agent_model": "DUMMY_PHONE",
|
|
|
|
"agent_version": "4X",
|
|
|
|
"client_type": "ANDROID",
|
|
|
|
"fcm_token": "DUMMY_FCM",
|
|
|
|
"username": "my_user",
|
|
|
|
})
|
|
|
|
|
2022-11-30 13:57:55 +01:00
|
|
|
tt.AssertEqual(t, "len(clients)", 1, len(r0["clients"].([]any)))
|
2022-11-30 10:35:05 +01:00
|
|
|
|
|
|
|
uid := fmt.Sprintf("%v", r0["user_id"])
|
|
|
|
|
|
|
|
admintok := r0["admin_key"].(string)
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r1 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid)
|
2022-11-30 13:57:55 +01:00
|
|
|
|
|
|
|
tt.AssertEqual(t, "uid", uid, fmt.Sprintf("%v", r1["user_id"]))
|
|
|
|
tt.AssertEqual(t, "username", "my_user", r1["username"])
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestUpdateUsername(t *testing.T) {
|
2022-12-14 17:02:18 +01:00
|
|
|
_, baseUrl, stop := tt.StartSimpleWebserver(t)
|
2022-11-30 13:57:55 +01:00
|
|
|
defer stop()
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
|
2022-11-30 13:57:55 +01:00
|
|
|
"agent_model": "DUMMY_PHONE",
|
|
|
|
"agent_version": "4X",
|
|
|
|
"client_type": "ANDROID",
|
|
|
|
"fcm_token": "DUMMY_FCM",
|
|
|
|
})
|
|
|
|
tt.AssertEqual(t, "username", nil, r0["username"])
|
|
|
|
|
|
|
|
uid := fmt.Sprintf("%v", r0["user_id"])
|
|
|
|
admintok := r0["admin_key"].(string)
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r1 := tt.RequestAuthPatch[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid, gin.H{"username": "my_user_001"})
|
2022-11-30 13:57:55 +01:00
|
|
|
tt.AssertEqual(t, "username", "my_user_001", r1["username"])
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r2 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid)
|
2022-11-30 13:57:55 +01:00
|
|
|
tt.AssertEqual(t, "username", "my_user_001", r2["username"])
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r3 := tt.RequestAuthPatch[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid, gin.H{"username": "my_user_002"})
|
2022-11-30 13:57:55 +01:00
|
|
|
tt.AssertEqual(t, "username", "my_user_002", r3["username"])
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r4 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid)
|
2022-11-30 13:57:55 +01:00
|
|
|
tt.AssertEqual(t, "username", "my_user_002", r4["username"])
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r5 := tt.RequestAuthPatch[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid, gin.H{"username": ""})
|
2022-11-30 13:57:55 +01:00
|
|
|
tt.AssertEqual(t, "username", nil, r5["username"])
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r6 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid)
|
2022-11-30 13:57:55 +01:00
|
|
|
tt.AssertEqual(t, "username", nil, r6["username"])
|
|
|
|
}
|
|
|
|
|
2023-01-17 22:56:04 +01:00
|
|
|
func TestUgradeUserToPro(t *testing.T) {
|
|
|
|
_, baseUrl, stop := tt.StartSimpleWebserver(t)
|
|
|
|
defer stop()
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
|
2023-01-17 22:56:04 +01:00
|
|
|
"no_client": true,
|
|
|
|
})
|
|
|
|
tt.AssertEqual(t, "is_pro", false, r0["is_pro"])
|
|
|
|
|
|
|
|
uid0 := fmt.Sprintf("%v", r0["user_id"])
|
|
|
|
admintok0 := r0["admin_key"].(string)
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r1 := tt.RequestAuthPatch[gin.H](t, admintok0, baseUrl, "/api/v2/users/"+uid0, gin.H{"pro_token": "ANDROID|v2|PURCHASED:000"})
|
2023-01-17 22:56:04 +01:00
|
|
|
tt.AssertEqual(t, "is_pro", true, r1["is_pro"])
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r2 := tt.RequestAuthGet[gin.H](t, admintok0, baseUrl, "/api/v2/users/"+uid0)
|
2023-01-17 22:56:04 +01:00
|
|
|
tt.AssertEqual(t, "is_pro", true, r2["is_pro"])
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDowngradeUserToNonPro(t *testing.T) {
|
|
|
|
_, baseUrl, stop := tt.StartSimpleWebserver(t)
|
|
|
|
defer stop()
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
|
2023-01-17 22:56:04 +01:00
|
|
|
"no_client": true,
|
|
|
|
"pro_token": "ANDROID|v2|PURCHASED:UNIQ_111",
|
|
|
|
})
|
|
|
|
tt.AssertEqual(t, "is_pro", true, r0["is_pro"])
|
|
|
|
|
|
|
|
uid0 := fmt.Sprintf("%v", r0["user_id"])
|
|
|
|
admintok0 := r0["admin_key"].(string)
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r1 := tt.RequestAuthPatch[gin.H](t, admintok0, baseUrl, "/api/v2/users/"+uid0, gin.H{"pro_token": ""})
|
2023-01-17 22:56:04 +01:00
|
|
|
tt.AssertEqual(t, "is_pro", false, r1["is_pro"])
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r2 := tt.RequestAuthGet[gin.H](t, admintok0, baseUrl, "/api/v2/users/"+uid0)
|
2023-01-17 22:56:04 +01:00
|
|
|
tt.AssertEqual(t, "is_pro", false, r2["is_pro"])
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestFailedUgradeUserToPro(t *testing.T) {
|
|
|
|
_, baseUrl, stop := tt.StartSimpleWebserver(t)
|
|
|
|
defer stop()
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
|
2023-01-17 22:56:04 +01:00
|
|
|
"no_client": true,
|
|
|
|
})
|
|
|
|
tt.AssertEqual(t, "is_pro", false, r0["is_pro"])
|
|
|
|
|
|
|
|
uid0 := fmt.Sprintf("%v", r0["user_id"])
|
|
|
|
admintok0 := r0["admin_key"].(string)
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
tt.RequestAuthPatchShouldFail(t, admintok0, baseUrl, "/api/v2/users/"+uid0, gin.H{"pro_token": "ANDROID|v2|INVALID"}, 400, apierr.INVALID_PRO_TOKEN)
|
2023-01-17 22:56:04 +01:00
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
tt.RequestAuthPatchShouldFail(t, admintok0, baseUrl, "/api/v2/users/"+uid0, gin.H{"pro_token": "ANDROID|v99|PURCHASED"}, 400, apierr.INVALID_PRO_TOKEN)
|
2023-01-17 22:56:04 +01:00
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
tt.RequestAuthPatchShouldFail(t, admintok0, baseUrl, "/api/v2/users/"+uid0, gin.H{"pro_token": "@INVALID"}, 400, apierr.INVALID_PRO_TOKEN)
|
2023-01-17 22:56:04 +01:00
|
|
|
}
|
|
|
|
|
2022-11-30 13:57:55 +01:00
|
|
|
func TestDeleteUser(t *testing.T) {
|
|
|
|
t.SkipNow() // TODO DeleteUser Not implemented
|
|
|
|
|
2022-12-14 17:02:18 +01:00
|
|
|
_, baseUrl, stop := tt.StartSimpleWebserver(t)
|
2022-11-30 13:57:55 +01:00
|
|
|
defer stop()
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
|
2022-11-30 13:57:55 +01:00
|
|
|
"agent_model": "DUMMY_PHONE",
|
|
|
|
"agent_version": "4X",
|
|
|
|
"client_type": "ANDROID",
|
|
|
|
"fcm_token": "DUMMY_FCM",
|
|
|
|
})
|
|
|
|
|
|
|
|
uid := fmt.Sprintf("%v", r0["user_id"])
|
|
|
|
admintok := r0["admin_key"].(string)
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid)
|
2022-11-30 13:57:55 +01:00
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
tt.RequestAuthDeleteShouldFail(t, admintok, baseUrl, "/api/v2/users/"+uid, nil, 401, apierr.USER_AUTH_FAILED)
|
2022-11-30 17:58:04 +01:00
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
tt.RequestAuthDelete[tt.Void](t, admintok, baseUrl, "/api/v2/users/"+uid, nil)
|
2022-11-30 10:35:05 +01:00
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
tt.RequestAuthGetShouldFail(t, admintok, baseUrl, "/api/v2/users/"+uid, 404, apierr.USER_NOT_FOUND)
|
2022-11-30 10:35:05 +01:00
|
|
|
|
2022-11-24 12:53:27 +01:00
|
|
|
}
|
2022-12-07 22:11:44 +01:00
|
|
|
|
2022-12-14 18:38:30 +01:00
|
|
|
func TestCreateProUser(t *testing.T) {
|
|
|
|
_, baseUrl, stop := tt.StartSimpleWebserver(t)
|
|
|
|
defer stop()
|
|
|
|
|
|
|
|
{
|
2023-01-27 10:04:06 +01:00
|
|
|
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
|
2022-12-14 18:38:30 +01:00
|
|
|
"no_client": true,
|
|
|
|
})
|
|
|
|
|
|
|
|
tt.AssertEqual(t, "is_pro", false, r0["is_pro"])
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2023-01-27 10:04:06 +01:00
|
|
|
r1 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
|
2022-12-14 18:38:30 +01:00
|
|
|
"no_client": true,
|
|
|
|
"pro_token": "ANDROID|v2|PURCHASED:000",
|
|
|
|
})
|
|
|
|
|
|
|
|
tt.AssertEqual(t, "is_pro", true, r1["is_pro"])
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2023-01-27 10:04:06 +01:00
|
|
|
r2 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
|
2022-12-14 18:38:30 +01:00
|
|
|
"agent_model": "DUMMY_PHONE",
|
|
|
|
"agent_version": "4X",
|
|
|
|
"client_type": "ANDROID",
|
|
|
|
"fcm_token": "DUMMY_FCM",
|
|
|
|
})
|
|
|
|
|
|
|
|
tt.AssertEqual(t, "is_pro", false, r2["is_pro"])
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2023-01-27 10:04:06 +01:00
|
|
|
r3 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
|
2022-12-14 18:38:30 +01:00
|
|
|
"agent_model": "DUMMY_PHONE",
|
|
|
|
"agent_version": "4X",
|
|
|
|
"client_type": "ANDROID",
|
|
|
|
"fcm_token": "DUMMY_FCM",
|
|
|
|
"pro_token": "ANDROID|v2|PURCHASED:000",
|
|
|
|
})
|
|
|
|
|
|
|
|
tt.AssertEqual(t, "is_pro", true, r3["is_pro"])
|
|
|
|
}
|
|
|
|
|
2023-01-17 22:56:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestFailToCreateProUser(t *testing.T) {
|
|
|
|
_, baseUrl, stop := tt.StartSimpleWebserver(t)
|
|
|
|
defer stop()
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
tt.RequestPostShouldFail(t, baseUrl, "/api/v2/users", gin.H{
|
2023-01-17 22:56:04 +01:00
|
|
|
"agent_model": "DUMMY_PHONE",
|
|
|
|
"agent_version": "4X",
|
|
|
|
"client_type": "ANDROID",
|
|
|
|
"fcm_token": "DUMMY_FCM",
|
|
|
|
"pro_token": "ANDROID|v2|INVALID",
|
|
|
|
}, 400, apierr.INVALID_PRO_TOKEN)
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
tt.RequestPostShouldFail(t, baseUrl, "/api/v2/users", gin.H{
|
2023-01-17 22:56:04 +01:00
|
|
|
"agent_model": "DUMMY_PHONE",
|
|
|
|
"agent_version": "4X",
|
|
|
|
"client_type": "ANDROID",
|
|
|
|
"fcm_token": "DUMMY_FCM",
|
|
|
|
"pro_token": "_",
|
|
|
|
}, 400, apierr.INVALID_PRO_TOKEN)
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
tt.RequestPostShouldFail(t, baseUrl, "/api/v2/users", gin.H{
|
2023-01-17 22:56:04 +01:00
|
|
|
"agent_model": "DUMMY_PHONE",
|
|
|
|
"agent_version": "4X",
|
|
|
|
"client_type": "ANDROID",
|
|
|
|
"fcm_token": "DUMMY_FCM",
|
|
|
|
"pro_token": "ANDROID|v99|xxx",
|
|
|
|
}, 400, apierr.INVALID_PRO_TOKEN)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestReuseProToken(t *testing.T) {
|
|
|
|
_, baseUrl, stop := tt.StartSimpleWebserver(t)
|
|
|
|
defer stop()
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
|
2023-01-17 22:56:04 +01:00
|
|
|
"no_client": true,
|
|
|
|
})
|
|
|
|
tt.AssertEqual(t, "is_pro", false, r0["is_pro"])
|
|
|
|
|
|
|
|
uid0 := fmt.Sprintf("%v", r0["user_id"])
|
|
|
|
admintok0 := r0["admin_key"].(string)
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r1 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
|
2023-01-17 22:56:04 +01:00
|
|
|
"no_client": true,
|
|
|
|
"pro_token": "ANDROID|v2|PURCHASED:UNIQ_1",
|
|
|
|
})
|
|
|
|
tt.AssertEqual(t, "is_pro", true, r1["is_pro"])
|
|
|
|
|
|
|
|
uid1 := fmt.Sprintf("%v", r1["user_id"])
|
|
|
|
admintok1 := r1["admin_key"].(string)
|
|
|
|
|
|
|
|
{
|
2023-01-27 10:04:06 +01:00
|
|
|
rc := tt.RequestAuthGet[gin.H](t, admintok1, baseUrl, "/api/v2/users/"+uid1)
|
2023-01-17 22:56:04 +01:00
|
|
|
tt.AssertEqual(t, "is_pro", true, rc["is_pro"])
|
|
|
|
}
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
r2 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
|
2023-01-17 22:56:04 +01:00
|
|
|
"no_client": true,
|
|
|
|
"pro_token": "ANDROID|v2|PURCHASED:UNIQ_1",
|
|
|
|
})
|
|
|
|
tt.AssertEqual(t, "is_pro", true, r2["is_pro"])
|
|
|
|
|
|
|
|
uid2 := fmt.Sprintf("%v", r2["user_id"])
|
|
|
|
admintok2 := r2["admin_key"].(string)
|
|
|
|
|
2023-01-17 22:03:27 +01:00
|
|
|
{
|
2023-01-27 10:04:06 +01:00
|
|
|
rc := tt.RequestAuthGet[gin.H](t, admintok0, baseUrl, "/api/v2/users/"+uid0)
|
2023-01-17 22:56:04 +01:00
|
|
|
tt.AssertEqual(t, "is_pro", false, rc["is_pro"])
|
|
|
|
}
|
2023-01-17 22:03:27 +01:00
|
|
|
|
2023-01-17 22:56:04 +01:00
|
|
|
{
|
2023-01-27 10:04:06 +01:00
|
|
|
rc := tt.RequestAuthGet[gin.H](t, admintok1, baseUrl, "/api/v2/users/"+uid1)
|
2023-01-17 22:56:04 +01:00
|
|
|
tt.AssertEqual(t, "is_pro", false, rc["is_pro"])
|
|
|
|
}
|
2023-01-17 22:03:27 +01:00
|
|
|
|
2023-01-17 22:56:04 +01:00
|
|
|
{
|
2023-01-27 10:04:06 +01:00
|
|
|
rc := tt.RequestAuthGet[gin.H](t, admintok2, baseUrl, "/api/v2/users/"+uid2)
|
2023-01-17 22:56:04 +01:00
|
|
|
tt.AssertEqual(t, "is_pro", true, rc["is_pro"])
|
|
|
|
}
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
tt.RequestAuthPatch[gin.H](t, admintok0, baseUrl, "/api/v2/users/"+uid0, gin.H{"pro_token": "ANDROID|v2|PURCHASED:UNIQ_2"})
|
2023-01-17 22:56:04 +01:00
|
|
|
|
|
|
|
{
|
2023-01-27 10:04:06 +01:00
|
|
|
rc := tt.RequestAuthGet[gin.H](t, admintok0, baseUrl, "/api/v2/users/"+uid0)
|
2023-01-17 22:56:04 +01:00
|
|
|
tt.AssertEqual(t, "is_pro", true, rc["is_pro"])
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2023-01-27 10:04:06 +01:00
|
|
|
rc := tt.RequestAuthGet[gin.H](t, admintok1, baseUrl, "/api/v2/users/"+uid1)
|
2023-01-17 22:56:04 +01:00
|
|
|
tt.AssertEqual(t, "is_pro", false, rc["is_pro"])
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2023-01-27 10:04:06 +01:00
|
|
|
rc := tt.RequestAuthGet[gin.H](t, admintok2, baseUrl, "/api/v2/users/"+uid2)
|
2023-01-17 22:56:04 +01:00
|
|
|
tt.AssertEqual(t, "is_pro", true, rc["is_pro"])
|
|
|
|
}
|
|
|
|
|
2023-01-27 10:04:06 +01:00
|
|
|
tt.RequestAuthPatch[gin.H](t, admintok0, baseUrl, "/api/v2/users/"+uid0, gin.H{"pro_token": "ANDROID|v2|PURCHASED:UNIQ_1"})
|
2023-01-17 22:56:04 +01:00
|
|
|
|
|
|
|
{
|
2023-01-27 10:04:06 +01:00
|
|
|
rc := tt.RequestAuthGet[gin.H](t, admintok0, baseUrl, "/api/v2/users/"+uid0)
|
2023-01-17 22:56:04 +01:00
|
|
|
tt.AssertEqual(t, "is_pro", true, rc["is_pro"])
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2023-01-27 10:04:06 +01:00
|
|
|
rc := tt.RequestAuthGet[gin.H](t, admintok1, baseUrl, "/api/v2/users/"+uid1)
|
2023-01-17 22:56:04 +01:00
|
|
|
tt.AssertEqual(t, "is_pro", false, rc["is_pro"])
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2023-01-27 10:04:06 +01:00
|
|
|
rc := tt.RequestAuthGet[gin.H](t, admintok2, baseUrl, "/api/v2/users/"+uid2)
|
2023-01-17 22:56:04 +01:00
|
|
|
tt.AssertEqual(t, "is_pro", false, rc["is_pro"])
|
2023-01-17 22:03:27 +01:00
|
|
|
}
|
|
|
|
|
2022-12-14 18:38:30 +01:00
|
|
|
}
|