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}) response := responses.NewXML(&responses.License{Valid: true})
c.Ctx.Output.Body(response) c.Ctx.Output.Body(response)
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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