This commit is contained in:
Deluan 2016-02-25 18:52:07 -05:00
parent a1829d432a
commit e760952263
17 changed files with 40 additions and 59 deletions

View File

@ -11,6 +11,3 @@ func (c *GetLicenseController) Get() {
response := responses.NewXML(&responses.License{Valid: true})
c.Ctx.Output.Body(response)
}

View File

@ -20,6 +20,3 @@ func (c *GetMusicFoldersController) Get() {
response := responses.NewXML(musicFolders)
c.Ctx.Output.Body(response)
}

View File

@ -1,8 +1,8 @@
package api
import (
"github.com/astaxie/beego"
"encoding/xml"
"github.com/astaxie/beego"
"github.com/deluan/gosonic/api/responses"
)
@ -13,6 +13,3 @@ func (c *PingController) Get() {
xmlBody, _ := xml.Marshal(response)
c.Ctx.Output.Body([]byte(xml.Header + string(xmlBody)))
}

View File

@ -19,7 +19,7 @@ func Validate(controller ControllerInterface) {
}
func checkParameters(c ControllerInterface) {
requiredParameters := []string {"u", "p", "v", "c",}
requiredParameters := []string{"u", "p", "v", "c"}
for _, p := range requiredParameters {
if c.GetString(p) == "" {
@ -31,7 +31,7 @@ func checkParameters(c ControllerInterface) {
func authenticate(c ControllerInterface) {
user := c.GetString("u")
pass := c.GetString("p") // TODO Handle hex-encoded password
if (user != beego.AppConfig.String("user") || pass != beego.AppConfig.String("password")) {
if user != beego.AppConfig.String("user") || pass != beego.AppConfig.String("password") {
cancel(c, responses.ERROR_AUTHENTICATION_FAIL)
}
}

View File

@ -1,18 +1,16 @@
package controllers
import (
"github.com/astaxie/beego"
"fmt"
"github.com/astaxie/beego"
)
type MainController struct{ beego.Controller }
func (c *MainController) Get() {
c.Ctx.Redirect(302, "/static/Jamstash/")
}
func (c *MainController) Error404() {
if beego.BConfig.RunMode == beego.DEV || beego.BConfig.Log.AccessLogs {
r := c.Ctx.Request

View File

@ -1,8 +1,8 @@
package controllers
import (
"github.com/deluan/gosonic/models"
"encoding/json"
"github.com/deluan/gosonic/models"
"github.com/astaxie/beego"
)
@ -89,4 +89,3 @@ func (o *ObjectController) Delete() {
o.Data["json"] = "delete success!"
o.ServeJSON()
}

View File

@ -1,8 +1,8 @@
package controllers
import (
"github.com/deluan/gosonic/models"
"encoding/json"
"github.com/deluan/gosonic/models"
"github.com/astaxie/beego"
)
@ -116,4 +116,3 @@ func (u *UserController) Logout() {
u.Data["json"] = "logout success"
u.ServeJSON()
}

View File

@ -1,10 +1,10 @@
package itunes
import (
"github.com/dhowden/itl"
"os"
"github.com/deluan/gosonic/models"
"github.com/dhowden/itl"
"net/url"
"os"
"strings"
)

View File

@ -1,11 +1,11 @@
package api_test
import (
"testing"
"encoding/xml"
_ "github.com/deluan/gosonic/routers"
. "github.com/deluan/gosonic/tests"
"encoding/xml"
. "github.com/smartystreets/goconvey/convey"
"testing"
)
func TestGetLicense(t *testing.T) {
@ -24,4 +24,3 @@ func TestGetLicense(t *testing.T) {
})
}

View File

@ -1,12 +1,12 @@
package api_test
import (
"testing"
_ "github.com/deluan/gosonic/routers"
. "github.com/deluan/gosonic/tests"
"testing"
. "github.com/smartystreets/goconvey/convey"
"encoding/xml"
. "github.com/smartystreets/goconvey/convey"
)
func TestGetMusicFolders(t *testing.T) {
@ -24,4 +24,3 @@ func TestGetMusicFolders(t *testing.T) {
})
})
}

View File

@ -1,12 +1,12 @@
package api_test
import (
"testing"
"encoding/xml"
_ "github.com/deluan/gosonic/routers"
. "github.com/smartystreets/goconvey/convey"
"github.com/deluan/gosonic/api/responses"
_ "github.com/deluan/gosonic/routers"
. "github.com/deluan/gosonic/tests"
. "github.com/smartystreets/goconvey/convey"
"testing"
)
func TestPing(t *testing.T) {
@ -28,4 +28,3 @@ func TestPing(t *testing.T) {
})
}

View File

@ -1,12 +1,12 @@
package api_test
import (
"testing"
"encoding/xml"
"github.com/deluan/gosonic/api/responses"
_ "github.com/deluan/gosonic/routers"
. "github.com/deluan/gosonic/tests"
. "github.com/smartystreets/goconvey/convey"
"github.com/deluan/gosonic/api/responses"
"testing"
)
func TestCheckParams(t *testing.T) {
@ -44,5 +44,3 @@ func TestAuthentication(t *testing.T) {
})
})
}

View File

@ -3,11 +3,11 @@ package test
import (
"fmt"
"github.com/astaxie/beego"
"net/http/httptest"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"runtime"
"os"
)
const (
@ -41,4 +41,3 @@ func Get(url string, testCase string) (*http.Request, *httptest.ResponseRecorder
return r, w
}