Skip to content

ROX-9723: Integration Scoped access control tests for secret resource type#942

Merged
rhybrillou merged 6 commits intomasterfrom
yann/ROX-9723-integrated_secret_sac_datastore_tests
Apr 12, 2022
Merged

ROX-9723: Integration Scoped access control tests for secret resource type#942
rhybrillou merged 6 commits intomasterfrom
yann/ROX-9723-integrated_secret_sac_datastore_tests

Conversation

@rhybrillou
Copy link
Copy Markdown
Contributor

Checklist

  • Investigated and inspected CI test results
  • Unit test and regression tests added
    - [ ] 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.

@ghost
Copy link
Copy Markdown

ghost commented Mar 15, 2022

Tag for build #417300 is 3.69.x-357-g07ddee3c7f.

💻 For deploying this image using the dev scripts, run the following first:

export MAIN_IMAGE_TAG='3.69.x-357-g07ddee3c7f'

🕹️ A roxctl binary can be downloaded from the CircleCI artifacts.

Comment thread pkg/fixtures/secret.go
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
}

message ListSecret {
string id = 1;
string name = 2;
string cluster_id = 7;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should go in separated PR

resultDistribution := make(map[string]map[string]int, 0)
for _, result := range results {
var clusterID string
var namespace string
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is redundant as it could be declared on initialization

@rhybrillou rhybrillou force-pushed the yann/ROX-9723-integrated_secret_sac_datastore_tests branch from b713a6b to a0644ce Compare April 11, 2022 12:49
// 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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think if you use 0 it's better to not use make

@rhybrillou rhybrillou merged commit 6a17945 into master Apr 12, 2022
@rhybrillou rhybrillou deleted the yann/ROX-9723-integrated_secret_sac_datastore_tests branch April 12, 2022 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants