-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update config import for user role mappings
- Loading branch information
Showing
8 changed files
with
498 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
sources: | ||
- type: okta | ||
oktaDomain: acme.okta.com | ||
oktaClientId: 0oapn0qwiQPiMIyR35d6 | ||
oktaClientSecret: jfpn0qwiQPiMIfs408fjs048fjpn0qwiQPiMajsdf08j10j2 | ||
oktaApiToken: 001XJv9xhv899sdfns938haos3h8oahsdaohd2o8hdao82hd | ||
users: | ||
admin@example.com: | ||
roles: | ||
admin: | ||
kind: cluster-role | ||
clusters: | ||
- cluster-AAA | ||
- cluster-BBB | ||
bob@example.com: | ||
roles: | ||
writer: | ||
kind: cluster-role | ||
clusters: | ||
- cluster-AAA | ||
reader: | ||
kind: cluster-role | ||
clusters: | ||
- cluster-BBB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package registry | ||
|
||
import ( | ||
"io/ioutil" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestImportCurrentValidConfig(t *testing.T) { | ||
conf, err := ioutil.ReadFile("_testdata/infra.yaml") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
db, err := NewDB("file::memory:") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
assert.NoError(t, ImportConfig(db, conf)) | ||
} | ||
|
||
// func TestImportUsersThatDoNotExist(t *testing.T) { | ||
// confFile, err := ioutil.ReadFile("_testdata/infra.yaml") | ||
// if err != nil { | ||
// t.Fatal(err) | ||
// } | ||
// config := NewConfig() | ||
// err = yaml.Unmarshal(confFile, &config) | ||
// if err != nil { | ||
// t.Fatal(err) | ||
// } | ||
|
||
// db, err := NewDB("file::memory:") | ||
// if err != nil { | ||
// t.Fatal(err) | ||
// } | ||
|
||
// ImportUserMappings(db, config.Users) | ||
// for user, userMapping := range config.Users { | ||
// for roleName, role := range userMapping.Roles { | ||
// var permission Permission | ||
// err = db.Where(&permission, &Permission{Role: roleName, Kind: role.Kind, UserId: user.Id, DestinationId: destination.Id, FromConfig: true}).Error | ||
// if err != nil { | ||
// return nil, err | ||
// } | ||
// } | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.