Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions ssolib/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,20 @@ type App struct {
Secret string `json:"secret"`
RedirectUri string `json:"redirect_uri"`
AdminGroup *Group `json:"admin_group"`
}

type AppInfoResource struct {
server.BaseResource
}
func (ai AppInfoResource) Get(ctx context.Context, r *http.Request) (int, interface{}) {
err := requireLogin(ctx)
if err != nil {
return http.StatusUnauthorized, err
}
mctx := getModelContext(ctx)
Apps, err := app.ListApps(mctx)
if err != nil {
return http.StatusInternalServerError, err
}
return http.StatusOK, Apps
}
14 changes: 0 additions & 14 deletions ssolib/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"net/http"
"strings"
"github.com/laincloud/sso/Godeps/_workspace/src/github.com/stretchr/testify/assert"
"github.com/laincloud/sso/ssolib/models/iuser"
"github.com/laincloud/sso/ssolib/models/testbackend"
)

func TestAppResource_Put(t *testing.T) {
Expand Down Expand Up @@ -91,16 +89,4 @@ func createApp2(th *TestHelper) (int, interface{}){
r, _ := http.NewRequest("POST", "http://sso.example.com/api/apps",
strings.NewReader(`{"fullname": "app2", "redirect_uri": "https://example.com"}`))
return AppsResource{}.Post(th.Ctx, r)
}

func createTestUserWithEmail(th *TestHelper, username string) iuser.User {
err := testBack.CreateUser(&testbackend.TestUser{
Name: username,
PasswordHash: []byte("test"),
Email: username+"@example.com",
}, true)
assert.Nil(th.T, err)
u, err := testBack.GetUserByName(username)
assert.Nil(th.T, err)
return u
}
Loading