API versioning ( basePath == /api/v2/* )

This commit is contained in:
Mike Schwörer 2023-01-27 10:04:06 +01:00
parent 27b189d33a
commit d1cefb0150
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
10 changed files with 253 additions and 247 deletions

View File

@ -49,7 +49,11 @@
- ios purchase verification
- api versioning (api/v2 ?)
- re-add ack labels as compat table for v1 api user
- return channel as "[..] asdf" in compat methods (mark clients as compat and send compat FB to them...)
(then we can replace the old server without switching phone clients)
(still needs switching of the send-script)
-
#### PERSONAL

View File

@ -40,7 +40,7 @@ func NewAPIHandler(app *logic.Application) APIHandler {
// @Failure 400 {object} ginresp.apiError "supplied values/parameters cannot be parsed / are invalid"
// @Failure 500 {object} ginresp.apiError "internal server error"
//
// @Router /api/users [POST]
// @Router /api/v2/users [POST]
func (h APIHandler) CreateUser(g *gin.Context) ginresp.HTTPResponse {
type body struct {
FCMToken string `json:"fcm_token"`
@ -148,7 +148,7 @@ func (h APIHandler) CreateUser(g *gin.Context) ginresp.HTTPResponse {
// @Failure 404 {object} ginresp.apiError "user not found"
// @Failure 500 {object} ginresp.apiError "internal server error"
//
// @Router /api/users/{uid} [GET]
// @Router /api/v2/users/{uid} [GET]
func (h APIHandler) GetUser(g *gin.Context) ginresp.HTTPResponse {
type uri struct {
UserID models.UserID `uri:"uid" binding:"entityid"`
@ -197,7 +197,7 @@ func (h APIHandler) GetUser(g *gin.Context) ginresp.HTTPResponse {
// @Failure 404 {object} ginresp.apiError "user not found"
// @Failure 500 {object} ginresp.apiError "internal server error"
//
// @Router /api/users/{uid} [PATCH]
// @Router /api/v2/users/{uid} [PATCH]
func (h APIHandler) UpdateUser(g *gin.Context) ginresp.HTTPResponse {
type uri struct {
UserID models.UserID `uri:"uid" binding:"entityid"`
@ -310,7 +310,7 @@ func (h APIHandler) UpdateUser(g *gin.Context) ginresp.HTTPResponse {
// @Failure 401 {object} ginresp.apiError "user is not authorized / has missing permissions"
// @Failure 500 {object} ginresp.apiError "internal server error"
//
// @Router /api/users/{uid}/clients [GET]
// @Router /api/v2/users/{uid}/clients [GET]
func (h APIHandler) ListClients(g *gin.Context) ginresp.HTTPResponse {
type uri struct {
UserID models.UserID `uri:"uid" binding:"entityid"`
@ -355,7 +355,7 @@ func (h APIHandler) ListClients(g *gin.Context) ginresp.HTTPResponse {
// @Failure 404 {object} ginresp.apiError "client not found"
// @Failure 500 {object} ginresp.apiError "internal server error"
//
// @Router /api/users/{uid}/clients/{cid} [GET]
// @Router /api/v2/users/{uid}/clients/{cid} [GET]
func (h APIHandler) GetClient(g *gin.Context) ginresp.HTTPResponse {
type uri struct {
UserID models.UserID `uri:"uid" binding:"entityid"`
@ -399,7 +399,7 @@ func (h APIHandler) GetClient(g *gin.Context) ginresp.HTTPResponse {
// @Failure 401 {object} ginresp.apiError "user is not authorized / has missing permissions"
// @Failure 500 {object} ginresp.apiError "internal server error"
//
// @Router /api/users/{uid}/clients [POST]
// @Router /api/v2/users/{uid}/clients [POST]
func (h APIHandler) AddClient(g *gin.Context) ginresp.HTTPResponse {
type uri struct {
UserID models.UserID `uri:"uid" binding:"entityid"`
@ -460,7 +460,7 @@ func (h APIHandler) AddClient(g *gin.Context) ginresp.HTTPResponse {
// @Failure 404 {object} ginresp.apiError "client not found"
// @Failure 500 {object} ginresp.apiError "internal server error"
//
// @Router /api/users/{uid}/clients/{cid} [DELETE]
// @Router /api/v2/users/{uid}/clients/{cid} [DELETE]
func (h APIHandler) DeleteClient(g *gin.Context) ginresp.HTTPResponse {
type uri struct {
UserID models.UserID `uri:"uid" binding:"entityid"`
@ -515,7 +515,7 @@ func (h APIHandler) DeleteClient(g *gin.Context) ginresp.HTTPResponse {
// @Failure 401 {object} ginresp.apiError "user is not authorized / has missing permissions"
// @Failure 500 {object} ginresp.apiError "internal server error"
//
// @Router /api/users/{uid}/channels [GET]
// @Router /api/v2/users/{uid}/channels [GET]
func (h APIHandler) ListChannels(g *gin.Context) ginresp.HTTPResponse {
type uri struct {
UserID models.UserID `uri:"uid" binding:"entityid"`
@ -607,7 +607,7 @@ func (h APIHandler) ListChannels(g *gin.Context) ginresp.HTTPResponse {
// @Failure 404 {object} ginresp.apiError "channel not found"
// @Failure 500 {object} ginresp.apiError "internal server error"
//
// @Router /api/users/{uid}/channels/{cid} [GET]
// @Router /api/v2/users/{uid}/channels/{cid} [GET]
func (h APIHandler) GetChannel(g *gin.Context) ginresp.HTTPResponse {
type uri struct {
UserID models.UserID `uri:"uid" binding:"entityid"`
@ -651,7 +651,7 @@ func (h APIHandler) GetChannel(g *gin.Context) ginresp.HTTPResponse {
// @Failure 409 {object} ginresp.apiError "channel already exists"
// @Failure 500 {object} ginresp.apiError "internal server error"
//
// @Router /api/users/{uid}/channels [POST]
// @Router /api/v2/users/{uid}/channels [POST]
func (h APIHandler) CreateChannel(g *gin.Context) ginresp.HTTPResponse {
type uri struct {
UserID models.UserID `uri:"uid" binding:"entityid"`
@ -748,7 +748,7 @@ func (h APIHandler) CreateChannel(g *gin.Context) ginresp.HTTPResponse {
// @Failure 404 {object} ginresp.apiError "channel not found"
// @Failure 500 {object} ginresp.apiError "internal server error"
//
// @Router /api/users/{uid}/channels/{cid} [PATCH]
// @Router /api/v2/users/{uid}/channels/{cid} [PATCH]
func (h APIHandler) UpdateChannel(g *gin.Context) ginresp.HTTPResponse {
type uri struct {
UserID models.UserID `uri:"uid" binding:"entityid"`
@ -873,7 +873,7 @@ func (h APIHandler) UpdateChannel(g *gin.Context) ginresp.HTTPResponse {
// @Failure 404 {object} ginresp.apiError "channel not found"
// @Failure 500 {object} ginresp.apiError "internal server error"
//
// @Router /api/users/{uid}/channels/{cid}/messages [GET]
// @Router /api/v2/users/{uid}/channels/{cid}/messages [GET]
func (h APIHandler) ListChannelMessages(g *gin.Context) ginresp.HTTPResponse {
type uri struct {
ChannelUserID models.UserID `uri:"uid" binding:"entityid"`
@ -976,7 +976,7 @@ func (h APIHandler) ListChannelMessages(g *gin.Context) ginresp.HTTPResponse {
// @Failure 401 {object} ginresp.apiError "user is not authorized / has missing permissions"
// @Failure 500 {object} ginresp.apiError "internal server error"
//
// @Router /api/users/{uid}/subscriptions [GET]
// @Router /api/v2/users/{uid}/subscriptions [GET]
func (h APIHandler) ListUserSubscriptions(g *gin.Context) ginresp.HTTPResponse {
type uri struct {
UserID models.UserID `uri:"uid" binding:"entityid"`
@ -1073,7 +1073,7 @@ func (h APIHandler) ListUserSubscriptions(g *gin.Context) ginresp.HTTPResponse {
// @Failure 404 {object} ginresp.apiError "channel not found"
// @Failure 500 {object} ginresp.apiError "internal server error"
//
// @Router /api/users/{uid}/channels/{cid}/subscriptions [GET]
// @Router /api/v2/users/{uid}/channels/{cid}/subscriptions [GET]
func (h APIHandler) ListChannelSubscriptions(g *gin.Context) ginresp.HTTPResponse {
type uri struct {
UserID models.UserID `uri:"uid" binding:"entityid"`
@ -1127,7 +1127,7 @@ func (h APIHandler) ListChannelSubscriptions(g *gin.Context) ginresp.HTTPRespons
// @Failure 404 {object} ginresp.apiError "subscription not found"
// @Failure 500 {object} ginresp.apiError "internal server error"
//
// @Router /api/users/{uid}/subscriptions/{sid} [GET]
// @Router /api/v2/users/{uid}/subscriptions/{sid} [GET]
func (h APIHandler) GetSubscription(g *gin.Context) ginresp.HTTPResponse {
type uri struct {
UserID models.UserID `uri:"uid" binding:"entityid"`
@ -1174,7 +1174,7 @@ func (h APIHandler) GetSubscription(g *gin.Context) ginresp.HTTPResponse {
// @Failure 404 {object} ginresp.apiError "subscription not found"
// @Failure 500 {object} ginresp.apiError "internal server error"
//
// @Router /api/users/{uid}/subscriptions/{sid} [DELETE]
// @Router /api/v2/users/{uid}/subscriptions/{sid} [DELETE]
func (h APIHandler) CancelSubscription(g *gin.Context) ginresp.HTTPResponse {
type uri struct {
UserID models.UserID `uri:"uid" binding:"entityid"`
@ -1227,7 +1227,7 @@ func (h APIHandler) CancelSubscription(g *gin.Context) ginresp.HTTPResponse {
// @Failure 401 {object} ginresp.apiError "user is not authorized / has missing permissions"
// @Failure 500 {object} ginresp.apiError "internal server error"
//
// @Router /api/users/{uid}/subscriptions [POST]
// @Router /api/v2/users/{uid}/subscriptions [POST]
func (h APIHandler) CreateSubscription(g *gin.Context) ginresp.HTTPResponse {
type uri struct {
UserID models.UserID `uri:"uid" binding:"entityid"`
@ -1316,7 +1316,7 @@ func (h APIHandler) CreateSubscription(g *gin.Context) ginresp.HTTPResponse {
// @Failure 404 {object} ginresp.apiError "subscription not found"
// @Failure 500 {object} ginresp.apiError "internal server error"
//
// @Router /api/users/{uid}/subscriptions/{sid} [PATCH]
// @Router /api/v2/users/{uid}/subscriptions/{sid} [PATCH]
func (h APIHandler) UpdateSubscription(g *gin.Context) ginresp.HTTPResponse {
type uri struct {
UserID models.UserID `uri:"uid" binding:"entityid"`
@ -1386,7 +1386,7 @@ func (h APIHandler) UpdateSubscription(g *gin.Context) ginresp.HTTPResponse {
// @Failure 401 {object} ginresp.apiError "user is not authorized / has missing permissions"
// @Failure 500 {object} ginresp.apiError "internal server error"
//
// @Router /api/messages [GET]
// @Router /api/v2/messages [GET]
func (h APIHandler) ListMessages(g *gin.Context) ginresp.HTTPResponse {
type query struct {
PageSize *int `json:"page_size" form:"page_size"`
@ -1469,7 +1469,7 @@ func (h APIHandler) ListMessages(g *gin.Context) ginresp.HTTPResponse {
// @Failure 404 {object} ginresp.apiError "message not found"
// @Failure 500 {object} ginresp.apiError "internal server error"
//
// @Router /api/messages/{mid} [PATCH]
// @Router /api/v2/messages/{mid} [PATCH]
func (h APIHandler) GetMessage(g *gin.Context) ginresp.HTTPResponse {
type uri struct {
MessageID models.MessageID `uri:"mid" binding:"entityid"`
@ -1539,7 +1539,7 @@ func (h APIHandler) GetMessage(g *gin.Context) ginresp.HTTPResponse {
// @Failure 404 {object} ginresp.apiError "message not found"
// @Failure 500 {object} ginresp.apiError "internal server error"
//
// @Router /api/messages/{mid} [DELETE]
// @Router /api/v2/messages/{mid} [DELETE]
func (h APIHandler) DeleteMessage(g *gin.Context) ginresp.HTTPResponse {
type uri struct {
MessageID models.MessageID `uri:"mid" binding:"entityid"`

View File

@ -59,7 +59,7 @@ func (r *Router) Init(e *gin.Engine) error {
return errors.New("failed to add validators - wrong engine")
}
// ================ General ================
// ================ General (unversioned) ================
commonAPI := e.Group("/api")
{
@ -118,9 +118,9 @@ func (r *Router) Init(e *gin.Engine) error {
compat.GET("/upgrade.php", r.Wrap(r.compatHandler.Upgrade))
}
// ================ Manage API ================
// ================ Manage API (v2) ================
apiv2 := e.Group("/api/")
apiv2 := e.Group("/api/v2/")
{
apiv2.POST("/users", r.Wrap(r.apiHandler.CreateUser))
@ -150,7 +150,7 @@ func (r *Router) Init(e *gin.Engine) error {
apiv2.DELETE("/messages/:mid", r.Wrap(r.apiHandler.DeleteMessage))
}
// ================ Send API ================
// ================ Send API (unversioned) ================
sendAPI := e.Group("")
{
@ -159,6 +159,8 @@ func (r *Router) Init(e *gin.Engine) error {
sendAPI.POST("/send.php", r.Wrap(r.messageHandler.SendMessageCompat))
}
// ================
if r.app.Config.ReturnRawErrors {
e.NoRoute(r.Wrap(r.commonHandler.NoRoute))
}

View File

@ -14,7 +14,7 @@ func TestCreateChannel(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -29,28 +29,28 @@ func TestCreateChannel(t *testing.T) {
}
{
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid))
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid))
tt.AssertMappedSet(t, "channels", []string{}, clist.Channels, "display_name")
tt.AssertMappedSet(t, "channels", []string{}, clist.Channels, "internal_name")
}
tt.RequestAuthPost[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid), gin.H{
tt.RequestAuthPost[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid), gin.H{
"name": "test",
})
{
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid))
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid))
tt.AssertEqual(t, "chan.len", 1, len(clist.Channels))
tt.AssertMappedSet(t, "channels", []string{"test"}, clist.Channels, "display_name")
tt.AssertMappedSet(t, "channels", []string{"test"}, clist.Channels, "internal_name")
}
tt.RequestAuthPost[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid), gin.H{
tt.RequestAuthPost[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid), gin.H{
"name": "asdf",
})
{
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid))
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid))
tt.AssertMappedSet(t, "channels", []string{"asdf", "test"}, clist.Channels, "display_name")
tt.AssertMappedSet(t, "channels", []string{"asdf", "test"}, clist.Channels, "internal_name")
}
@ -60,7 +60,7 @@ func TestCreateChannelNameTooLong(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -70,7 +70,7 @@ func TestCreateChannelNameTooLong(t *testing.T) {
uid := r0["user_id"].(string)
admintok := r0["admin_key"].(string)
tt.RequestAuthPostShouldFail(t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid), gin.H{
tt.RequestAuthPostShouldFail(t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid), gin.H{
"name": langext.StrRepeat("X", 121),
}, 400, apierr.CHANNEL_TOO_LONG)
}
@ -79,7 +79,7 @@ func TestChannelNameNormalization(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -94,57 +94,57 @@ func TestChannelNameNormalization(t *testing.T) {
}
{
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid))
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid))
tt.AssertMappedSet(t, "channels", []string{}, clist.Channels, "display_name")
tt.AssertMappedSet(t, "channels", []string{}, clist.Channels, "internal_name")
}
tt.RequestAuthPost[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid), gin.H{
tt.RequestAuthPost[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid), gin.H{
"name": "tESt",
})
{
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid))
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid))
tt.AssertMappedSet(t, "channels", []string{"tESt"}, clist.Channels, "display_name")
tt.AssertMappedSet(t, "channels", []string{"test"}, clist.Channels, "internal_name")
}
tt.RequestAuthPostShouldFail(t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid), gin.H{
tt.RequestAuthPostShouldFail(t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid), gin.H{
"name": "test",
}, 409, apierr.CHANNEL_ALREADY_EXISTS)
tt.RequestAuthPostShouldFail(t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid), gin.H{
tt.RequestAuthPostShouldFail(t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid), gin.H{
"name": "TEST",
}, 409, apierr.CHANNEL_ALREADY_EXISTS)
tt.RequestAuthPostShouldFail(t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid), gin.H{
tt.RequestAuthPostShouldFail(t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid), gin.H{
"name": "Test",
}, 409, apierr.CHANNEL_ALREADY_EXISTS)
tt.RequestAuthPostShouldFail(t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid), gin.H{
tt.RequestAuthPostShouldFail(t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid), gin.H{
"name": "Test ",
}, 409, apierr.CHANNEL_ALREADY_EXISTS)
tt.RequestAuthPostShouldFail(t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid), gin.H{
tt.RequestAuthPostShouldFail(t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid), gin.H{
"name": " Test",
}, 409, apierr.CHANNEL_ALREADY_EXISTS)
tt.RequestAuthPostShouldFail(t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid), gin.H{
tt.RequestAuthPostShouldFail(t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid), gin.H{
"name": "\rTeSt\n",
}, 409, apierr.CHANNEL_ALREADY_EXISTS)
{
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid))
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid))
tt.AssertMappedSet(t, "channels", []string{"tESt"}, clist.Channels, "display_name")
tt.AssertMappedSet(t, "channels", []string{"test"}, clist.Channels, "internal_name")
}
tt.RequestAuthPost[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid), gin.H{
tt.RequestAuthPost[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid), gin.H{
"name": " WeiRD_[\uF5FF]\\stUFf\r\n\t ",
})
{
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid))
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid))
tt.AssertMappedSet(t, "channels", []string{"tESt", "WeiRD_[\uF5FF]\\stUFf"}, clist.Channels, "display_name")
tt.AssertMappedSet(t, "channels", []string{"test", "weird_[\uF5FF]\\stuff"}, clist.Channels, "internal_name")
}
@ -181,7 +181,7 @@ func TestListChannelsDefault(t *testing.T) {
}
for k, v := range testdata {
r0 := tt.RequestAuthGet[chanlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/users/%s/channels", data.User[k].UID))
r0 := tt.RequestAuthGet[chanlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", data.User[k].UID))
tt.AssertMappedSet(t, fmt.Sprintf("%d->chanlist", k), v, r0.Channels, "internal_name")
}
}
@ -216,7 +216,7 @@ func TestListChannelsOwned(t *testing.T) {
}
for k, v := range testdata {
r0 := tt.RequestAuthGet[chanlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/users/%s/channels?selector=%s", data.User[k].UID, "owned"))
r0 := tt.RequestAuthGet[chanlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels?selector=%s", data.User[k].UID, "owned"))
tt.AssertMappedSet(t, fmt.Sprintf("%d->chanlist", k), v, r0.Channels, "internal_name")
}
}
@ -251,7 +251,7 @@ func TestListChannelsSubscribedAny(t *testing.T) {
}
for k, v := range testdata {
r0 := tt.RequestAuthGet[chanlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/users/%s/channels?selector=%s", data.User[k].UID, "subscribed_any"))
r0 := tt.RequestAuthGet[chanlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels?selector=%s", data.User[k].UID, "subscribed_any"))
tt.AssertMappedSet(t, fmt.Sprintf("%d->chanlist", k), v, r0.Channels, "internal_name")
}
}
@ -286,7 +286,7 @@ func TestListChannelsAllAny(t *testing.T) {
}
for k, v := range testdata {
r0 := tt.RequestAuthGet[chanlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/users/%s/channels?selector=%s", data.User[k].UID, "all_any"))
r0 := tt.RequestAuthGet[chanlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels?selector=%s", data.User[k].UID, "all_any"))
tt.AssertMappedSet(t, fmt.Sprintf("%d->chanlist", k), v, r0.Channels, "internal_name")
}
}
@ -321,7 +321,7 @@ func TestListChannelsSubscribed(t *testing.T) {
}
for k, v := range testdata {
r0 := tt.RequestAuthGet[chanlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/users/%s/channels?selector=%s", data.User[k].UID, "subscribed"))
r0 := tt.RequestAuthGet[chanlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels?selector=%s", data.User[k].UID, "subscribed"))
tt.AssertMappedSet(t, fmt.Sprintf("%d->chanlist", k), v, r0.Channels, "internal_name")
}
}
@ -356,7 +356,7 @@ func TestListChannelsAll(t *testing.T) {
}
for k, v := range testdata {
r0 := tt.RequestAuthGet[chanlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/users/%s/channels?selector=%s", data.User[k].UID, "all"))
r0 := tt.RequestAuthGet[chanlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels?selector=%s", data.User[k].UID, "all"))
tt.AssertMappedSet(t, fmt.Sprintf("%d->chanlist", k), v, r0.Channels, "internal_name")
}
}
@ -365,7 +365,7 @@ func TestChannelUpdate(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -380,25 +380,25 @@ func TestChannelUpdate(t *testing.T) {
}
{
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid))
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid))
tt.AssertMappedSet(t, "channels", []string{}, clist.Channels, "display_name")
tt.AssertMappedSet(t, "channels", []string{}, clist.Channels, "internal_name")
}
chan0 := tt.RequestAuthPost[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid), gin.H{
chan0 := tt.RequestAuthPost[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid), gin.H{
"name": "server-alerts",
})
chanid := fmt.Sprintf("%v", chan0["channel_id"])
{
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid))
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid))
tt.AssertMappedSet(t, "channels", []string{"server-alerts"}, clist.Channels, "display_name")
tt.AssertMappedSet(t, "channels", []string{"server-alerts"}, clist.Channels, "internal_name")
tt.AssertEqual(t, "channels.descr", nil, clist.Channels[0]["description_name"])
}
{
chan1 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels/%s", uid, chanid))
chan1 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels/%s", uid, chanid))
tt.AssertEqual(t, "channels.display_name", "server-alerts", chan1["display_name"])
tt.AssertEqual(t, "channels.internal_name", "server-alerts", chan1["internal_name"])
tt.AssertEqual(t, "channels.description_name", nil, chan1["description_name"])
@ -408,12 +408,12 @@ func TestChannelUpdate(t *testing.T) {
// [1] update display_name
tt.RequestAuthPatch[tt.Void](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels/%s", uid, chanid), gin.H{
tt.RequestAuthPatch[tt.Void](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels/%s", uid, chanid), gin.H{
"display_name": "SERVER-ALERTS",
})
{
chan1 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels/%s", uid, chanid))
chan1 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels/%s", uid, chanid))
tt.AssertEqual(t, "channels.display_name", "SERVER-ALERTS", chan1["display_name"])
tt.AssertEqual(t, "channels.internal_name", "server-alerts", chan1["internal_name"])
tt.AssertEqual(t, "channels.description_name", nil, chan1["description_name"])
@ -423,70 +423,70 @@ func TestChannelUpdate(t *testing.T) {
// [2] fail to update display_name
tt.RequestAuthPatchShouldFail(t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels/%s", uid, chanid), gin.H{
tt.RequestAuthPatchShouldFail(t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels/%s", uid, chanid), gin.H{
"display_name": "SERVER-ALERTS2",
}, 400, apierr.CHANNEL_NAME_WOULD_CHANGE)
// [3] renew subscribe_key
tt.RequestAuthPatch[tt.Void](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels/%s", uid, chanid), gin.H{
tt.RequestAuthPatch[tt.Void](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels/%s", uid, chanid), gin.H{
"subscribe_key": true,
})
{
chan1 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels/%s", uid, chanid))
chan1 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels/%s", uid, chanid))
tt.AssertNotEqual(t, "channels.subscribe_key", chan0["subscribe_key"], chan1["subscribe_key"])
tt.AssertEqual(t, "channels.send_key", chan0["send_key"], chan1["send_key"])
}
// [4] renew send_key
tt.RequestAuthPatch[tt.Void](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels/%s", uid, chanid), gin.H{
tt.RequestAuthPatch[tt.Void](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels/%s", uid, chanid), gin.H{
"send_key": true,
})
{
chan1 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels/%s", uid, chanid))
chan1 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels/%s", uid, chanid))
tt.AssertNotEqual(t, "channels.subscribe_key", chan0["subscribe_key"], chan1["subscribe_key"])
tt.AssertNotEqual(t, "channels.send_key", chan0["send_key"], chan1["send_key"])
}
// [5] update description_name
tt.RequestAuthPatch[tt.Void](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels/%s", uid, chanid), gin.H{
tt.RequestAuthPatch[tt.Void](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels/%s", uid, chanid), gin.H{
"description_name": "hello World",
})
{
chan1 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels/%s", uid, chanid))
chan1 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels/%s", uid, chanid))
tt.AssertEqual(t, "channels.description_name", "hello World", chan1["description_name"])
}
// [6] update description_name
tt.RequestAuthPatch[tt.Void](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels/%s", uid, chanid), gin.H{
tt.RequestAuthPatch[tt.Void](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels/%s", uid, chanid), gin.H{
"description_name": " AXXhello World9 ",
})
{
chan1 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels/%s", uid, chanid))
chan1 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels/%s", uid, chanid))
tt.AssertEqual(t, "channels.description_name", "AXXhello World9", chan1["description_name"])
}
// [7] clear description_name
tt.RequestAuthPatch[tt.Void](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels/%s", uid, chanid), gin.H{
tt.RequestAuthPatch[tt.Void](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels/%s", uid, chanid), gin.H{
"description_name": "",
})
{
chan1 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels/%s", uid, chanid))
chan1 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels/%s", uid, chanid))
tt.AssertEqual(t, "channels.description_name", nil, chan1["description_name"])
}
// [8] fail to update description_name
tt.RequestAuthPatchShouldFail(t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels/%s", uid, chanid), gin.H{
tt.RequestAuthPatchShouldFail(t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels/%s", uid, chanid), gin.H{
"description_name": strings.Repeat("0123456789", 48),
}, 400, apierr.CHANNEL_DESCRIPTION_TOO_LONG)

View File

@ -13,7 +13,7 @@ func TestGetClient(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -29,7 +29,7 @@ func TestGetClient(t *testing.T) {
fmt.Printf("uid := %s\n", uid)
fmt.Printf("admin_key := %s\n", admintok)
r1 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/users/"+uid)
r1 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid)
tt.AssertEqual(t, "uid", uid, fmt.Sprintf("%v", r1["user_id"]))
tt.AssertEqual(t, "admin_key", admintok, r1["admin_key"])
@ -39,7 +39,7 @@ func TestGetClient(t *testing.T) {
Clients []gin.H `json:"clients"`
}
r2 := tt.RequestAuthGet[rt2](t, admintok, baseUrl, "/api/users/"+uid+"/clients")
r2 := tt.RequestAuthGet[rt2](t, admintok, baseUrl, "/api/v2/users/"+uid+"/clients")
tt.AssertEqual(t, "len(clients)", 1, len(r2.Clients))
@ -53,7 +53,7 @@ func TestGetClient(t *testing.T) {
cid := fmt.Sprintf("%v", c0["client_id"])
r3 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/users/"+uid+"/clients/"+cid)
r3 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid+"/clients/"+cid)
tt.AssertJsonMapEqual(t, "client", r3, c0)
}
@ -62,7 +62,7 @@ func TestCreateAndDeleteClient(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -78,7 +78,7 @@ func TestCreateAndDeleteClient(t *testing.T) {
fmt.Printf("uid := %s\n", uid)
fmt.Printf("admin_key := %s\n", admintok)
r2 := tt.RequestAuthPost[gin.H](t, admintok, baseUrl, "/api/users/"+uid+"/clients", gin.H{
r2 := tt.RequestAuthPost[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid+"/clients", gin.H{
"agent_model": "DUMMY_PHONE_2",
"agent_version": "99X",
"client_type": "IOS",
@ -91,13 +91,13 @@ func TestCreateAndDeleteClient(t *testing.T) {
Clients []gin.H `json:"clients"`
}
r3 := tt.RequestAuthGet[rt3](t, admintok, baseUrl, "/api/users/"+uid+"/clients")
r3 := tt.RequestAuthGet[rt3](t, admintok, baseUrl, "/api/v2/users/"+uid+"/clients")
tt.AssertEqual(t, "len(clients)", 2, len(r3.Clients))
r4 := tt.RequestAuthDelete[gin.H](t, admintok, baseUrl, "/api/users/"+uid+"/clients/"+cid2, nil)
r4 := tt.RequestAuthDelete[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid+"/clients/"+cid2, nil)
tt.AssertEqual(t, "client_id", cid2, fmt.Sprintf("%v", r4["client_id"]))
r5 := tt.RequestAuthGet[rt3](t, admintok, baseUrl, "/api/users/"+uid+"/clients")
r5 := tt.RequestAuthGet[rt3](t, admintok, baseUrl, "/api/v2/users/"+uid+"/clients")
tt.AssertEqual(t, "len(clients)", 1, len(r5.Clients))
}
@ -105,7 +105,7 @@ func TestReuseFCM(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -125,11 +125,11 @@ func TestReuseFCM(t *testing.T) {
Clients []gin.H `json:"clients"`
}
r1 := tt.RequestAuthGet[rt2](t, admintok, baseUrl, "/api/users/"+uid+"/clients")
r1 := tt.RequestAuthGet[rt2](t, admintok, baseUrl, "/api/v2/users/"+uid+"/clients")
tt.AssertEqual(t, "len(clients)", 1, len(r1.Clients))
r2 := tt.RequestAuthPost[gin.H](t, admintok, baseUrl, "/api/users/"+uid+"/clients", gin.H{
r2 := tt.RequestAuthPost[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid+"/clients", gin.H{
"agent_model": "DUMMY_PHONE_2",
"agent_version": "99X",
"client_type": "IOS",
@ -142,7 +142,7 @@ func TestReuseFCM(t *testing.T) {
Clients []gin.H `json:"clients"`
}
r3 := tt.RequestAuthGet[rt3](t, admintok, baseUrl, "/api/users/"+uid+"/clients")
r3 := tt.RequestAuthGet[rt3](t, admintok, baseUrl, "/api/v2/users/"+uid+"/clients")
tt.AssertEqual(t, "len(clients)", 1, len(r3.Clients))
tt.AssertEqual(t, "clients->client_id", cid2, fmt.Sprintf("%v", r3.Clients[0]["client_id"]))
@ -184,11 +184,11 @@ func TestListClients(t *testing.T) {
}
for k, v := range vals {
clist1 := tt.RequestAuthGet[clientlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/users/%s/clients", url.QueryEscape(data.User[k].UID)))
clist1 := tt.RequestAuthGet[clientlist](t, data.User[k].AdminKey, baseUrl, fmt.Sprintf("/api/v2/users/%s/clients", url.QueryEscape(data.User[k].UID)))
tt.AssertMappedSet(t, fmt.Sprintf("clients[%d]->type", k), v.CT, clist1.Clients, "type")
tt.AssertMappedSet(t, fmt.Sprintf("clients[%d]->agent_model", k), v.AM, clist1.Clients, "agent_model")
tt.AssertMappedSet(t, fmt.Sprintf("clients[%d]->agent_version", k), v.AV, clist1.Clients, "agent_version")
}
tt.RequestAuthGetShouldFail(t, data.User[0].AdminKey, baseUrl, fmt.Sprintf("/api/users/%s/clients", url.QueryEscape(data.User[1].UID)), 401, apierr.USER_AUTH_FAILED)
tt.RequestAuthGetShouldFail(t, data.User[0].AdminKey, baseUrl, fmt.Sprintf("/api/v2/users/%s/clients", url.QueryEscape(data.User[1].UID)), 401, apierr.USER_AUTH_FAILED)
}

View File

@ -46,10 +46,10 @@ func TestSendCompatWithOldUser(t *testing.T) {
Messages []gin.H `json:"messages"`
}
msgList1 := tt.RequestAuthGet[mglist](t, admintok, baseUrl, "/api/messages")
msgList1 := tt.RequestAuthGet[mglist](t, admintok, baseUrl, "/api/v2/messages")
tt.AssertEqual(t, "len(messages)", 1, len(msgList1.Messages))
msg1Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/messages/"+fmt.Sprintf("%v", pusher.Last().Message.MessageID))
msg1Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", pusher.Last().Message.MessageID))
tt.AssertStrRepEqual(t, "msg.title", "HelloWorld_001", msg1Get["title"])
tt.AssertStrRepEqual(t, "msg.channel_internal_name", "main", msg1Get["channel_internal_name"])
@ -62,7 +62,7 @@ func TestSendCompatWithOldUser(t *testing.T) {
exp2 := tt.RequestGet[gin.H](t, baseUrl, fmt.Sprintf("/api/expand.php?user_id=%d&user_key=%s&scn_msg_id=%d", uidold, admintok, int64(msg2["scn_msg_id"].(float64))))
tt.AssertEqual(t, "success", true, exp2["success"])
tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/messages/"+fmt.Sprintf("%v", pusher.Last().Message.MessageID))
tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", pusher.Last().Message.MessageID))
content3 := "039c1817-76ee-44ab-972a-4cec0a15a791\n" +
"046f59ea-9a49-4060-93e6-8a4e14134faf\n" +
@ -85,7 +85,7 @@ func TestSendCompatWithOldUser(t *testing.T) {
"timestamp": fmt.Sprintf("%d", ts3),
})
tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/messages/"+fmt.Sprintf("%v", pusher.Last().Message.MessageID))
tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", pusher.Last().Message.MessageID))
tt.AssertEqual(t, "messageCount", 3, len(pusher.Data))
tt.AssertStrRepEqual(t, "msg.Title", "HelloWorld_003", pusher.Last().Message.Title)
@ -104,7 +104,7 @@ func TestSendCompatWithNewUser(t *testing.T) {
pusher := ws.Pusher.(*push.TestSink)
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -142,10 +142,10 @@ func TestSendCompatWithNewUser(t *testing.T) {
Messages []gin.H `json:"messages"`
}
msgList1 := tt.RequestAuthGet[mglist](t, admintok, baseUrl, "/api/messages")
msgList1 := tt.RequestAuthGet[mglist](t, admintok, baseUrl, "/api/v2/messages")
tt.AssertEqual(t, "len(messages)", 1, len(msgList1.Messages))
msg1Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/messages/"+fmt.Sprintf("%v", pusher.Last().Message.MessageID))
msg1Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", pusher.Last().Message.MessageID))
tt.AssertStrRepEqual(t, "msg.title", "HelloWorld_001", msg1Get["title"])
tt.AssertStrRepEqual(t, "msg.channel_internal_name", "main", msg1Get["channel_internal_name"])
@ -158,7 +158,7 @@ func TestSendCompatWithNewUser(t *testing.T) {
exp2 := tt.RequestGet[gin.H](t, baseUrl, fmt.Sprintf("/api/expand.php?user_id=%d&user_key=%s&scn_msg_id=%d", uidold, admintok, int64(msg2["scn_msg_id"].(float64))))
tt.AssertEqual(t, "success", true, exp2["success"])
tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/messages/"+fmt.Sprintf("%v", pusher.Last().Message.MessageID))
tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", pusher.Last().Message.MessageID))
content3 := "039c1817-76ee-44ab-972a-4cec0a15a791\n" +
"046f59ea-9a49-4060-93e6-8a4e14134faf\n" +
@ -183,7 +183,7 @@ func TestSendCompatWithNewUser(t *testing.T) {
exp3 := tt.RequestGet[gin.H](t, baseUrl, fmt.Sprintf("/api/expand.php?user_id=%d&user_key=%s&scn_msg_id=%d", uidold, admintok, int64(msg3["scn_msg_id"].(float64))))
tt.AssertEqual(t, "success", true, exp3["success"])
tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/messages/"+fmt.Sprintf("%v", pusher.Last().Message.MessageID))
tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", pusher.Last().Message.MessageID))
tt.AssertEqual(t, "messageCount", 3, len(pusher.Data))
tt.AssertStrRepEqual(t, "msg.Title", "HelloWorld_003", pusher.Last().Message.Title)

View File

@ -22,7 +22,7 @@ func TestSearchMessageFTSSimple(t *testing.T) {
Messages []gin.H `json:"messages"`
}
msgList := tt.RequestAuthGet[mglist](t, data.User[0].AdminKey, baseUrl, fmt.Sprintf("/api/messages?filter=%s", url.QueryEscape("Friday")))
msgList := tt.RequestAuthGet[mglist](t, data.User[0].AdminKey, baseUrl, fmt.Sprintf("/api/v2/messages?filter=%s", url.QueryEscape("Friday")))
tt.AssertEqual(t, "msgList.len", 2, len(msgList.Messages))
tt.AssertArrAny(t, "msgList.any<1>", msgList.Messages, func(msg gin.H) bool { return msg["title"].(string) == "Invitation" })
tt.AssertArrAny(t, "msgList.any<2>", msgList.Messages, func(msg gin.H) bool { return msg["title"].(string) == "Important notice" })
@ -42,7 +42,7 @@ func TestDeleteMessage(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -59,18 +59,18 @@ func TestDeleteMessage(t *testing.T) {
"title": "Message_1",
})
tt.RequestAuthGet[tt.Void](t, admintok, baseUrl, "/api/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]))
tt.RequestAuthGet[tt.Void](t, admintok, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]))
tt.RequestAuthDelete[tt.Void](t, admintok, baseUrl, "/api/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]), gin.H{})
tt.RequestAuthDelete[tt.Void](t, admintok, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]), gin.H{})
tt.RequestAuthGetShouldFail(t, admintok, baseUrl, "/api/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]), 404, apierr.MESSAGE_NOT_FOUND)
tt.RequestAuthGetShouldFail(t, admintok, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]), 404, apierr.MESSAGE_NOT_FOUND)
}
func TestDeleteMessageAndResendUsrMsgId(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -90,7 +90,7 @@ func TestDeleteMessageAndResendUsrMsgId(t *testing.T) {
tt.AssertEqual(t, "suppress_send", false, msg1["suppress_send"])
tt.RequestAuthGet[tt.Void](t, admintok, baseUrl, "/api/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]))
tt.RequestAuthGet[tt.Void](t, admintok, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]))
msg2 := tt.RequestPost[gin.H](t, baseUrl, "/", gin.H{
"user_key": sendtok,
@ -101,7 +101,7 @@ func TestDeleteMessageAndResendUsrMsgId(t *testing.T) {
tt.AssertEqual(t, "suppress_send", true, msg2["suppress_send"])
tt.RequestAuthDelete[tt.Void](t, admintok, baseUrl, "/api/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]), gin.H{})
tt.RequestAuthDelete[tt.Void](t, admintok, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]), gin.H{})
// even though message is deleted, we still get a `suppress_send` on send_message
@ -128,7 +128,7 @@ func TestGetMessageSimple(t *testing.T) {
"title": "Message_1",
})
msgIn := tt.RequestAuthGet[gin.H](t, data.User[0].AdminKey, baseUrl, "/api/messages/"+fmt.Sprintf("%v", msgOut["scn_msg_id"]))
msgIn := tt.RequestAuthGet[gin.H](t, data.User[0].AdminKey, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", msgOut["scn_msg_id"]))
tt.AssertEqual(t, "msg.title", "Message_1", msgIn["title"])
}
@ -139,7 +139,7 @@ func TestGetMessageNotFound(t *testing.T) {
data := tt.InitDefaultData(t, ws)
tt.RequestAuthGetShouldFail(t, data.User[0].AdminKey, baseUrl, "/api/messages/"+models.NewMessageID().String(), 404, apierr.MESSAGE_NOT_FOUND)
tt.RequestAuthGetShouldFail(t, data.User[0].AdminKey, baseUrl, "/api/v2/messages/"+models.NewMessageID().String(), 404, apierr.MESSAGE_NOT_FOUND)
}
func TestGetMessageInvalidID(t *testing.T) {
@ -148,9 +148,9 @@ func TestGetMessageInvalidID(t *testing.T) {
data := tt.InitDefaultData(t, ws)
tt.RequestAuthGetShouldFail(t, data.User[0].AdminKey, baseUrl, "/api/messages/"+models.NewUserID().String(), 400, apierr.BINDFAIL_URI_PARAM)
tt.RequestAuthGetShouldFail(t, data.User[0].AdminKey, baseUrl, "/api/v2/messages/"+models.NewUserID().String(), 400, apierr.BINDFAIL_URI_PARAM)
tt.RequestAuthGetShouldFail(t, data.User[0].AdminKey, baseUrl, "/api/messages/"+"asdfxxx", 400, apierr.BINDFAIL_URI_PARAM)
tt.RequestAuthGetShouldFail(t, data.User[0].AdminKey, baseUrl, "/api/v2/messages/"+"asdfxxx", 400, apierr.BINDFAIL_URI_PARAM)
}
func TestGetMessageFull(t *testing.T) {
@ -174,7 +174,7 @@ func TestGetMessageFull(t *testing.T) {
"timestamp": ts,
})
msgIn := tt.RequestAuthGet[gin.H](t, data.User[0].AdminKey, baseUrl, "/api/messages/"+fmt.Sprintf("%v", msgOut["scn_msg_id"]))
msgIn := tt.RequestAuthGet[gin.H](t, data.User[0].AdminKey, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", msgOut["scn_msg_id"]))
tt.AssertEqual(t, "msg.title", "Message_1", msgIn["title"])
tt.AssertEqual(t, "msg.content", content, msgIn["content"])

View File

@ -18,7 +18,7 @@ func TestSendSimpleMessageJSON(t *testing.T) {
pusher := ws.Pusher.(*push.TestSink)
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -57,10 +57,10 @@ func TestSendSimpleMessageJSON(t *testing.T) {
Messages []gin.H `json:"messages"`
}
msgList1 := tt.RequestAuthGet[mglist](t, admintok, baseUrl, "/api/messages")
msgList1 := tt.RequestAuthGet[mglist](t, admintok, baseUrl, "/api/v2/messages")
tt.AssertEqual(t, "len(messages)", 1, len(msgList1.Messages))
msg1Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]))
msg1Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]))
tt.AssertStrRepEqual(t, "msg.title", "HelloWorld_001", msg1Get["title"])
tt.AssertStrRepEqual(t, "msg.channel_internal_name", "main", msg1Get["channel_internal_name"])
}
@ -71,7 +71,7 @@ func TestSendSimpleMessageQuery(t *testing.T) {
pusher := ws.Pusher.(*push.TestSink)
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -93,10 +93,10 @@ func TestSendSimpleMessageQuery(t *testing.T) {
Messages []gin.H `json:"messages"`
}
msgList1 := tt.RequestAuthGet[mglist](t, admintok, baseUrl, "/api/messages")
msgList1 := tt.RequestAuthGet[mglist](t, admintok, baseUrl, "/api/v2/messages")
tt.AssertEqual(t, "len(messages)", 1, len(msgList1.Messages))
msg1Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]))
msg1Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]))
tt.AssertStrRepEqual(t, "msg.title", "Hello World 2134", msg1Get["title"])
tt.AssertStrRepEqual(t, "msg.channel_internal_name", "main", msg1Get["channel_internal_name"])
}
@ -107,7 +107,7 @@ func TestSendSimpleMessageForm(t *testing.T) {
pusher := ws.Pusher.(*push.TestSink)
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -133,10 +133,10 @@ func TestSendSimpleMessageForm(t *testing.T) {
Messages []gin.H `json:"messages"`
}
msgList1 := tt.RequestAuthGet[mglist](t, admintok, baseUrl, "/api/messages")
msgList1 := tt.RequestAuthGet[mglist](t, admintok, baseUrl, "/api/v2/messages")
tt.AssertEqual(t, "len(messages)", 1, len(msgList1.Messages))
msg1Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]))
msg1Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]))
tt.AssertStrRepEqual(t, "msg.title", "Hello World 9999 [$$$]", msg1Get["title"])
tt.AssertStrRepEqual(t, "msg.channel_internal_name", "main", msg1Get["channel_internal_name"])
}
@ -147,7 +147,7 @@ func TestSendSimpleMessageFormAndQuery(t *testing.T) {
pusher := ws.Pusher.(*push.TestSink)
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -174,7 +174,7 @@ func TestSendSimpleMessageJSONAndQuery(t *testing.T) {
pusher := ws.Pusher.(*push.TestSink)
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -202,7 +202,7 @@ func TestSendSimpleMessageAlt1(t *testing.T) {
pusher := ws.Pusher.(*push.TestSink)
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -235,10 +235,10 @@ func TestSendSimpleMessageAlt1(t *testing.T) {
Messages []gin.H `json:"messages"`
}
msgList1 := tt.RequestAuthGet[mglist](t, admintok, baseUrl, "/api/messages")
msgList1 := tt.RequestAuthGet[mglist](t, admintok, baseUrl, "/api/v2/messages")
tt.AssertEqual(t, "len(messages)", 1, len(msgList1.Messages))
msg1Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]))
msg1Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]))
tt.AssertStrRepEqual(t, "msg.title", "HelloWorld_001", msg1Get["title"])
tt.AssertStrRepEqual(t, "msg.channel_internal_name", "main", msg1Get["channel_internal_name"])
}
@ -249,7 +249,7 @@ func TestSendContentMessage(t *testing.T) {
pusher := ws.Pusher.(*push.TestSink)
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -276,13 +276,13 @@ func TestSendContentMessage(t *testing.T) {
Messages []gin.H `json:"messages"`
}
msgList1 := tt.RequestAuthGet[mglist](t, admintok, baseUrl, "/api/messages")
msgList1 := tt.RequestAuthGet[mglist](t, admintok, baseUrl, "/api/v2/messages")
tt.AssertEqual(t, "len(messages)", 1, len(msgList1.Messages))
tt.AssertStrRepEqual(t, "msg.title", "HelloWorld_042", msgList1.Messages[0]["title"])
tt.AssertStrRepEqual(t, "msg.content", "I am Content\nasdf", msgList1.Messages[0]["content"])
tt.AssertStrRepEqual(t, "msg.channel_internal_name", "main", msgList1.Messages[0]["channel_internal_name"])
msg1Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]))
msg1Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]))
tt.AssertStrRepEqual(t, "msg.title", "HelloWorld_042", msg1Get["title"])
tt.AssertStrRepEqual(t, "msg.content", "I am Content\nasdf", msg1Get["content"])
tt.AssertStrRepEqual(t, "msg.channel_internal_name", "main", msg1Get["channel_internal_name"])
@ -294,7 +294,7 @@ func TestSendWithSendername(t *testing.T) {
pusher := ws.Pusher.(*push.TestSink)
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -323,14 +323,14 @@ func TestSendWithSendername(t *testing.T) {
Messages []gin.H `json:"messages"`
}
msgList1 := tt.RequestAuthGet[mglist](t, admintok, baseUrl, "/api/messages")
msgList1 := tt.RequestAuthGet[mglist](t, admintok, baseUrl, "/api/v2/messages")
tt.AssertEqual(t, "len(messages)", 1, len(msgList1.Messages))
tt.AssertStrRepEqual(t, "msg.title", "HelloWorld_xyz", msgList1.Messages[0]["title"])
tt.AssertStrRepEqual(t, "msg.content", "Unicode: 日本 - yäy\000\n\t\x00...", msgList1.Messages[0]["content"])
tt.AssertStrRepEqual(t, "msg.sender_name", "localhorst", msgList1.Messages[0]["sender_name"])
tt.AssertStrRepEqual(t, "msg.channel_internal_name", "main", msgList1.Messages[0]["channel_internal_name"])
msg1Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]))
msg1Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]))
tt.AssertStrRepEqual(t, "msg.title", "HelloWorld_xyz", msg1Get["title"])
tt.AssertStrRepEqual(t, "msg.content", "Unicode: 日本 - yäy\000\n\t\x00...", msg1Get["content"])
tt.AssertStrRepEqual(t, "msg.sender_name", "localhorst", msg1Get["sender_name"])
@ -343,7 +343,7 @@ func TestSendLongContent(t *testing.T) {
pusher := ws.Pusher.(*push.TestSink)
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -375,21 +375,21 @@ func TestSendLongContent(t *testing.T) {
Messages []gin.H `json:"messages"`
}
msgList1 := tt.RequestAuthGet[mglist](t, admintok, baseUrl, "/api/messages")
msgList1 := tt.RequestAuthGet[mglist](t, admintok, baseUrl, "/api/v2/messages")
tt.AssertEqual(t, "len(messages)", 1, len(msgList1.Messages))
tt.AssertStrRepEqual(t, "msg.title", "HelloWorld_042", msgList1.Messages[0]["title"])
tt.AssertNotStrRepEqual(t, "msg.content", longContent, msgList1.Messages[0]["content"])
tt.AssertStrRepEqual(t, "msg.channel_internal_name", "main", msgList1.Messages[0]["channel_internal_name"])
tt.AssertStrRepEqual(t, "msg.trimmmed", true, msgList1.Messages[0]["trimmed"])
msgList2 := tt.RequestAuthGet[mglist](t, admintok, baseUrl, "/api/messages?trimmed=false")
msgList2 := tt.RequestAuthGet[mglist](t, admintok, baseUrl, "/api/v2/messages?trimmed=false")
tt.AssertEqual(t, "len(messages)", 1, len(msgList2.Messages))
tt.AssertStrRepEqual(t, "msg.title", "HelloWorld_042", msgList2.Messages[0]["title"])
tt.AssertStrRepEqual(t, "msg.content", longContent, msgList2.Messages[0]["content"])
tt.AssertStrRepEqual(t, "msg.channel_internal_name", "main", msgList2.Messages[0]["channel_internal_name"])
tt.AssertStrRepEqual(t, "msg.trimmmed", false, msgList2.Messages[0]["trimmed"])
msg1Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]))
msg1Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]))
tt.AssertStrRepEqual(t, "msg.title", "HelloWorld_042", msg1Get["title"])
tt.AssertStrRepEqual(t, "msg.titcontentle", longContent, msg1Get["content"])
tt.AssertStrRepEqual(t, "msg.channel_internal_name", "main", msg1Get["channel_internal_name"])
@ -400,7 +400,7 @@ func TestSendTooLongContent(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -427,7 +427,7 @@ func TestSendLongContentPro(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -514,7 +514,7 @@ func TestSendTooLongTitle(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -537,7 +537,7 @@ func TestSendIdempotent(t *testing.T) {
pusher := ws.Pusher.(*push.TestSink)
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -567,7 +567,7 @@ func TestSendIdempotent(t *testing.T) {
Messages []gin.H `json:"messages"`
}
msgList1 := tt.RequestAuthGet[mglist](t, readtok, baseUrl, "/api/messages")
msgList1 := tt.RequestAuthGet[mglist](t, readtok, baseUrl, "/api/v2/messages")
tt.AssertEqual(t, "len(messages)", 1, len(msgList1.Messages))
msg2 := tt.RequestPost[gin.H](t, baseUrl, "/", gin.H{
@ -586,7 +586,7 @@ func TestSendIdempotent(t *testing.T) {
tt.AssertStrRepEqual(t, "msg.title", "Hello SCN", pusher.Last().Message.Title)
tt.AssertStrRepEqual(t, "msg.content", "mamma mia", pusher.Last().Message.Content)
msgList2 := tt.RequestAuthGet[mglist](t, readtok, baseUrl, "/api/messages")
msgList2 := tt.RequestAuthGet[mglist](t, readtok, baseUrl, "/api/v2/messages")
tt.AssertEqual(t, "len(messages)", 1, len(msgList2.Messages))
msg3 := tt.RequestPost[gin.H](t, baseUrl, "/", gin.H{
@ -605,7 +605,7 @@ func TestSendIdempotent(t *testing.T) {
tt.AssertStrRepEqual(t, "msg.title", "Hello third", pusher.Last().Message.Title)
tt.AssertStrRepEqual(t, "msg.content", "let me go", pusher.Last().Message.Content)
msgList3 := tt.RequestAuthGet[mglist](t, readtok, baseUrl, "/api/messages")
msgList3 := tt.RequestAuthGet[mglist](t, readtok, baseUrl, "/api/v2/messages")
tt.AssertEqual(t, "len(messages)", 2, len(msgList3.Messages))
}
@ -615,7 +615,7 @@ func TestSendWithPriority(t *testing.T) {
pusher := ws.Pusher.(*push.TestSink)
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -638,7 +638,7 @@ func TestSendWithPriority(t *testing.T) {
tt.AssertStrRepEqual(t, "msg.prio", 1, pusher.Last().Message.Priority)
msg1Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]))
msg1Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]))
tt.AssertStrRepEqual(t, "msg.title", "M_001", msg1Get["title"])
tt.AssertStrRepEqual(t, "msg.content", "TestSendWithPriority#001", msg1Get["content"])
tt.AssertStrRepEqual(t, "msg.content", 1, msg1Get["priority"])
@ -657,7 +657,7 @@ func TestSendWithPriority(t *testing.T) {
tt.AssertStrRepEqual(t, "msg.prio", 0, pusher.Last().Message.Priority)
msg2Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/messages/"+fmt.Sprintf("%v", msg2["scn_msg_id"]))
msg2Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", msg2["scn_msg_id"]))
tt.AssertStrRepEqual(t, "msg.title", "M_002", msg2Get["title"])
tt.AssertStrRepEqual(t, "msg.content", "TestSendWithPriority#002", msg2Get["content"])
tt.AssertStrRepEqual(t, "msg.content", 0, msg2Get["priority"])
@ -676,7 +676,7 @@ func TestSendWithPriority(t *testing.T) {
tt.AssertStrRepEqual(t, "msg.prio", 1, pusher.Last().Message.Priority)
msg3Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/messages/"+fmt.Sprintf("%v", msg3["scn_msg_id"]))
msg3Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", msg3["scn_msg_id"]))
tt.AssertStrRepEqual(t, "msg.title", "M_003", msg3Get["title"])
tt.AssertStrRepEqual(t, "msg.content", "TestSendWithPriority#003", msg3Get["content"])
tt.AssertStrRepEqual(t, "msg.content", 1, msg3Get["priority"])
@ -695,7 +695,7 @@ func TestSendWithPriority(t *testing.T) {
tt.AssertStrRepEqual(t, "msg.prio", 2, pusher.Last().Message.Priority)
msg4Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/messages/"+fmt.Sprintf("%v", msg4["scn_msg_id"]))
msg4Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", msg4["scn_msg_id"]))
tt.AssertStrRepEqual(t, "msg.title", "M_004", msg4Get["title"])
tt.AssertStrRepEqual(t, "msg.content", "TestSendWithPriority#004", msg4Get["content"])
tt.AssertStrRepEqual(t, "msg.content", 2, msg4Get["priority"])
@ -708,7 +708,7 @@ func TestSendInvalidPriority(t *testing.T) {
pusher := ws.Pusher.(*push.TestSink)
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -824,7 +824,7 @@ func TestSendWithTimestamp(t *testing.T) {
pusher := ws.Pusher.(*push.TestSink)
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -855,7 +855,7 @@ func TestSendWithTimestamp(t *testing.T) {
Messages []gin.H `json:"messages"`
}
msgList1 := tt.RequestAuthGet[mglist](t, admintok, baseUrl, "/api/messages")
msgList1 := tt.RequestAuthGet[mglist](t, admintok, baseUrl, "/api/v2/messages")
tt.AssertEqual(t, "len(messages)", 1, len(msgList1.Messages))
tt.AssertStrRepEqual(t, "msg.title", "TTT", msgList1.Messages[0]["title"])
tt.AssertStrRepEqual(t, "msg.content", nil, msgList1.Messages[0]["sender_name"])
@ -865,7 +865,7 @@ func TestSendWithTimestamp(t *testing.T) {
tt.TestFailIfErr(t, err)
tt.AssertStrRepEqual(t, "msg.timestamp", ts, tm1.Unix())
msg1Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]))
msg1Get := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/messages/"+fmt.Sprintf("%v", msg1["scn_msg_id"]))
tt.AssertStrRepEqual(t, "msg.title", "TTT", msg1Get["title"])
tt.AssertStrRepEqual(t, "msg.content", nil, msg1Get["sender_name"])
tt.AssertStrRepEqual(t, "msg.channel_internal_name", "main", msg1Get["channel_internal_name"])
@ -881,7 +881,7 @@ func TestSendInvalidTimestamp(t *testing.T) {
pusher := ws.Pusher.(*push.TestSink)
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -982,7 +982,7 @@ func TestSendToNewChannel(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -998,7 +998,7 @@ func TestSendToNewChannel(t *testing.T) {
}
{
chan0 := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid))
chan0 := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid))
tt.AssertEqual(t, "chan-count", 0, len(chan0.Channels))
}
@ -1009,7 +1009,7 @@ func TestSendToNewChannel(t *testing.T) {
})
{
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid))
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid))
tt.AssertMappedSet(t, "channels", []string{"main"}, clist.Channels, "display_name")
tt.AssertMappedSet(t, "channels", []string{"main"}, clist.Channels, "internal_name")
}
@ -1023,7 +1023,7 @@ func TestSendToNewChannel(t *testing.T) {
})
{
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid))
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid))
tt.AssertMappedSet(t, "channels", []string{"main"}, clist.Channels, "display_name")
tt.AssertMappedSet(t, "channels", []string{"main"}, clist.Channels, "internal_name")
}
@ -1037,7 +1037,7 @@ func TestSendToNewChannel(t *testing.T) {
})
{
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid))
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid))
tt.AssertMappedSet(t, "channels", []string{"main", "test"}, clist.Channels, "display_name")
tt.AssertMappedSet(t, "channels", []string{"main", "test"}, clist.Channels, "internal_name")
}
@ -1050,7 +1050,7 @@ func TestSendToNewChannel(t *testing.T) {
})
{
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid))
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid))
tt.AssertMappedSet(t, "channels", []string{"main", "test"}, clist.Channels, "display_name")
tt.AssertMappedSet(t, "channels", []string{"main", "test"}, clist.Channels, "internal_name")
}
@ -1060,7 +1060,7 @@ func TestSendToManualChannel(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -1076,7 +1076,7 @@ func TestSendToManualChannel(t *testing.T) {
}
{
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid))
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid))
tt.AssertMappedSet(t, "channels", []string{}, clist.Channels, "display_name")
tt.AssertMappedSet(t, "channels", []string{}, clist.Channels, "internal_name")
}
@ -1088,7 +1088,7 @@ func TestSendToManualChannel(t *testing.T) {
})
{
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid))
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid))
tt.AssertMappedSet(t, "channels", []string{"main"}, clist.Channels, "display_name")
tt.AssertMappedSet(t, "channels", []string{"main"}, clist.Channels, "internal_name")
}
@ -1102,18 +1102,18 @@ func TestSendToManualChannel(t *testing.T) {
})
{
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid))
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid))
tt.AssertEqual(t, "chan.len", 1, len(clist.Channels))
tt.AssertEqual(t, "chan.internal_name", "main", clist.Channels[0]["internal_name"])
tt.AssertEqual(t, "chan.display_name", "main", clist.Channels[0]["display_name"])
}
tt.RequestAuthPost[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid), gin.H{
tt.RequestAuthPost[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid), gin.H{
"name": "test",
})
{
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid))
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid))
tt.AssertMappedSet(t, "channels", []string{"main", "test"}, clist.Channels, "display_name")
tt.AssertMappedSet(t, "channels", []string{"main", "test"}, clist.Channels, "internal_name")
}
@ -1127,7 +1127,7 @@ func TestSendToManualChannel(t *testing.T) {
})
{
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid))
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid))
tt.AssertMappedSet(t, "channels", []string{"main", "test"}, clist.Channels, "display_name")
tt.AssertMappedSet(t, "channels", []string{"main", "test"}, clist.Channels, "internal_name")
}
@ -1140,7 +1140,7 @@ func TestSendToManualChannel(t *testing.T) {
})
{
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s/channels", uid))
clist := tt.RequestAuthGet[chanlist](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", uid))
tt.AssertMappedSet(t, "channels", []string{"main", "test"}, clist.Channels, "display_name")
tt.AssertMappedSet(t, "channels", []string{"main", "test"}, clist.Channels, "internal_name")
}
@ -1150,7 +1150,7 @@ func TestSendToTooLongChannel(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -1186,7 +1186,7 @@ func TestQuotaExceededNoPro(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -1212,7 +1212,7 @@ func TestQuotaExceededNoPro(t *testing.T) {
}
{
usr := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s", uid))
usr := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s", uid))
tt.AssertStrRepEqual(t, "quota.1", 1, usr["quota_used"])
tt.AssertStrRepEqual(t, "quota.1", 50, usr["quota_max"])
@ -1229,7 +1229,7 @@ func TestQuotaExceededNoPro(t *testing.T) {
}
{
usr := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s", uid))
usr := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s", uid))
tt.AssertStrRepEqual(t, "quota.49", 49, usr["quota_used"])
tt.AssertStrRepEqual(t, "quota.49", 50, usr["quota_max"])
@ -1245,7 +1245,7 @@ func TestQuotaExceededNoPro(t *testing.T) {
tt.AssertStrRepEqual(t, "quota.msg.50", 50, msg50["quota_max"])
{
usr := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s", uid))
usr := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s", uid))
tt.AssertStrRepEqual(t, "quota.50", 50, usr["quota_used"])
tt.AssertStrRepEqual(t, "quota.50", 50, usr["quota_max"])
@ -1263,7 +1263,7 @@ func TestQuotaExceededPro(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -1290,7 +1290,7 @@ func TestQuotaExceededPro(t *testing.T) {
}
{
usr := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s", uid))
usr := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s", uid))
tt.AssertStrRepEqual(t, "quota.1", 1, usr["quota_used"])
tt.AssertStrRepEqual(t, "quota.1", 1000, usr["quota_max"])
@ -1307,7 +1307,7 @@ func TestQuotaExceededPro(t *testing.T) {
}
{
usr := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s", uid))
usr := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s", uid))
tt.AssertStrRepEqual(t, "quota.999", 999, usr["quota_used"])
tt.AssertStrRepEqual(t, "quota.999", 1000, usr["quota_max"])
@ -1323,7 +1323,7 @@ func TestQuotaExceededPro(t *testing.T) {
tt.AssertStrRepEqual(t, "quota.msg.1000", 1000, msg50["quota_max"])
{
usr := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/users/%s", uid))
usr := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s", uid))
tt.AssertStrRepEqual(t, "quota.1000", 1000, usr["quota_used"])
tt.AssertStrRepEqual(t, "quota.1000", 1000, usr["quota_max"])
@ -1341,7 +1341,7 @@ func TestSendParallel(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",

View File

@ -12,7 +12,7 @@ func TestCreateUserNoClient(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"no_client": true,
})
@ -23,10 +23,10 @@ func TestCreateUserNoClient(t *testing.T) {
readtok := r0["read_key"].(string)
sendtok := r0["send_key"].(string)
tt.RequestAuthGetShouldFail(t, sendtok, baseUrl, "/api/users/"+uid, 401, apierr.USER_AUTH_FAILED)
tt.RequestAuthGetShouldFail(t, "", baseUrl, "/api/users/"+uid, 401, apierr.USER_AUTH_FAILED)
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)
r1 := tt.RequestAuthGet[gin.H](t, readtok, baseUrl, "/api/users/"+uid)
r1 := tt.RequestAuthGet[gin.H](t, readtok, baseUrl, "/api/v2/users/"+uid)
tt.AssertEqual(t, "uid", uid, fmt.Sprintf("%v", r1["user_id"]))
tt.AssertEqual(t, "admin_key", admintok, r1["admin_key"])
@ -36,7 +36,7 @@ func TestCreateUserDummyClient(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -49,7 +49,7 @@ func TestCreateUserDummyClient(t *testing.T) {
admintok := r0["admin_key"].(string)
r1 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/users/"+uid)
r1 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid)
tt.AssertEqual(t, "uid", uid, fmt.Sprintf("%v", r1["user_id"]))
tt.AssertEqual(t, "admin_key", admintok, r1["admin_key"])
@ -59,7 +59,7 @@ func TestCreateUserDummyClient(t *testing.T) {
Clients []gin.H `json:"clients"`
}
r2 := tt.RequestAuthGet[rt2](t, admintok, baseUrl, "/api/users/"+uid+"/clients")
r2 := tt.RequestAuthGet[rt2](t, admintok, baseUrl, "/api/v2/users/"+uid+"/clients")
tt.AssertEqual(t, "len(clients)", 1, len(r2.Clients))
@ -75,7 +75,7 @@ func TestCreateUserWithUsername(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -89,7 +89,7 @@ func TestCreateUserWithUsername(t *testing.T) {
admintok := r0["admin_key"].(string)
r1 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/users/"+uid)
r1 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid)
tt.AssertEqual(t, "uid", uid, fmt.Sprintf("%v", r1["user_id"]))
tt.AssertEqual(t, "admin_key", admintok, r1["admin_key"])
@ -100,7 +100,7 @@ func TestUpdateUsername(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -111,22 +111,22 @@ func TestUpdateUsername(t *testing.T) {
uid := fmt.Sprintf("%v", r0["user_id"])
admintok := r0["admin_key"].(string)
r1 := tt.RequestAuthPatch[gin.H](t, admintok, baseUrl, "/api/users/"+uid, gin.H{"username": "my_user_001"})
r1 := tt.RequestAuthPatch[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid, gin.H{"username": "my_user_001"})
tt.AssertEqual(t, "username", "my_user_001", r1["username"])
r2 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/users/"+uid)
r2 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid)
tt.AssertEqual(t, "username", "my_user_001", r2["username"])
r3 := tt.RequestAuthPatch[gin.H](t, admintok, baseUrl, "/api/users/"+uid, gin.H{"username": "my_user_002"})
r3 := tt.RequestAuthPatch[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid, gin.H{"username": "my_user_002"})
tt.AssertEqual(t, "username", "my_user_002", r3["username"])
r4 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/users/"+uid)
r4 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid)
tt.AssertEqual(t, "username", "my_user_002", r4["username"])
r5 := tt.RequestAuthPatch[gin.H](t, admintok, baseUrl, "/api/users/"+uid, gin.H{"username": ""})
r5 := tt.RequestAuthPatch[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid, gin.H{"username": ""})
tt.AssertEqual(t, "username", nil, r5["username"])
r6 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/users/"+uid)
r6 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid)
tt.AssertEqual(t, "username", nil, r6["username"])
}
@ -134,7 +134,7 @@ func TestUgradeUserToPro(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"no_client": true,
})
tt.AssertEqual(t, "is_pro", false, r0["is_pro"])
@ -142,10 +142,10 @@ func TestUgradeUserToPro(t *testing.T) {
uid0 := fmt.Sprintf("%v", r0["user_id"])
admintok0 := r0["admin_key"].(string)
r1 := tt.RequestAuthPatch[gin.H](t, admintok0, baseUrl, "/api/users/"+uid0, gin.H{"pro_token": "ANDROID|v2|PURCHASED:000"})
r1 := tt.RequestAuthPatch[gin.H](t, admintok0, baseUrl, "/api/v2/users/"+uid0, gin.H{"pro_token": "ANDROID|v2|PURCHASED:000"})
tt.AssertEqual(t, "is_pro", true, r1["is_pro"])
r2 := tt.RequestAuthGet[gin.H](t, admintok0, baseUrl, "/api/users/"+uid0)
r2 := tt.RequestAuthGet[gin.H](t, admintok0, baseUrl, "/api/v2/users/"+uid0)
tt.AssertEqual(t, "is_pro", true, r2["is_pro"])
}
@ -153,7 +153,7 @@ func TestDowngradeUserToNonPro(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"no_client": true,
"pro_token": "ANDROID|v2|PURCHASED:UNIQ_111",
})
@ -162,10 +162,10 @@ func TestDowngradeUserToNonPro(t *testing.T) {
uid0 := fmt.Sprintf("%v", r0["user_id"])
admintok0 := r0["admin_key"].(string)
r1 := tt.RequestAuthPatch[gin.H](t, admintok0, baseUrl, "/api/users/"+uid0, gin.H{"pro_token": ""})
r1 := tt.RequestAuthPatch[gin.H](t, admintok0, baseUrl, "/api/v2/users/"+uid0, gin.H{"pro_token": ""})
tt.AssertEqual(t, "is_pro", false, r1["is_pro"])
r2 := tt.RequestAuthGet[gin.H](t, admintok0, baseUrl, "/api/users/"+uid0)
r2 := tt.RequestAuthGet[gin.H](t, admintok0, baseUrl, "/api/v2/users/"+uid0)
tt.AssertEqual(t, "is_pro", false, r2["is_pro"])
}
@ -173,7 +173,7 @@ func TestFailedUgradeUserToPro(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"no_client": true,
})
tt.AssertEqual(t, "is_pro", false, r0["is_pro"])
@ -181,18 +181,18 @@ func TestFailedUgradeUserToPro(t *testing.T) {
uid0 := fmt.Sprintf("%v", r0["user_id"])
admintok0 := r0["admin_key"].(string)
tt.RequestAuthPatchShouldFail(t, admintok0, baseUrl, "/api/users/"+uid0, gin.H{"pro_token": "ANDROID|v2|INVALID"}, 400, apierr.INVALID_PRO_TOKEN)
tt.RequestAuthPatchShouldFail(t, admintok0, baseUrl, "/api/v2/users/"+uid0, gin.H{"pro_token": "ANDROID|v2|INVALID"}, 400, apierr.INVALID_PRO_TOKEN)
tt.RequestAuthPatchShouldFail(t, admintok0, baseUrl, "/api/users/"+uid0, gin.H{"pro_token": "ANDROID|v99|PURCHASED"}, 400, apierr.INVALID_PRO_TOKEN)
tt.RequestAuthPatchShouldFail(t, admintok0, baseUrl, "/api/v2/users/"+uid0, gin.H{"pro_token": "ANDROID|v99|PURCHASED"}, 400, apierr.INVALID_PRO_TOKEN)
tt.RequestAuthPatchShouldFail(t, admintok0, baseUrl, "/api/users/"+uid0, gin.H{"pro_token": "@INVALID"}, 400, apierr.INVALID_PRO_TOKEN)
tt.RequestAuthPatchShouldFail(t, admintok0, baseUrl, "/api/v2/users/"+uid0, gin.H{"pro_token": "@INVALID"}, 400, apierr.INVALID_PRO_TOKEN)
}
func TestRecreateKeys(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -206,42 +206,42 @@ func TestRecreateKeys(t *testing.T) {
readtok := r0["read_key"].(string)
sendtok := r0["send_key"].(string)
tt.RequestAuthPatchShouldFail(t, readtok, baseUrl, "/api/users/"+uid, gin.H{"read_key": true}, 401, apierr.USER_AUTH_FAILED)
tt.RequestAuthPatchShouldFail(t, readtok, baseUrl, "/api/v2/users/"+uid, gin.H{"read_key": true}, 401, apierr.USER_AUTH_FAILED)
tt.RequestAuthPatchShouldFail(t, sendtok, baseUrl, "/api/users/"+uid, gin.H{"read_key": true}, 401, apierr.USER_AUTH_FAILED)
tt.RequestAuthPatchShouldFail(t, sendtok, baseUrl, "/api/v2/users/"+uid, gin.H{"read_key": true}, 401, apierr.USER_AUTH_FAILED)
r1 := tt.RequestAuthPatch[gin.H](t, admintok, baseUrl, "/api/users/"+uid, gin.H{})
r1 := tt.RequestAuthPatch[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid, gin.H{})
tt.AssertEqual(t, "admin_key", admintok, r1["admin_key"])
tt.AssertEqual(t, "read_key", readtok, r1["read_key"])
tt.AssertEqual(t, "send_key", sendtok, r1["send_key"])
r2 := tt.RequestAuthPatch[gin.H](t, admintok, baseUrl, "/api/users/"+uid, gin.H{"read_key": true})
r2 := tt.RequestAuthPatch[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid, gin.H{"read_key": true})
tt.AssertEqual(t, "admin_key", admintok, r2["admin_key"])
tt.AssertNotEqual(t, "read_key", readtok, r2["read_key"])
tt.AssertEqual(t, "send_key", sendtok, r2["send_key"])
readtok = r2["read_key"].(string)
r3 := tt.RequestAuthPatch[gin.H](t, admintok, baseUrl, "/api/users/"+uid, gin.H{"read_key": true, "send_key": true})
r3 := tt.RequestAuthPatch[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid, gin.H{"read_key": true, "send_key": true})
tt.AssertEqual(t, "admin_key", admintok, r3["admin_key"])
tt.AssertNotEqual(t, "read_key", readtok, r3["read_key"])
tt.AssertNotEqual(t, "send_key", sendtok, r3["send_key"])
readtok = r3["read_key"].(string)
sendtok = r3["send_key"].(string)
r4 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/users/"+uid)
r4 := tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid)
tt.AssertEqual(t, "admin_key", admintok, r4["admin_key"])
tt.AssertEqual(t, "read_key", readtok, r4["read_key"])
tt.AssertEqual(t, "send_key", sendtok, r4["send_key"])
r5 := tt.RequestAuthPatch[gin.H](t, admintok, baseUrl, "/api/users/"+uid, gin.H{"admin_key": true})
r5 := tt.RequestAuthPatch[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid, gin.H{"admin_key": true})
tt.AssertNotEqual(t, "admin_key", admintok, r5["admin_key"])
tt.AssertEqual(t, "read_key", readtok, r5["read_key"])
tt.AssertEqual(t, "send_key", sendtok, r5["send_key"])
admintokNew := r5["admin_key"].(string)
tt.RequestAuthGetShouldFail(t, admintok, baseUrl, "/api/users/"+uid, 401, apierr.USER_AUTH_FAILED)
tt.RequestAuthGetShouldFail(t, admintok, baseUrl, "/api/v2/users/"+uid, 401, apierr.USER_AUTH_FAILED)
r6 := tt.RequestAuthGet[gin.H](t, admintokNew, baseUrl, "/api/users/"+uid)
r6 := tt.RequestAuthGet[gin.H](t, admintokNew, baseUrl, "/api/v2/users/"+uid)
tt.AssertEqual(t, "admin_key", admintokNew, r6["admin_key"])
tt.AssertEqual(t, "read_key", readtok, r6["read_key"])
tt.AssertEqual(t, "send_key", sendtok, r6["send_key"])
@ -253,7 +253,7 @@ func TestDeleteUser(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -263,13 +263,13 @@ func TestDeleteUser(t *testing.T) {
uid := fmt.Sprintf("%v", r0["user_id"])
admintok := r0["admin_key"].(string)
tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/users/"+uid)
tt.RequestAuthGet[gin.H](t, admintok, baseUrl, "/api/v2/users/"+uid)
tt.RequestAuthDeleteShouldFail(t, admintok, baseUrl, "/api/users/"+uid, nil, 401, apierr.USER_AUTH_FAILED)
tt.RequestAuthDeleteShouldFail(t, admintok, baseUrl, "/api/v2/users/"+uid, nil, 401, apierr.USER_AUTH_FAILED)
tt.RequestAuthDelete[tt.Void](t, admintok, baseUrl, "/api/users/"+uid, nil)
tt.RequestAuthDelete[tt.Void](t, admintok, baseUrl, "/api/v2/users/"+uid, nil)
tt.RequestAuthGetShouldFail(t, admintok, baseUrl, "/api/users/"+uid, 404, apierr.USER_NOT_FOUND)
tt.RequestAuthGetShouldFail(t, admintok, baseUrl, "/api/v2/users/"+uid, 404, apierr.USER_NOT_FOUND)
}
@ -278,7 +278,7 @@ func TestCreateProUser(t *testing.T) {
defer stop()
{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"no_client": true,
})
@ -286,7 +286,7 @@ func TestCreateProUser(t *testing.T) {
}
{
r1 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r1 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"no_client": true,
"pro_token": "ANDROID|v2|PURCHASED:000",
})
@ -295,7 +295,7 @@ func TestCreateProUser(t *testing.T) {
}
{
r2 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r2 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -306,7 +306,7 @@ func TestCreateProUser(t *testing.T) {
}
{
r3 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r3 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -323,7 +323,7 @@ func TestFailToCreateProUser(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
tt.RequestPostShouldFail(t, baseUrl, "/api/users", gin.H{
tt.RequestPostShouldFail(t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -331,7 +331,7 @@ func TestFailToCreateProUser(t *testing.T) {
"pro_token": "ANDROID|v2|INVALID",
}, 400, apierr.INVALID_PRO_TOKEN)
tt.RequestPostShouldFail(t, baseUrl, "/api/users", gin.H{
tt.RequestPostShouldFail(t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -339,7 +339,7 @@ func TestFailToCreateProUser(t *testing.T) {
"pro_token": "_",
}, 400, apierr.INVALID_PRO_TOKEN)
tt.RequestPostShouldFail(t, baseUrl, "/api/users", gin.H{
tt.RequestPostShouldFail(t, baseUrl, "/api/v2/users", gin.H{
"agent_model": "DUMMY_PHONE",
"agent_version": "4X",
"client_type": "ANDROID",
@ -352,7 +352,7 @@ func TestReuseProToken(t *testing.T) {
_, baseUrl, stop := tt.StartSimpleWebserver(t)
defer stop()
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"no_client": true,
})
tt.AssertEqual(t, "is_pro", false, r0["is_pro"])
@ -360,7 +360,7 @@ func TestReuseProToken(t *testing.T) {
uid0 := fmt.Sprintf("%v", r0["user_id"])
admintok0 := r0["admin_key"].(string)
r1 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r1 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"no_client": true,
"pro_token": "ANDROID|v2|PURCHASED:UNIQ_1",
})
@ -370,11 +370,11 @@ func TestReuseProToken(t *testing.T) {
admintok1 := r1["admin_key"].(string)
{
rc := tt.RequestAuthGet[gin.H](t, admintok1, baseUrl, "/api/users/"+uid1)
rc := tt.RequestAuthGet[gin.H](t, admintok1, baseUrl, "/api/v2/users/"+uid1)
tt.AssertEqual(t, "is_pro", true, rc["is_pro"])
}
r2 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{
r2 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
"no_client": true,
"pro_token": "ANDROID|v2|PURCHASED:UNIQ_1",
})
@ -384,51 +384,51 @@ func TestReuseProToken(t *testing.T) {
admintok2 := r2["admin_key"].(string)
{
rc := tt.RequestAuthGet[gin.H](t, admintok0, baseUrl, "/api/users/"+uid0)
rc := tt.RequestAuthGet[gin.H](t, admintok0, baseUrl, "/api/v2/users/"+uid0)
tt.AssertEqual(t, "is_pro", false, rc["is_pro"])
}
{
rc := tt.RequestAuthGet[gin.H](t, admintok1, baseUrl, "/api/users/"+uid1)
rc := tt.RequestAuthGet[gin.H](t, admintok1, baseUrl, "/api/v2/users/"+uid1)
tt.AssertEqual(t, "is_pro", false, rc["is_pro"])
}
{
rc := tt.RequestAuthGet[gin.H](t, admintok2, baseUrl, "/api/users/"+uid2)
rc := tt.RequestAuthGet[gin.H](t, admintok2, baseUrl, "/api/v2/users/"+uid2)
tt.AssertEqual(t, "is_pro", true, rc["is_pro"])
}
tt.RequestAuthPatch[gin.H](t, admintok0, baseUrl, "/api/users/"+uid0, gin.H{"pro_token": "ANDROID|v2|PURCHASED:UNIQ_2"})
tt.RequestAuthPatch[gin.H](t, admintok0, baseUrl, "/api/v2/users/"+uid0, gin.H{"pro_token": "ANDROID|v2|PURCHASED:UNIQ_2"})
{
rc := tt.RequestAuthGet[gin.H](t, admintok0, baseUrl, "/api/users/"+uid0)
rc := tt.RequestAuthGet[gin.H](t, admintok0, baseUrl, "/api/v2/users/"+uid0)
tt.AssertEqual(t, "is_pro", true, rc["is_pro"])
}
{
rc := tt.RequestAuthGet[gin.H](t, admintok1, baseUrl, "/api/users/"+uid1)
rc := tt.RequestAuthGet[gin.H](t, admintok1, baseUrl, "/api/v2/users/"+uid1)
tt.AssertEqual(t, "is_pro", false, rc["is_pro"])
}
{
rc := tt.RequestAuthGet[gin.H](t, admintok2, baseUrl, "/api/users/"+uid2)
rc := tt.RequestAuthGet[gin.H](t, admintok2, baseUrl, "/api/v2/users/"+uid2)
tt.AssertEqual(t, "is_pro", true, rc["is_pro"])
}
tt.RequestAuthPatch[gin.H](t, admintok0, baseUrl, "/api/users/"+uid0, gin.H{"pro_token": "ANDROID|v2|PURCHASED:UNIQ_1"})
tt.RequestAuthPatch[gin.H](t, admintok0, baseUrl, "/api/v2/users/"+uid0, gin.H{"pro_token": "ANDROID|v2|PURCHASED:UNIQ_1"})
{
rc := tt.RequestAuthGet[gin.H](t, admintok0, baseUrl, "/api/users/"+uid0)
rc := tt.RequestAuthGet[gin.H](t, admintok0, baseUrl, "/api/v2/users/"+uid0)
tt.AssertEqual(t, "is_pro", true, rc["is_pro"])
}
{
rc := tt.RequestAuthGet[gin.H](t, admintok1, baseUrl, "/api/users/"+uid1)
rc := tt.RequestAuthGet[gin.H](t, admintok1, baseUrl, "/api/v2/users/"+uid1)
tt.AssertEqual(t, "is_pro", false, rc["is_pro"])
}
{
rc := tt.RequestAuthGet[gin.H](t, admintok2, baseUrl, "/api/users/"+uid2)
rc := tt.RequestAuthGet[gin.H](t, admintok2, baseUrl, "/api/v2/users/"+uid2)
tt.AssertEqual(t, "is_pro", false, rc["is_pro"])
}

View File

@ -318,7 +318,7 @@ func InitDefaultData(t *testing.T, ws *logic.Application) DefData {
body["pro_token"] = uex.ProTok
}
user0 := RequestPost[gin.H](t, baseUrl, "/api/users", body)
user0 := RequestPost[gin.H](t, baseUrl, "/api/v2/users", body)
uid0 := user0["user_id"].(string)
readtok0 := user0["read_key"].(string)
sendtok0 := user0["send_key"].(string)
@ -341,7 +341,7 @@ func InitDefaultData(t *testing.T, ws *logic.Application) DefData {
body["agent_version"] = cex.AgentVersion
body["client_type"] = cex.ClientType
body["fcm_token"] = cex.FCMTok
RequestAuthPost[gin.H](t, users[cex.User].AdminKey, baseUrl, fmt.Sprintf("/api/users/%s/clients", users[cex.User].UID), body)
RequestAuthPost[gin.H](t, users[cex.User].AdminKey, baseUrl, fmt.Sprintf("/api/v2/users/%s/clients", users[cex.User].UID), body)
}
// Create Messages
@ -378,7 +378,7 @@ func InitDefaultData(t *testing.T, ws *logic.Application) DefData {
// create manual channels
{
RequestAuthPost[Void](t, users[9].AdminKey, baseUrl, fmt.Sprintf("/api/users/%s/channels", users[9].UID), gin.H{"name": "manual@chan"})
RequestAuthPost[Void](t, users[9].AdminKey, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", users[9].UID), gin.H{"name": "manual@chan"})
}
// Sub/Unsub for Users 12+13
@ -399,7 +399,7 @@ func doSubscribe(t *testing.T, baseUrl string, user Userdat, chanOwner Userdat,
if user == chanOwner {
RequestAuthPost[Void](t, user.AdminKey, baseUrl, fmt.Sprintf("/api/users/%s/channels", user.UID), gin.H{
RequestAuthPost[Void](t, user.AdminKey, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", user.UID), gin.H{
"channel_owner_user_id": chanOwner.UID,
"channel_internal_name": chanInternalName,
})
@ -409,7 +409,7 @@ func doSubscribe(t *testing.T, baseUrl string, user Userdat, chanOwner Userdat,
Channels []gin.H `json:"channels"`
}
clist := RequestAuthGet[chanlist](t, chanOwner.AdminKey, baseUrl, fmt.Sprintf("/api/users/%s/channels?selector=owned", chanOwner.UID))
clist := RequestAuthGet[chanlist](t, chanOwner.AdminKey, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels?selector=owned", chanOwner.UID))
var chandat gin.H
for _, v := range clist.Channels {
@ -419,7 +419,7 @@ func doSubscribe(t *testing.T, baseUrl string, user Userdat, chanOwner Userdat,
}
}
RequestAuthPost[Void](t, user.AdminKey, baseUrl, fmt.Sprintf("/api/users/%s/subscriptions?chan_subscribe_key=%s", user.UID, chandat["subscribe_key"].(string)), gin.H{
RequestAuthPost[Void](t, user.AdminKey, baseUrl, fmt.Sprintf("/api/v2/users/%s/subscriptions?chan_subscribe_key=%s", user.UID, chandat["subscribe_key"].(string)), gin.H{
"channel_id": chandat["channel_id"].(string),
})
@ -433,7 +433,7 @@ func doUnsubscribe(t *testing.T, baseUrl string, user Userdat, chanOwner Userdat
Subscriptions []gin.H `json:"subscriptions"`
}
slist := RequestAuthGet[chanlist](t, user.AdminKey, baseUrl, fmt.Sprintf("/api/users/%s/subscriptions?selector=outgoing_confirmed", user.UID))
slist := RequestAuthGet[chanlist](t, user.AdminKey, baseUrl, fmt.Sprintf("/api/v2/users/%s/subscriptions?selector=outgoing_confirmed", user.UID))
var subdat gin.H
for _, v := range slist.Subscriptions {
@ -443,7 +443,7 @@ func doUnsubscribe(t *testing.T, baseUrl string, user Userdat, chanOwner Userdat
}
}
RequestAuthDelete[Void](t, user.AdminKey, baseUrl, fmt.Sprintf("/api/users/%s/subscriptions/%v", user.UID, subdat["subscription_id"]), gin.H{})
RequestAuthDelete[Void](t, user.AdminKey, baseUrl, fmt.Sprintf("/api/v2/users/%s/subscriptions/%v", user.UID, subdat["subscription_id"]), gin.H{})
}
@ -453,7 +453,7 @@ func doAcceptSub(t *testing.T, baseUrl string, user Userdat, subscriber Userdat,
Subscriptions []gin.H `json:"subscriptions"`
}
slist := RequestAuthGet[chanlist](t, user.AdminKey, baseUrl, fmt.Sprintf("/api/users/%s/subscriptions?selector=incoming_unconfirmed", user.UID))
slist := RequestAuthGet[chanlist](t, user.AdminKey, baseUrl, fmt.Sprintf("/api/v2/users/%s/subscriptions?selector=incoming_unconfirmed", user.UID))
var subdat gin.H
for _, v := range slist.Subscriptions {
@ -463,7 +463,7 @@ func doAcceptSub(t *testing.T, baseUrl string, user Userdat, subscriber Userdat,
}
}
RequestAuthPatch[Void](t, user.AdminKey, baseUrl, fmt.Sprintf("/api/users/%s/subscriptions/%v", user.UID, subdat["subscription_id"]), gin.H{
RequestAuthPatch[Void](t, user.AdminKey, baseUrl, fmt.Sprintf("/api/v2/users/%s/subscriptions/%v", user.UID, subdat["subscription_id"]), gin.H{
"confirmed": true,
})