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
25afdbe0
Commit
25afdbe0
authored
Aug 25, 2017
by
zhangxiaoyu-zidif
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add unit test for describe secret
parent
9f5849a0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
describe_test.go
pkg/printers/internalversion/describe_test.go
+25
-0
No files found.
pkg/printers/internalversion/describe_test.go
View file @
25afdbe0
...
...
@@ -118,6 +118,31 @@ func TestDescribePodTolerations(t *testing.T) {
}
}
func
TestDescribeSecret
(
t
*
testing
.
T
)
{
fake
:=
fake
.
NewSimpleClientset
(
&
api
.
Secret
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"bar"
,
Namespace
:
"foo"
,
},
Data
:
map
[
string
][]
byte
{
"username"
:
[]
byte
(
"YWRtaW4="
),
"password"
:
[]
byte
(
"MWYyZDFlMmU2N2Rm"
),
},
})
c
:=
&
describeClient
{
T
:
t
,
Namespace
:
"foo"
,
Interface
:
fake
}
d
:=
SecretDescriber
{
c
}
out
,
err
:=
d
.
Describe
(
"foo"
,
"bar"
,
printers
.
DescriberSettings
{})
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
if
!
strings
.
Contains
(
out
,
"bar"
)
||
!
strings
.
Contains
(
out
,
"foo"
)
||
!
strings
.
Contains
(
out
,
"username"
)
||
!
strings
.
Contains
(
out
,
"8 bytes"
)
||
!
strings
.
Contains
(
out
,
"password"
)
||
!
strings
.
Contains
(
out
,
"16 bytes"
)
{
t
.
Errorf
(
"unexpected out: %s"
,
out
)
}
if
strings
.
Contains
(
out
,
"YWRtaW4="
)
||
strings
.
Contains
(
out
,
"MWYyZDFlMmU2N2Rm"
)
{
t
.
Errorf
(
"sensitive data should not be shown, unexpected out: %s"
,
out
)
}
}
func
TestDescribeNamespace
(
t
*
testing
.
T
)
{
fake
:=
fake
.
NewSimpleClientset
(
&
api
.
Namespace
{
ObjectMeta
:
metav1
.
ObjectMeta
{
...
...
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