|
|
@@ -22,7 +22,7 @@ const (
|
|
|
func TestServer_WebPush_TopicAdd(t *testing.T) {
|
|
|
s := newTestServer(t, newTestConfigWithWebPush(t))
|
|
|
|
|
|
- response := request(t, s, "PUT", "/v1/account/webpush", payloadForTopics(t, []string{"test-topic"}, testWebPushEndpoint), nil)
|
|
|
+ response := request(t, s, "POST", "/v1/account/webpush", payloadForTopics(t, []string{"test-topic"}, testWebPushEndpoint), nil)
|
|
|
require.Equal(t, 200, response.Code)
|
|
|
require.Equal(t, `{"success":true}`+"\n", response.Body.String())
|
|
|
|
|
|
@@ -39,7 +39,7 @@ func TestServer_WebPush_TopicAdd(t *testing.T) {
|
|
|
func TestServer_WebPush_TopicAdd_InvalidEndpoint(t *testing.T) {
|
|
|
s := newTestServer(t, newTestConfigWithWebPush(t))
|
|
|
|
|
|
- response := request(t, s, "PUT", "/v1/account/webpush", payloadForTopics(t, []string{"test-topic"}, "https://ddos-target.example.com/webpush"), nil)
|
|
|
+ response := request(t, s, "POST", "/v1/account/webpush", payloadForTopics(t, []string{"test-topic"}, "https://ddos-target.example.com/webpush"), nil)
|
|
|
require.Equal(t, 400, response.Code)
|
|
|
require.Equal(t, `{"code":40039,"http":400,"error":"invalid request: web push endpoint unknown"}`+"\n", response.Body.String())
|
|
|
}
|
|
|
@@ -52,7 +52,7 @@ func TestServer_WebPush_TopicAdd_TooManyTopics(t *testing.T) {
|
|
|
topicList[i] = util.RandomString(5)
|
|
|
}
|
|
|
|
|
|
- response := request(t, s, "PUT", "/v1/account/webpush", payloadForTopics(t, topicList, testWebPushEndpoint), nil)
|
|
|
+ response := request(t, s, "POST", "/v1/account/webpush", payloadForTopics(t, topicList, testWebPushEndpoint), nil)
|
|
|
require.Equal(t, 400, response.Code)
|
|
|
require.Equal(t, `{"code":40040,"http":400,"error":"invalid request: too many web push topic subscriptions"}`+"\n", response.Body.String())
|
|
|
}
|
|
|
@@ -63,7 +63,7 @@ func TestServer_WebPush_TopicUnsubscribe(t *testing.T) {
|
|
|
addSubscription(t, s, testWebPushEndpoint, "test-topic")
|
|
|
requireSubscriptionCount(t, s, "test-topic", 1)
|
|
|
|
|
|
- response := request(t, s, "PUT", "/v1/account/webpush", payloadForTopics(t, []string{}, testWebPushEndpoint), nil)
|
|
|
+ response := request(t, s, "POST", "/v1/account/webpush", payloadForTopics(t, []string{}, testWebPushEndpoint), nil)
|
|
|
require.Equal(t, 200, response.Code)
|
|
|
require.Equal(t, `{"success":true}`+"\n", response.Body.String())
|
|
|
|
|
|
@@ -78,7 +78,7 @@ func TestServer_WebPush_TopicSubscribeProtected_Allowed(t *testing.T) {
|
|
|
require.Nil(t, s.userManager.AddUser("ben", "ben", user.RoleUser))
|
|
|
require.Nil(t, s.userManager.AllowAccess("ben", "test-topic", user.PermissionReadWrite))
|
|
|
|
|
|
- response := request(t, s, "PUT", "/v1/account/webpush", payloadForTopics(t, []string{"test-topic"}, testWebPushEndpoint), map[string]string{
|
|
|
+ response := request(t, s, "POST", "/v1/account/webpush", payloadForTopics(t, []string{"test-topic"}, testWebPushEndpoint), map[string]string{
|
|
|
"Authorization": util.BasicAuth("ben", "ben"),
|
|
|
})
|
|
|
require.Equal(t, 200, response.Code)
|
|
|
@@ -95,7 +95,7 @@ func TestServer_WebPush_TopicSubscribeProtected_Denied(t *testing.T) {
|
|
|
config.AuthDefault = user.PermissionDenyAll
|
|
|
s := newTestServer(t, config)
|
|
|
|
|
|
- response := request(t, s, "PUT", "/v1/account/webpush", payloadForTopics(t, []string{"test-topic"}, testWebPushEndpoint), nil)
|
|
|
+ response := request(t, s, "POST", "/v1/account/webpush", payloadForTopics(t, []string{"test-topic"}, testWebPushEndpoint), nil)
|
|
|
require.Equal(t, 403, response.Code)
|
|
|
|
|
|
requireSubscriptionCount(t, s, "test-topic", 0)
|
|
|
@@ -108,7 +108,7 @@ func TestServer_WebPush_DeleteAccountUnsubscribe(t *testing.T) {
|
|
|
require.Nil(t, s.userManager.AddUser("ben", "ben", user.RoleUser))
|
|
|
require.Nil(t, s.userManager.AllowAccess("ben", "test-topic", user.PermissionReadWrite))
|
|
|
|
|
|
- response := request(t, s, "PUT", "/v1/account/webpush", payloadForTopics(t, []string{"test-topic"}, testWebPushEndpoint), map[string]string{
|
|
|
+ response := request(t, s, "POST", "/v1/account/webpush", payloadForTopics(t, []string{"test-topic"}, testWebPushEndpoint), map[string]string{
|
|
|
"Authorization": util.BasicAuth("ben", "ben"),
|
|
|
})
|
|
|
|
|
|
@@ -139,7 +139,7 @@ func TestServer_WebPush_Publish(t *testing.T) {
|
|
|
defer pushService.Close()
|
|
|
|
|
|
addSubscription(t, s, pushService.URL+"/push-receive", "test-topic")
|
|
|
- request(t, s, "PUT", "/test-topic", "web push test", nil)
|
|
|
+ request(t, s, "POST", "/test-topic", "web push test", nil)
|
|
|
|
|
|
waitFor(t, func() bool {
|
|
|
return received.Load()
|
|
|
@@ -162,7 +162,7 @@ func TestServer_WebPush_Publish_RemoveOnError(t *testing.T) {
|
|
|
requireSubscriptionCount(t, s, "test-topic", 1)
|
|
|
requireSubscriptionCount(t, s, "test-topic-abc", 1)
|
|
|
|
|
|
- request(t, s, "PUT", "/test-topic", "web push test", nil)
|
|
|
+ request(t, s, "POST", "/test-topic", "web push test", nil)
|
|
|
|
|
|
waitFor(t, func() bool {
|
|
|
return received.Load()
|