mirror of
https://github.com/photoprism/photoprism.git
synced 2026-01-23 02:24:24 +00:00
CLI: Refactor cluster_helpers.go and cluster_theme_pull_oauth_test.go
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
parent
5d6e46b87f
commit
bc83e00273
2 changed files with 6 additions and 9 deletions
|
|
@ -22,12 +22,12 @@ func obtainClientCredentialsViaRegister(portalURL, joinToken, nodeName string) (
|
|||
endpoint := *u
|
||||
endpoint.Path = strings.TrimRight(endpoint.Path, "/") + "/api/v1/cluster/nodes/register"
|
||||
|
||||
reqBody := map[string]any{
|
||||
"nodeName": nodeName,
|
||||
"nodeRole": cluster.RoleInstance,
|
||||
"rotateSecret": true,
|
||||
payload := cluster.RegisterRequest{
|
||||
NodeName: nodeName,
|
||||
NodeRole: cluster.RoleInstance,
|
||||
RotateSecret: true,
|
||||
}
|
||||
b, _ := json.Marshal(reqBody)
|
||||
b, _ := json.Marshal(payload)
|
||||
req, _ := http.NewRequest(http.MethodPost, endpoint.String(), bytes.NewReader(b))
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
header.SetAuthorization(req, joinToken)
|
||||
|
|
|
|||
|
|
@ -86,10 +86,7 @@ func TestClusterThemePull_JoinTokenToOAuth(t *testing.T) {
|
|||
return
|
||||
}
|
||||
// Read body to check rotateSecret flag
|
||||
var req struct {
|
||||
RotateSecret bool `json:"rotateSecret"`
|
||||
NodeName string `json:"nodeName"`
|
||||
}
|
||||
var req cluster.RegisterRequest
|
||||
_ = json.NewDecoder(r.Body).Decode(&req)
|
||||
sawRotateSecret = req.RotateSecret
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue