add a test for \n handling in wp, fix incorrect curl param caused removal of \n #156
This commit is contained in:
@@ -39,13 +39,17 @@ func TestMiddleware_AppInfo(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMiddleware_GetBodyAndUser(t *testing.T) {
|
||||
req, err := http.NewRequest("GET", "http://example.com/request", strings.NewReader("body"))
|
||||
req, err := http.NewRequest("GET", "http://example.com/request", strings.NewReader("body1\nbody2"))
|
||||
require.Nil(t, err)
|
||||
|
||||
body, user := getBodyAndUser(req, []LoggerFlag{LogAll})
|
||||
assert.Equal(t, "body", body)
|
||||
assert.Equal(t, "body1 body2", body)
|
||||
assert.Equal(t, "", user, "no user")
|
||||
|
||||
b, err := ioutil.ReadAll(req.Body)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "body1\nbody2", string(b))
|
||||
|
||||
req = rest.SetUserInfo(req, store.User{ID: "id1", Name: "user1"})
|
||||
_, user = getBodyAndUser(req, []LoggerFlag{LogAll})
|
||||
assert.Equal(t, ` - id1 "user1"`, user, "no user")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
echo "import wordpress file $1 to site $2"
|
||||
curl -X POST -H "Content-Type: application/xml" -d @/srv/var/$1 "http://127.0.0.1:8081/api/v1/admin/import?site=${2}&provider=wordpress&secret=${SECRET}"
|
||||
curl -X POST -H "Content-Type: application/xml" --data-binary @/srv/var/$1 "http://127.0.0.1:8081/api/v1/admin/import?site=${2}&provider=wordpress&secret=${SECRET}"
|
||||
echo "import completed"
|
||||
Reference in New Issue
Block a user