Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
k8s-crt-dnldr
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
k8s
k8s-crt-dnldr
Commits
71a69b25
Commit
71a69b25
authored
Jul 28, 2020
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
REST API: test error response for /v1/pems.
parent
64ccf633
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
+50
-0
allpems_handler_test.go
pkg/rest/allpems_handler_test.go
+50
-0
No files found.
pkg/rest/allpems_handler_test.go
View file @
71a69b25
...
...
@@ -83,6 +83,15 @@ var (
ModTime
:
time
.
Date
(
2020
,
7
,
27
,
9
,
51
,
0
,
0
,
time
.
UTC
),
}
invalidFile
=
&
pem
.
File
{
Namespace
:
"invalid"
,
Name
:
"crt"
,
UID
:
"9396fc87-23eb-480a-8437-f9767df13ed8"
,
ResourceVersion
:
"123456"
,
Size
:
132
,
ModTime
:
time
.
Date
(
2020
,
7
,
28
,
6
,
9
,
0
,
0
,
time
.
UTC
),
}
expWhiskeyCrt
=
pem
.
Crt
{
Version
:
3
,
SN
:
"2f:6d:d8:e4:83:f0:e7:44:4d:3a:cc:97:52:0e:18:93:d7:a5:1f:0d"
,
...
...
@@ -325,6 +334,47 @@ func TestAllPems(t *testing.T) {
if
len
(
allInfo
)
!=
0
{
t
.
Fatalf
(
"GET /v1/pems len(slice) got %d want 0"
,
len
(
allInfo
))
}
files
.
Files
[
"invalid/crt"
]
=
invalidFile
req
=
httptest
.
NewRequest
(
http
.
MethodGet
,
"/v1/pems"
,
nil
)
rr
=
httptest
.
NewRecorder
()
hndlr
.
ServeHTTP
(
rr
,
req
)
if
rr
.
Code
!=
http
.
StatusInternalServerError
{
t
.
Errorf
(
"GET /v1/pems status: got %d want %d"
,
rr
.
Code
,
http
.
StatusInternalServerError
)
}
if
rr
.
Header
()
.
Get
(
"Content-Type"
)
!=
problemContentType
{
t
.
Errorf
(
"GET /v1/pems Content-Type: got %s want %s"
,
rr
.
Header
()
.
Get
(
"Content-Type"
),
problemContentType
)
}
bodylen
:=
len
(
rr
.
Body
.
String
())
if
rr
.
Header
()
.
Get
(
"Content-Length"
)
!=
strconv
.
Itoa
(
bodylen
)
{
t
.
Errorf
(
"GET /v1/pems Content-Length: got %s want %d"
,
rr
.
Header
()
.
Get
(
"Content-Length"
),
bodylen
)
}
problem
:=
&
Problem
{}
if
err
=
json
.
Unmarshal
(
rr
.
Body
.
Bytes
(),
problem
);
err
!=
nil
{
t
.
Fatalf
(
"GET /v1/pems body unmarshal: %v"
,
err
)
}
if
problem
.
Type
!=
errPemsReadErr
.
Type
{
t
.
Errorf
(
"GET /v1/pems problem type: got %s want %s"
,
problem
.
Type
,
errPemsReadErr
.
Type
)
}
if
problem
.
Title
!=
errPemsReadErr
.
Title
{
t
.
Errorf
(
"GET /v1/pems problem title: got %s want %s"
,
problem
.
Title
,
errPemsReadErr
.
Title
)
}
if
len
(
problem
.
Detail
)
==
0
{
t
.
Error
(
"GET /v1/pems problem detail empty"
)
}
if
problem
.
Status
!=
http
.
StatusInternalServerError
{
t
.
Errorf
(
"GET /v1/pems problem status: got %d want %d"
,
problem
.
Status
,
http
.
StatusInternalServerError
)
}
if
!
errInstancePattern
.
Match
([]
byte
(
problem
.
Instance
))
{
t
.
Errorf
(
"GET /v1/pems problem instance: "
+
"got %s want /log/errors/N"
,
problem
.
Instance
)
}
}
func
TestAllPems405
(
t
*
testing
.
T
)
{
...
...
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