Handling encoded passwords
This commit is contained in:
+21
-2
@@ -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")
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user