mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-06 22:17:37 +03:00
Handling encoded passwords
This commit is contained in:
parent
61d96421dd
commit
031738f1eb
2 changed files with 31 additions and 3 deletions
|
@ -2,10 +2,11 @@ package api_test
|
|||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"testing"
|
||||
|
||||
"github.com/deluan/gosonic/api/responses"
|
||||
"github.com/deluan/gosonic/tests"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCheckParams(t *testing.T) {
|
||||
|
@ -29,9 +30,10 @@ func TestCheckParams(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAuthentication(t *testing.T) {
|
||||
_, w := Get("/rest/ping.view?u=INVALID&p=INVALID&c=test&v=1.0.0", "TestAuthentication")
|
||||
tests.Init(t, false)
|
||||
|
||||
Convey("Subject: Authentication\n", t, func() {
|
||||
_, w := Get("/rest/ping.view?u=INVALID&p=INVALID&c=test&v=1.0.0", "TestAuthentication")
|
||||
Convey("Status code should be 200", func() {
|
||||
So(w.Code, ShouldEqual, 200)
|
||||
})
|
||||
|
@ -44,4 +46,21 @@ func TestAuthentication(t *testing.T) {
|
|||
So(v.Status, ShouldEqual, "fail")
|
||||
})
|
||||
})
|
||||
Convey("Subject: Authentication Valid\n", t, func() {
|
||||
_, w := Get("/rest/ping.view?u=deluan&p=wordpass&c=test&v=1.0.0", "TestAuthentication")
|
||||
Convey("The status should be 'ok'", func() {
|
||||
v := responses.Subsonic{}
|
||||
xml.Unmarshal(w.Body.Bytes(), &v)
|
||||
So(v.Status, ShouldEqual, "ok")
|
||||
})
|
||||
})
|
||||
Convey("Subject: Password encoded\n", t, func() {
|
||||
_, w := Get("/rest/ping.view?u=deluan&p=enc:776f726470617373&c=test&v=1.0.0", "TestAuthentication")
|
||||
Convey("The status should be 'ok'", func() {
|
||||
v := responses.Subsonic{}
|
||||
println("------", w.Body.String())
|
||||
xml.Unmarshal(w.Body.Bytes(), &v)
|
||||
So(v.Status, ShouldEqual, "ok")
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue