Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix codecov #1389

Merged
merged 6 commits into from
Sep 29, 2024
Merged
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
2 changes: 1 addition & 1 deletion release/conf/polaris-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ store:
option:
path: ./polaris.bolt
loadFile: ./conf/bolt-data.yaml
## Database storage plugin
# Database storage plugin
# name: defaultStore
# option:
# master:
Expand Down
5 changes: 3 additions & 2 deletions store/mysql/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (s *roleStore) savePrincipals(tx *BaseTx, role *authcommon.Role) error {
return err
}

insertTpl := "INSERT INTO auth_role_principal(role_id, principal_id, principal_role, extend_info) VALUES (?, ?, ?)"
insertTpl := "INSERT INTO auth_role_principal(role_id, principal_id, principal_role, IFNULL(extend_info, '')) VALUES (?, ?, ?)"

for i := range role.Users {
args := []interface{}{role.ID, role.Users[i].PrincipalID, authcommon.PrincipalUser, utils.MustJson(role.Users[i].Extend)}
Expand Down Expand Up @@ -267,7 +267,8 @@ func (s *roleStore) GetMoreRoles(firstUpdate bool, mtime time.Time) ([]*authcomm
}

func (s *roleStore) fetchRolePrincipals(tx *BaseTx, role *authcommon.Role) error {
rows, err := tx.Query("SELECT role_id, principal_id, principal_role, extend_info FROM auth_role_principal WHERE rold_id = ?", role.ID)
rows, err := tx.Query("SELECT role_id, principal_id, principal_role, IFNULL(extend_info, '') FROM "+
" auth_role_principal WHERE rold_id = ?", role.ID)
if err != nil {
log.Error("[store][role] fetch role principals", zap.String("name", role.Name), zap.Error(err))
return store.Error(err)
Expand Down
12 changes: 9 additions & 3 deletions store/mysql/scripts/polaris_server.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,7 @@ INSERT INTO
`owner`,
`comment`,
`default`,
`source`,
`revision`,
`flag`,
`ctime`,
Expand All @@ -1022,6 +1023,7 @@ VALUES
'65e4789a6d5b49669adf1e9e8387549c',
'default admin',
1,
'Polaris',
'fbca9bfa04ae4ead86e1ecf5811e32a9',
0,
sysdate(),
Expand Down Expand Up @@ -1146,6 +1148,7 @@ INSERT INTO
`owner`,
`comment`,
`default`,
`source`,
`revision`,
`flag`,
`ctime`,
Expand All @@ -1159,6 +1162,7 @@ VALUES
'65e4789a6d5b49669adf1e9e8387549c',
'global resources read onyly',
1,
'Polaris',
'fbca9bfa04ae4ead86e1ecf5811e32a9',
0,
sysdate(),
Expand Down Expand Up @@ -1261,15 +1265,15 @@ VALUES

INSERT INTO
auth_strategy_function (`strategy_id`, `function`) VALUES (
'fbca9bfa04ae4ead86e1ecf5811e32a9',
'bfa04ae1e32a94fbca9ead86e1ecf581',
'Describe*'
),
(
'fbca9bfa04ae4ead86e1ecf5811e32a9',
'bfa04ae1e32a94fbca9ead86e1ecf581',
'List*'
),
(
'fbca9bfa04ae4ead86e1ecf5811e32a9',
'bfa04ae1e32a94fbca9ead86e1ecf581',
'Get*'
);

Expand All @@ -1283,6 +1287,7 @@ INSERT INTO
`owner`,
`comment`,
`default`,
`source`,
`revision`,
`flag`,
`ctime`,
Expand All @@ -1296,6 +1301,7 @@ VALUES
'65e4789a6d5b49669adf1e9e8387549c',
'global resources read and write',
1,
'Polaris',
'fbca9bfa04ae4ead86e1ecf5811e32a9',
0,
sysdate(),
Expand Down
6 changes: 3 additions & 3 deletions store/mysql/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func (s *strategyStore) addPolicyPrincipals(tx *BaseTx, id string, principals []
return nil
}

savePrincipalSql := "INSERT IGNORE INTO auth_principal(strategy_id, principal_id, principal_role, extend_info) VALUES "
savePrincipalSql := "INSERT IGNORE INTO auth_principal(strategy_id, principal_id, principal_role, IFNULL(extend_info, '')) VALUES "
values := make([]string, 0)
args := make([]interface{}, 0)

Expand Down Expand Up @@ -613,7 +613,7 @@ func (s *strategyStore) GetStrategyResources(principalId string,

func (s *strategyStore) getStrategyPrincipals(queryHander QueryHandler, id string) ([]authcommon.Principal, error) {

rows, err := queryHander("SELECT principal_id, principal_role, extend_info FROM auth_principal WHERE strategy_id = ?", id)
rows, err := queryHander("SELECT principal_id, principal_role, IFNULL(extend_info, '') FROM auth_principal WHERE strategy_id = ?", id)
if err != nil {
switch err {
case sql.ErrNoRows:
Expand Down Expand Up @@ -670,7 +670,7 @@ func (s *strategyStore) getStrategyConditions(queryHander QueryHandler, id strin

func (s *strategyStore) getStrategyFunctions(queryHander QueryHandler, id string) ([]string, error) {

rows, err := queryHander("SELECT `function` FROM auth_strategy_label WHERE strategy_id = ?", id)
rows, err := queryHander("SELECT `function` FROM auth_strategy_function WHERE strategy_id = ?", id)
if err != nil {
switch err {
case sql.ErrNoRows:
Expand Down
Loading