Skip to content

Commit 7aace3c

Browse files
authored
Fix unit codecov (#1389)
1 parent cd564a0 commit 7aace3c

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

release/conf/polaris-server.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ store:
452452
option:
453453
path: ./polaris.bolt
454454
loadFile: ./conf/bolt-data.yaml
455-
## Database storage plugin
455+
# Database storage plugin
456456
# name: defaultStore
457457
# option:
458458
# master:

store/mysql/role.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (s *roleStore) savePrincipals(tx *BaseTx, role *authcommon.Role) error {
7070
return err
7171
}
7272

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

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

269269
func (s *roleStore) fetchRolePrincipals(tx *BaseTx, role *authcommon.Role) error {
270-
rows, err := tx.Query("SELECT role_id, principal_id, principal_role, extend_info FROM auth_role_principal WHERE rold_id = ?", role.ID)
270+
rows, err := tx.Query("SELECT role_id, principal_id, principal_role, IFNULL(extend_info, '') FROM "+
271+
" auth_role_principal WHERE rold_id = ?", role.ID)
271272
if err != nil {
272273
log.Error("[store][role] fetch role principals", zap.String("name", role.Name), zap.Error(err))
273274
return store.Error(err)

store/mysql/scripts/polaris_server.sql

+9-3
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,7 @@ INSERT INTO
10091009
`owner`,
10101010
`comment`,
10111011
`default`,
1012+
`source`,
10121013
`revision`,
10131014
`flag`,
10141015
`ctime`,
@@ -1022,6 +1023,7 @@ VALUES
10221023
'65e4789a6d5b49669adf1e9e8387549c',
10231024
'default admin',
10241025
1,
1026+
'Polaris',
10251027
'fbca9bfa04ae4ead86e1ecf5811e32a9',
10261028
0,
10271029
sysdate(),
@@ -1146,6 +1148,7 @@ INSERT INTO
11461148
`owner`,
11471149
`comment`,
11481150
`default`,
1151+
`source`,
11491152
`revision`,
11501153
`flag`,
11511154
`ctime`,
@@ -1159,6 +1162,7 @@ VALUES
11591162
'65e4789a6d5b49669adf1e9e8387549c',
11601163
'global resources read onyly',
11611164
1,
1165+
'Polaris',
11621166
'fbca9bfa04ae4ead86e1ecf5811e32a9',
11631167
0,
11641168
sysdate(),
@@ -1261,15 +1265,15 @@ VALUES
12611265

12621266
INSERT INTO
12631267
auth_strategy_function (`strategy_id`, `function`) VALUES (
1264-
'fbca9bfa04ae4ead86e1ecf5811e32a9',
1268+
'bfa04ae1e32a94fbca9ead86e1ecf581',
12651269
'Describe*'
12661270
),
12671271
(
1268-
'fbca9bfa04ae4ead86e1ecf5811e32a9',
1272+
'bfa04ae1e32a94fbca9ead86e1ecf581',
12691273
'List*'
12701274
),
12711275
(
1272-
'fbca9bfa04ae4ead86e1ecf5811e32a9',
1276+
'bfa04ae1e32a94fbca9ead86e1ecf581',
12731277
'Get*'
12741278
);
12751279

@@ -1283,6 +1287,7 @@ INSERT INTO
12831287
`owner`,
12841288
`comment`,
12851289
`default`,
1290+
`source`,
12861291
`revision`,
12871292
`flag`,
12881293
`ctime`,
@@ -1296,6 +1301,7 @@ VALUES
12961301
'65e4789a6d5b49669adf1e9e8387549c',
12971302
'global resources read and write',
12981303
1,
1304+
'Polaris',
12991305
'fbca9bfa04ae4ead86e1ecf5811e32a9',
13001306
0,
13011307
sysdate(),

store/mysql/strategy.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ func (s *strategyStore) addPolicyPrincipals(tx *BaseTx, id string, principals []
277277
return nil
278278
}
279279

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

@@ -613,7 +613,7 @@ func (s *strategyStore) GetStrategyResources(principalId string,
613613

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

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

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

673-
rows, err := queryHander("SELECT `function` FROM auth_strategy_label WHERE strategy_id = ?", id)
673+
rows, err := queryHander("SELECT `function` FROM auth_strategy_function WHERE strategy_id = ?", id)
674674
if err != nil {
675675
switch err {
676676
case sql.ErrNoRows:

0 commit comments

Comments
 (0)