mirror of
https://github.com/balzack/databag.git
synced 2025-02-16 05:29:15 +00:00
testing searchable flag
This commit is contained in:
parent
dde82cd37b
commit
d82cc5009b
@ -63,8 +63,4 @@ func GetAccountListing(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetAccountSeachable(w http.ResponseWriter, r *http.Request) {
|
|
||||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
|
||||||
w.WriteHeader(http.StatusOK)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@ import (
|
|||||||
|
|
||||||
func GetAccountStatus(w http.ResponseWriter, r *http.Request) {
|
func GetAccountStatus(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
account, err := AccountLogin(r)
|
account, code, err := BearerAppToken(r, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ErrResponse(w, http.StatusUnauthorized, err)
|
ErrResponse(w, code, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
29
net/server/internal/api_setAccountSearchable.go
Normal file
29
net/server/internal/api_setAccountSearchable.go
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package databag
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"databag/internal/store"
|
||||||
|
)
|
||||||
|
|
||||||
|
func SetAccountSearchable(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
account, code, err := BearerAppToken(r, false)
|
||||||
|
if err != nil {
|
||||||
|
ErrResponse(w, code, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var flag bool
|
||||||
|
if err := ParseRequest(r, w, &flag); err != nil {
|
||||||
|
ErrResponse(w, http.StatusBadRequest, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = store.DB.Model(account).Update("searchable", flag).Error; err != nil {
|
||||||
|
ErrResponse(w, http.StatusInternalServerError, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
WriteResponse(w, nil)
|
||||||
|
}
|
||||||
|
|
@ -180,6 +180,13 @@ var routes = Routes{
|
|||||||
SetAccountNode,
|
SetAccountNode,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Route{
|
||||||
|
"SetAccountSerchable",
|
||||||
|
strings.ToUpper("Put"),
|
||||||
|
"/account/searchable",
|
||||||
|
SetAccountSearchable,
|
||||||
|
},
|
||||||
|
|
||||||
Route{
|
Route{
|
||||||
"AddNodeAccount",
|
"AddNodeAccount",
|
||||||
strings.ToUpper("Post"),
|
strings.ToUpper("Post"),
|
||||||
|
@ -92,12 +92,17 @@ func TestAccountConfig(t *testing.T) {
|
|||||||
return false
|
return false
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
// set to searchable
|
||||||
|
searchable := true
|
||||||
|
params = &TestApiParams{ query: "/account/searchable", tokenType: APP_TOKENAPP, token: set.A.Token, body: &searchable }
|
||||||
|
assert.NoError(t, TestApiRequest(SetAccountSearchable, params, nil))
|
||||||
|
|
||||||
// get account status
|
// get account status
|
||||||
accountStatus := &AccountStatus{}
|
accountStatus := &AccountStatus{}
|
||||||
params = &TestApiParams{ query: "/account/status", authorization: "newguy:ssap",
|
params = &TestApiParams{ query: "/account/status", tokenType: APP_TOKENAPP, token: set.A.Token }
|
||||||
path: map[string]string{ "channelId": channel.Id, "topicId": topic.Id } }
|
|
||||||
response = &TestApiResponse{ data: accountStatus }
|
response = &TestApiResponse{ data: accountStatus }
|
||||||
assert.NoError(t, TestApiRequest(GetAccountStatus, params, response))
|
assert.NoError(t, TestApiRequest(GetAccountStatus, params, response))
|
||||||
|
assert.True(t, accountStatus.Searchable)
|
||||||
|
|
||||||
// add asset to topic
|
// add asset to topic
|
||||||
assets = &[]Asset{}
|
assets = &[]Asset{}
|
||||||
|
Loading…
Reference in New Issue
Block a user