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
c6712455
Commit
c6712455
authored
May 13, 2019
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apiextensions: add pruning e2e & integration tests for admission webhooks
parent
77bfddac
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
3 deletions
+51
-3
webhook.go
test/e2e/apimachinery/webhook.go
+8
-3
admission_test.go
.../integration/apiserver/admissionwebhook/admission_test.go
+43
-0
No files found.
test/e2e/apimachinery/webhook.go
View file @
c6712455
...
...
@@ -210,9 +210,14 @@ var _ = SIGDescribe("AdmissionWebhook", func() {
OpenAPIV3Schema
:
&
apiextensionsv1beta1
.
JSONSchemaProps
{
Type
:
"object"
,
Properties
:
map
[
string
]
apiextensionsv1beta1
.
JSONSchemaProps
{
"mutation-start"
:
{
Type
:
"string"
},
"mutation-stage-1"
:
{
Type
:
"string"
},
// mutation-stage-2 is intentionally missing such that it is pruned
"data"
:
{
Type
:
"object"
,
Properties
:
map
[
string
]
apiextensionsv1beta1
.
JSONSchemaProps
{
"mutation-start"
:
{
Type
:
"string"
},
"mutation-stage-1"
:
{
Type
:
"string"
},
// mutation-stage-2 is intentionally missing such that it is pruned
},
},
},
},
}
...
...
test/integration/apiserver/admissionwebhook/admission_test.go
View file @
c6712455
...
...
@@ -113,6 +113,9 @@ var (
gvr
(
""
,
"v1"
,
"nodes/proxy"
)
:
{
"*"
:
testSubresourceProxy
},
gvr
(
""
,
"v1"
,
"pods/proxy"
)
:
{
"*"
:
testSubresourceProxy
},
gvr
(
""
,
"v1"
,
"services/proxy"
)
:
{
"*"
:
testSubresourceProxy
},
gvr
(
"random.numbers.com"
,
"v1"
,
"integers"
)
:
{
"create"
:
testPruningRandomNumbers
},
gvr
(
"custom.fancy.com"
,
"v2"
,
"pants"
)
:
{
"create"
:
testNoPruningCustomFancy
},
}
// admissionExemptResources lists objects which are exempt from admission validation/mutation,
...
...
@@ -931,6 +934,46 @@ func testSubresourceProxy(c *testContext) {
}
}
func
testPruningRandomNumbers
(
c
*
testContext
)
{
testResourceCreate
(
c
)
cr2pant
,
err
:=
c
.
client
.
Resource
(
c
.
gvr
)
.
Get
(
"fortytwo"
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
c
.
t
.
Error
(
err
)
return
}
foo
,
found
,
err
:=
unstructured
.
NestedString
(
cr2pant
.
Object
,
"foo"
)
if
err
!=
nil
{
c
.
t
.
Error
(
err
)
return
}
if
found
{
c
.
t
.
Errorf
(
"expected .foo to be pruned, but got: %s"
,
foo
)
}
}
func
testNoPruningCustomFancy
(
c
*
testContext
)
{
testResourceCreate
(
c
)
cr2pant
,
err
:=
c
.
client
.
Resource
(
c
.
gvr
)
.
Get
(
"cr2pant"
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
c
.
t
.
Error
(
err
)
return
}
foo
,
_
,
err
:=
unstructured
.
NestedString
(
cr2pant
.
Object
,
"foo"
)
if
err
!=
nil
{
c
.
t
.
Error
(
err
)
return
}
// check that no pruning took place
if
expected
,
got
:=
"test"
,
foo
;
expected
!=
got
{
c
.
t
.
Errorf
(
"expected /foo to be %q, got: %q"
,
expected
,
got
)
}
}
//
// utility methods
//
...
...
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