-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add behavioural tests for Cluster Menu K8s Resources in Sidebar menu not being shown #7280
Conversation
packages/core/src/common/cluster/request-namespace-list-permissions.injectable.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO this PR touches too many places for a hotfix (patch release).
const { | ||
fakeTime = true, | ||
} = options; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that there's case where we want to support behavioural unit tests without fake time.
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
7e0556b
to
931048e
Compare
Conflicts have been resolved. A maintainer will review the pull request shortly. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
931048e
to
c7ef585
Compare
Conflicts have been resolved. A maintainer will review the pull request shortly. |
c7ef585
to
b3773c8
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
b3773c8
to
c5e1778
Compare
Conflicts have been resolved. A maintainer will review the pull request shortly. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
93abc4c
to
7c48248
Compare
Conflicts have been resolved. A maintainer will review the pull request shortly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all refactoring? (I don't see any tests added)
I guess my comments are for the previous review, and not really an issue if "CreateCanI" is called more than once, so "CanI" can change, if some auth/api error gets corrected.
} catch (error) { | ||
logger.error(`[AUTHORIZATION-REVIEW]: failed to create access review: ${error}`, { resourceAttributes }); | ||
|
||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there's an error do we know for sure the answer is false
? Seems strange that the caller doesn't know there was an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No we don't, but since these are currently only used for optimizations it is fine if they are turned off in case of error.
Plus this has always been the case.
logger.warn(`[AUTHORIZATION-NAMESPACE-REVIEW]: allowing all resources in namespace="${namespace}" due to incomplete SelfSubjectRulesReview: ${status?.evaluationError}`); | ||
|
||
return () => true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The caller has no idea here, or in the catch below, that api.createSelfSubjectRulesReview()
failed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is safer to show all the resources of this fails then to show none.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'm really questioning whether that decision should be made here or by the caller, which might be able to show a helpful notification to the end-user. Now there is no indication to the user why there are suddenly all these resources listed in the sidebar that perhaps can't be listed.
packages/core/src/features/cluster/refresh-accessibility-technical.test.ts was added The diff is large so it is hidden by default. |
This PR fixes an oversight in #6657. Namely, I previously assumed that all the applicable resources rules would be merged together on the server side before sending a response back for a given
SelfSubjectRulesReview
. That, however, is not the case and instead it seems that most kubernetes distros (or at least K0s) just find all the applicable rules and then send them all back in a list.To reproduce this yourself:
ClusterRoles
's, one callednamespace-get
which allows theget
verb onnamespaces
and one callednamespace-list
which allows thelist
verb onnamespaces
ClusterRoleBindings
, one for each of the above, targeting your own user.curl -H "Content-Type: application/json" -X POST 127.0.0.1:8001/apis/authorization.k8s.io/v1/selfsubjectrulesreviews --data '{ "apiVersion": "authorization.k8s.io/v1", "kind": "SelfSubjectRulesReview", "spec": { "namespace": "default" }}'