ROX-9723: Integration Scoped access control tests for secret resource type#942
Merged
rhybrillou merged 6 commits intomasterfrom Apr 12, 2022
Merged
Conversation
|
Tag for build #417300 is 💻 For deploying this image using the dev scripts, run the following first: export MAIN_IMAGE_TAG='3.69.x-357-g07ddee3c7f'🕹️ A |
janisz
reviewed
Mar 21, 2022
| secrets = append(secrets, GetScopedSecret(uuid.NewV4().String(), testconsts.Cluster2, testconsts.NamespaceB)) | ||
| secrets = append(secrets, GetScopedSecret(uuid.NewV4().String(), testconsts.Cluster2, testconsts.NamespaceC)) | ||
| secrets = append(secrets, GetScopedSecret(uuid.NewV4().String(), testconsts.Cluster2, testconsts.NamespaceC)) | ||
| return secrets |
Contributor
There was a problem hiding this comment.
nit:
// GetSACTestSecretSet returns a set of mock secrets that can be used for scoped access control tests
func GetSACTestSecretSet() []*storage.Secret {
secrets := []*storage.Secret{
scopedSecret(testconsts.Cluster1, testconsts.NamespaceA),
scopedSecret(testconsts.Cluster1, testconsts.NamespaceA),
scopedSecret(testconsts.Cluster1, testconsts.NamespaceA),
scopedSecret(testconsts.Cluster1, testconsts.NamespaceA),
scopedSecret(testconsts.Cluster1, testconsts.NamespaceA),
scopedSecret(testconsts.Cluster1, testconsts.NamespaceA),
scopedSecret(testconsts.Cluster1, testconsts.NamespaceA),
scopedSecret(testconsts.Cluster1, testconsts.NamespaceA),
scopedSecret(testconsts.Cluster1, testconsts.NamespaceB),
scopedSecret(testconsts.Cluster1, testconsts.NamespaceB),
scopedSecret(testconsts.Cluster1, testconsts.NamespaceB),
scopedSecret(testconsts.Cluster1, testconsts.NamespaceB),
scopedSecret(testconsts.Cluster1, testconsts.NamespaceB),
scopedSecret(testconsts.Cluster2, testconsts.NamespaceB),
scopedSecret(testconsts.Cluster2, testconsts.NamespaceB),
scopedSecret(testconsts.Cluster2, testconsts.NamespaceB),
scopedSecret(testconsts.Cluster2, testconsts.NamespaceC),
scopedSecret(testconsts.Cluster2, testconsts.NamespaceC),
}
return secrets
}
func scopedSecret(cluster, namespace string) *storage.Secret {
return GetScopedSecret(uuid.NewV4().String(), cluster, namespace)
}
janisz
reviewed
Mar 21, 2022
| message ListSecret { | ||
| string id = 1; | ||
| string name = 2; | ||
| string cluster_id = 7; |
Contributor
There was a problem hiding this comment.
I think this should go in separated PR
janisz
reviewed
Mar 21, 2022
| resultDistribution := make(map[string]map[string]int, 0) | ||
| for _, result := range results { | ||
| var clusterID string | ||
| var namespace string |
Contributor
There was a problem hiding this comment.
This is redundant as it could be declared on initialization
janisz
approved these changes
Mar 21, 2022
1 task
This was referenced Apr 8, 2022
b713a6b to
a0644ce
Compare
janisz
reviewed
Apr 11, 2022
| // CountSearchResultObjectsPerClusterAndNamespace builds a result distribution map from the search output of a test, | ||
| // counting the results per cluster and namespace. | ||
| func CountSearchResultObjectsPerClusterAndNamespace(_ *testing.T, results []sac.NamespaceScopedObject) map[string]map[string]int { | ||
| resultDistribution := make(map[string]map[string]int, 0) |
Contributor
There was a problem hiding this comment.
nit: I think if you use 0 it's better to not use make
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
- [ ] Evaluated and added CHANGELOG entry if required- [ ] Determined and documented upgrade steps- [ ] Documented user facing changes (create PR based on [stackrox/openshift-docs] (https://github.com/stackrox/openshift-docs) and merge into rhacs-docs).If any of these don't apply, please comment below.
This pull request only adds integration tests for scoped access control against one specific resource type. It does not alter the user experience, nor requires data model changes
Testing Performed
Locally running the added tests is the level of testing performed so far.