Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
cb565585
Commit
cb565585
authored
Jul 28, 2017
by
Mike Danese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
csr: add resync to csr approver
parent
5ce3b359
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
sarapprove.go
pkg/controller/certificates/approver/sarapprove.go
+10
-0
sarapprove_test.go
pkg/controller/certificates/approver/sarapprove_test.go
+4
-2
No files found.
pkg/controller/certificates/approver/sarapprove.go
View file @
cb565585
...
@@ -91,10 +91,15 @@ func (a *sarApprover) handle(csr *capi.CertificateSigningRequest) error {
...
@@ -91,10 +91,15 @@ func (a *sarApprover) handle(csr *capi.CertificateSigningRequest) error {
return
fmt
.
Errorf
(
"unable to parse csr %q: %v"
,
csr
.
Name
,
err
)
return
fmt
.
Errorf
(
"unable to parse csr %q: %v"
,
csr
.
Name
,
err
)
}
}
tried
:=
[]
string
{}
for
_
,
r
:=
range
a
.
recognizers
{
for
_
,
r
:=
range
a
.
recognizers
{
if
!
r
.
recognize
(
csr
,
x509cr
)
{
if
!
r
.
recognize
(
csr
,
x509cr
)
{
continue
continue
}
}
tried
=
append
(
tried
,
r
.
permission
.
Subresource
)
approved
,
err
:=
a
.
authorize
(
csr
,
r
.
permission
)
approved
,
err
:=
a
.
authorize
(
csr
,
r
.
permission
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -108,6 +113,11 @@ func (a *sarApprover) handle(csr *capi.CertificateSigningRequest) error {
...
@@ -108,6 +113,11 @@ func (a *sarApprover) handle(csr *capi.CertificateSigningRequest) error {
return
nil
return
nil
}
}
}
}
if
len
(
tried
)
!=
0
{
return
fmt
.
Errorf
(
"recognized csr %q as %v but subject access review was not approved"
,
csr
.
Name
,
tried
)
}
return
nil
return
nil
}
}
...
...
pkg/controller/certificates/approver/sarapprove_test.go
View file @
cb565585
...
@@ -89,6 +89,7 @@ func TestHandle(t *testing.T) {
...
@@ -89,6 +89,7 @@ func TestHandle(t *testing.T) {
message
string
message
string
allowed
bool
allowed
bool
recognized
bool
recognized
bool
err
bool
verify
func
(
*
testing
.
T
,
[]
testclient
.
Action
)
verify
func
(
*
testing
.
T
,
[]
testclient
.
Action
)
}{
}{
{
{
...
@@ -119,6 +120,7 @@ func TestHandle(t *testing.T) {
...
@@ -119,6 +120,7 @@ func TestHandle(t *testing.T) {
}
}
_
=
as
[
0
]
.
(
testclient
.
CreateActionImpl
)
_
=
as
[
0
]
.
(
testclient
.
CreateActionImpl
)
},
},
err
:
true
,
},
},
{
{
recognized
:
true
,
recognized
:
true
,
...
@@ -155,7 +157,7 @@ func TestHandle(t *testing.T) {
...
@@ -155,7 +157,7 @@ func TestHandle(t *testing.T) {
}
}
for
_
,
c
:=
range
cases
{
for
_
,
c
:=
range
cases
{
t
.
Run
(
fmt
.
Sprintf
(
"recognized:%v,allowed: %v
"
,
c
.
recognized
,
c
.
allowed
),
func
(
t
*
testing
.
T
)
{
t
.
Run
(
fmt
.
Sprintf
(
"recognized:%v,allowed: %v
,err: %v"
,
c
.
recognized
,
c
.
allowed
,
c
.
err
),
func
(
t
*
testing
.
T
)
{
client
:=
&
fake
.
Clientset
{}
client
:=
&
fake
.
Clientset
{}
client
.
AddReactor
(
"create"
,
"subjectaccessreviews"
,
func
(
action
testclient
.
Action
)
(
handled
bool
,
ret
runtime
.
Object
,
err
error
)
{
client
.
AddReactor
(
"create"
,
"subjectaccessreviews"
,
func
(
action
testclient
.
Action
)
(
handled
bool
,
ret
runtime
.
Object
,
err
error
)
{
return
true
,
&
authorization
.
SubjectAccessReview
{
return
true
,
&
authorization
.
SubjectAccessReview
{
...
@@ -177,7 +179,7 @@ func TestHandle(t *testing.T) {
...
@@ -177,7 +179,7 @@ func TestHandle(t *testing.T) {
},
},
}
}
csr
:=
makeTestCsr
()
csr
:=
makeTestCsr
()
if
err
:=
approver
.
handle
(
csr
);
err
!=
nil
{
if
err
:=
approver
.
handle
(
csr
);
err
!=
nil
&&
!
c
.
err
{
t
.
Errorf
(
"unexpected err: %v"
,
err
)
t
.
Errorf
(
"unexpected err: %v"
,
err
)
}
}
c
.
verify
(
t
,
client
.
Actions
())
c
.
verify
(
t
,
client
.
Actions
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment