feat(copilot): finish configuration center
This commit is contained in:
@@ -146,6 +146,28 @@ func TestChatwootAuthValidateTokenReturnsPayloadData(t *testing.T) {
|
||||
assertChatwootAuthUserFixture(t, data)
|
||||
}
|
||||
|
||||
func TestChatwootAuthValidateTokenSerializesPlatformAdminType(t *testing.T) {
|
||||
router, db, user := setupChatwootAuthTest(t)
|
||||
require.NoError(t, db.Model(user).Updates(map[string]any{
|
||||
"role": "super_admin",
|
||||
"type": "User",
|
||||
}).Error)
|
||||
|
||||
token := signInAndReturnAccessToken(t, router)
|
||||
req, _ := http.NewRequest(http.MethodGet, "/auth/validate_token", nil)
|
||||
req.Header.Set("access-token", token)
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
router.ServeHTTP(w, req)
|
||||
|
||||
require.Equal(t, http.StatusOK, w.Code)
|
||||
var body map[string]any
|
||||
require.NoError(t, json.Unmarshal(w.Body.Bytes(), &body))
|
||||
data := body["payload"].(map[string]any)["data"].(map[string]any)
|
||||
require.Equal(t, "SuperAdmin", data["type"])
|
||||
require.Equal(t, "administrator", data["role"])
|
||||
}
|
||||
|
||||
func TestChatwootAuthSignOutRevokesRefreshSession(t *testing.T) {
|
||||
router, _, _ := setupChatwootAuthTest(t)
|
||||
token := signInAndReturnAccessToken(t, router)
|
||||
|
||||
Reference in New Issue
Block a user