diff --git a/backend/app/rest/api/admin_test.go b/backend/app/rest/api/admin_test.go
index 1cc7ec45..40062f39 100644
--- a/backend/app/rest/api/admin_test.go
+++ b/backend/app/rest/api/admin_test.go
@@ -640,7 +640,7 @@ func TestAdmin_DeleteMeRequestFailed(t *testing.T) {
req.SetBasicAuth("admin", "bad-password")
resp, err = client.Do(req)
assert.Nil(t, err)
- assert.Equal(t, 401, resp.StatusCode)
+ assert.Equal(t, 403, resp.StatusCode)
// try bad user
badClaims := claims
diff --git a/backend/app/rest/api/rss_test.go b/backend/app/rest/api/rss_test.go
index 201ac3cd..54938629 100644
--- a/backend/app/rest/api/rss_test.go
+++ b/backend/app/rest/api/rss_test.go
@@ -7,21 +7,26 @@ import (
"testing"
"time"
+ "github.com/go-pkgz/mongo/.vendor/github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
"github.com/umputun/remark/backend/app/store"
)
func TestServer_RssPost(t *testing.T) {
- ts, _, teardown := startupT(t)
+ ts, rst, teardown := startupT(t)
defer teardown()
waitOnSecChange()
c1 := store.Comment{
+ ID: "1234567890",
Text: "test 123",
Locator: store.Locator{URL: "https://radio-t.com/blah1", SiteID: "radio-t"},
+ User: store.User{ID: "u1", Name: "developer one"},
}
- id1 := addComment(t, c1, ts)
+ id1, err := rst.DataService.Create(c1)
+ require.NoError(t, err)
+ assert.Equal(t, "1234567890", id1)
pubDate := time.Now().Format(time.RFC1123Z)
res, code := get(t, ts.URL+"/api/v1/rss/post?site=radio-t&url=https://radio-t.com/blah1")
@@ -36,13 +41,14 @@ func TestServer_RssPost(t *testing.T) {
%s
-
developer one
- https://radio-t.com/blah1#remark42__comment-%s
- <p>test 123</p>
+ https://radio-t.com/blah1#remark42__comment-1234567890
+ test 123
developer one
+ 1234567890
%s
- `, pubDate, id1, pubDate)
+ `, pubDate, pubDate)
expected, res = cleanRssFormatting(expected, res)
assert.Equal(t, expected, res)
@@ -52,7 +58,7 @@ func TestServer_RssPost(t *testing.T) {
}
func TestServer_RssSite(t *testing.T) {
- ts, _, teardown := startupT(t)
+ ts, rst, teardown := startupT(t)
defer teardown()
waitOnSecChange()
@@ -60,16 +66,24 @@ func TestServer_RssSite(t *testing.T) {
pubDate := time.Now().Format(time.RFC1123Z)
c1 := store.Comment{
+ ID: "comment-id-1",
Text: "test 123",
Locator: store.Locator{URL: "https://radio-t.com/blah10", SiteID: "radio-t"},
+ User: store.User{ID: "u1", Name: "developer one"},
}
c2 := store.Comment{
+ ID: "comment-id-2",
Text: "xyz test",
Locator: store.Locator{URL: "https://radio-t.com/blah11", SiteID: "radio-t"},
+ User: store.User{ID: "u1", Name: "developer one"},
}
- id1 := addComment(t, c1, ts)
- id2 := addComment(t, c2, ts)
+ _, err := rst.DataService.Create(c1)
+ require.NoError(t, err)
+ _, err = rst.DataService.Create(c2)
+ require.NoError(t, err)
+
+ require.NoError(t, err)
res, code := get(t, ts.URL+"/api/v1/rss/site?site=radio-t")
assert.Equal(t, 200, code)
t.Log(res)
@@ -82,20 +96,22 @@ func TestServer_RssSite(t *testing.T) {
%s
-
developer one
- https://radio-t.com/blah11#remark42__comment-%s
- <p>xyz test</p>
+ https://radio-t.com/blah11#remark42__comment-comment-id-2
+ xyz test
developer one
+ comment-id-2
%s
-
developer one
- https://radio-t.com/blah10#remark42__comment-%s
- <p>test 123</p>
+ https://radio-t.com/blah10#remark42__comment-comment-id-1
+ test 123
developer one
+ comment-id-1
%s
- `, pubDate, id2, pubDate, id1, pubDate)
+ `, pubDate, pubDate, pubDate)
expected, res = cleanRssFormatting(expected, res)
assert.Equal(t, expected, res)
@@ -105,7 +121,7 @@ func TestServer_RssSite(t *testing.T) {
}
func TestServer_RssWithReply(t *testing.T) {
- ts, _, teardown := startupT(t)
+ ts, rst, teardown := startupT(t)
defer teardown()
waitOnSecChange()
@@ -113,16 +129,23 @@ func TestServer_RssWithReply(t *testing.T) {
pubDate := time.Now().Format(time.RFC1123Z)
c1 := store.Comment{
+ ID: "comment-id-1",
Text: "test 123",
Locator: store.Locator{URL: "https://radio-t.com/blah10", SiteID: "radio-t"},
+ User: store.User{ID: "u1", Name: "developer one"},
}
c2 := store.Comment{
- Text: "xyz test",
- Locator: store.Locator{URL: "https://radio-t.com/blah10", SiteID: "radio-t"},
+ ID: "comment-id-2",
+ ParentID: "comment-id-1",
+ Text: "xyz test",
+ Locator: store.Locator{URL: "https://radio-t.com/blah10", SiteID: "radio-t"},
+ User: store.User{ID: "u1", Name: "developer one"},
}
- id1 := addComment(t, c1, ts)
- c2.ParentID = id1
- id2 := addComment(t, c2, ts)
+
+ _, err := rst.DataService.Create(c1)
+ require.NoError(t, err)
+ _, err = rst.DataService.Create(c2)
+ require.NoError(t, err)
res, code := get(t, ts.URL+"/api/v1/rss/post?site=radio-t&url=https://radio-t.com/blah10")
assert.Equal(t, 200, code)
@@ -136,20 +159,22 @@ func TestServer_RssWithReply(t *testing.T) {
%s
-
developer one > developer one
- https://radio-t.com/blah10#remark42__comment-%s
- <p>xyz test</p>
+ https://radio-t.com/blah10#remark42__comment-comment-id-2
+ xyz test
developer one
+ comment-id-2
%s
-
developer one
- https://radio-t.com/blah10#remark42__comment-%s
- <p>test 123</p>
+ https://radio-t.com/blah10#remark42__comment-comment-id-1
+ test 123
developer one
+ comment-id-1
%s
- `, pubDate, id2, pubDate, id1, pubDate)
+ `, pubDate, pubDate, pubDate)
expected, res = cleanRssFormatting(expected, res)
assert.Equal(t, expected, res)
@@ -164,39 +189,49 @@ func TestServer_RssReplies(t *testing.T) {
pubDate := time.Now().Format(time.RFC1123Z)
c1 := store.Comment{
+ ID: "comment-1",
Text: "c1",
Locator: store.Locator{URL: "https://radio-t.com/blah1", SiteID: "radio-t"},
User: store.User{ID: "user1", Name: "user1"},
}
- id1, err := srv.DataService.Create(c1)
- assert.Nil(t, err)
c2 := store.Comment{
+ ID: "comment-2",
Text: "reply to c1 from user2",
- ParentID: id1,
+ ParentID: "comment-1",
Locator: store.Locator{URL: "https://radio-t.com/blah1", SiteID: "radio-t"},
User: store.User{ID: "user2", Name: "user2"},
}
- id2, err := srv.DataService.Create(c2)
- assert.Nil(t, err)
c3 := store.Comment{
+ ID: "comment-3",
Text: "reply to c1 from user3",
- ParentID: id1,
+ ParentID: "comment-1",
Locator: store.Locator{URL: "https://radio-t.com/blah1", SiteID: "radio-t"},
User: store.User{ID: "user3", Name: "user3"},
}
- id3, err := srv.DataService.Create(c3)
- assert.Nil(t, err)
c4 := store.Comment{
+ ID: "comment-4",
Text: "reply to c2 from developer one",
- ParentID: id2,
+ ParentID: "comment-2",
Locator: store.Locator{URL: "https://radio-t.com/blah1", SiteID: "radio-t"},
+ User: store.User{ID: "dev", Name: "developer one"},
}
- addComment(t, c4, ts)
c5 := store.Comment{
+ ID: "comment-5",
Text: "developer one",
Locator: store.Locator{URL: "https://radio-t.com/blah1", SiteID: "radio-t"},
+ User: store.User{ID: "dev", Name: "developer one"},
}
- addComment(t, c5, ts)
+
+ _, err := srv.DataService.Create(c1)
+ require.NoError(t, err)
+ _, err = srv.DataService.Create(c2)
+ require.NoError(t, err)
+ _, err = srv.DataService.Create(c3)
+ require.NoError(t, err)
+ _, err = srv.DataService.Create(c4)
+ require.NoError(t, err)
+ _, err = srv.DataService.Create(c5)
+ require.NoError(t, err)
// replies to c1 (user1). Must be [c3, c2]
res, code := get(t, ts.URL+"/api/v1/rss/reply?user=user1&site=radio-t")
@@ -210,20 +245,22 @@ func TestServer_RssReplies(t *testing.T) {
%s
-
user3 > user1
- https://radio-t.com/blah1#remark42__comment-%s
+ https://radio-t.com/blah1#remark42__comment-comment-3
reply to c1 from user3
user3
+ comment-3
%s
-
user2 > user1
- https://radio-t.com/blah1#remark42__comment-%s
+ https://radio-t.com/blah1#remark42__comment-comment-2
reply to c1 from user2
user2
+ comment-2
%s
- `, pubDate, id3, pubDate, id2, pubDate)
+ `, pubDate, pubDate, pubDate)
expected, res = cleanRssFormatting(expected, res)
assert.Equal(t, expected, res)
diff --git a/backend/app/store/engine/bolt_accessor.go b/backend/app/store/engine/bolt_accessor.go
index 877febd4..fc3099a4 100644
--- a/backend/app/store/engine/bolt_accessor.go
+++ b/backend/app/store/engine/bolt_accessor.go
@@ -127,7 +127,7 @@ func (b *BoltDB) Create(comment store.Comment) (commentID string, err error) {
return errors.Wrapf(e, "failed to put user comment %s for %s", comment.ID, comment.User.ID)
}
- // set info with countfor post url
+ // set info with the count for post url
if _, e = b.setInfo(tx, comment); e != nil {
return errors.Wrapf(e, "failed to set info for %s", comment.Locator)
}