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
2fb3ba71
Unverified
Commit
2fb3ba71
authored
Oct 08, 2018
by
Ibrahim AshShohail
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update usages of http.ResponseWriter.WriteHeader to use http.Error
Signed-off-by:
Ibrahim AshShohail
<
me@ibrasho.com
>
parent
add731df
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
29 additions
and
32 deletions
+29
-32
markmaster_test.go
cmd/kubeadm/app/phases/markmaster/markmaster_test.go
+2
-2
endpoints_controller_test.go
pkg/controller/endpoint/endpoints_controller_test.go
+1
-1
dump.go
pkg/controller/garbagecollector/dump.go
+2
-3
metadata_test.go
pkg/credentialprovider/gcp/metadata_test.go
+7
-7
proxy_server.go
pkg/kubectl/proxy/proxy_server.go
+1
-2
httpstream.go
pkg/kubelet/server/remotecommand/httpstream.go
+1
-2
http_test.go
pkg/probe/http/http_test.go
+1
-1
httpstream.go
...src/k8s.io/apimachinery/pkg/util/httpstream/httpstream.go
+3
-3
upgrade.go
...c/k8s.io/apimachinery/pkg/util/httpstream/spdy/upgrade.go
+4
-4
authn_audit_test.go
...8s.io/apiserver/pkg/endpoints/filters/authn_audit_test.go
+4
-4
maxinflight.go
...ng/src/k8s.io/apiserver/pkg/server/filters/maxinflight.go
+2
-2
etcd_util_test.go
.../k8s.io/apiserver/pkg/storage/etcd/util/etcd_util_test.go
+1
-1
No files found.
cmd/kubeadm/app/phases/markmaster/markmaster_test.go
View file @
2fb3ba71
...
@@ -140,7 +140,7 @@ func TestMarkMaster(t *testing.T) {
...
@@ -140,7 +140,7 @@ func TestMarkMaster(t *testing.T) {
if
req
.
URL
.
Path
!=
"/api/v1/nodes/"
+
hostname
{
if
req
.
URL
.
Path
!=
"/api/v1/nodes/"
+
hostname
{
t
.
Errorf
(
"MarkMaster(%s): request for unexpected HTTP resource: %v"
,
tc
.
name
,
req
.
URL
.
Path
)
t
.
Errorf
(
"MarkMaster(%s): request for unexpected HTTP resource: %v"
,
tc
.
name
,
req
.
URL
.
Path
)
w
.
WriteHeader
(
http
.
StatusNotFound
)
http
.
Error
(
w
,
""
,
http
.
StatusNotFound
)
return
return
}
}
...
@@ -150,7 +150,7 @@ func TestMarkMaster(t *testing.T) {
...
@@ -150,7 +150,7 @@ func TestMarkMaster(t *testing.T) {
patchRequest
=
toString
(
req
.
Body
)
patchRequest
=
toString
(
req
.
Body
)
default
:
default
:
t
.
Errorf
(
"MarkMaster(%s): request for unexpected HTTP verb: %v"
,
tc
.
name
,
req
.
Method
)
t
.
Errorf
(
"MarkMaster(%s): request for unexpected HTTP verb: %v"
,
tc
.
name
,
req
.
Method
)
w
.
WriteHeader
(
http
.
StatusNotFound
)
http
.
Error
(
w
,
""
,
http
.
StatusNotFound
)
return
return
}
}
...
...
pkg/controller/endpoint/endpoints_controller_test.go
View file @
2fb3ba71
...
@@ -120,7 +120,7 @@ func makeTestServer(t *testing.T, namespace string) (*httptest.Server, *utiltest
...
@@ -120,7 +120,7 @@ func makeTestServer(t *testing.T, namespace string) (*httptest.Server, *utiltest
mux
.
Handle
(
testapi
.
Default
.
ResourcePath
(
"endpoints/"
,
namespace
,
""
),
&
fakeEndpointsHandler
)
mux
.
Handle
(
testapi
.
Default
.
ResourcePath
(
"endpoints/"
,
namespace
,
""
),
&
fakeEndpointsHandler
)
mux
.
HandleFunc
(
"/"
,
func
(
res
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
mux
.
HandleFunc
(
"/"
,
func
(
res
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
t
.
Errorf
(
"unexpected request: %v"
,
req
.
RequestURI
)
t
.
Errorf
(
"unexpected request: %v"
,
req
.
RequestURI
)
res
.
WriteHeader
(
http
.
StatusNotFound
)
http
.
Error
(
res
,
""
,
http
.
StatusNotFound
)
})
})
return
httptest
.
NewServer
(
mux
),
&
fakeEndpointsHandler
return
httptest
.
NewServer
(
mux
),
&
fakeEndpointsHandler
}
}
...
...
pkg/controller/garbagecollector/dump.go
View file @
2fb3ba71
...
@@ -252,7 +252,7 @@ type debugHTTPHandler struct {
...
@@ -252,7 +252,7 @@ type debugHTTPHandler struct {
func
(
h
*
debugHTTPHandler
)
ServeHTTP
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
func
(
h
*
debugHTTPHandler
)
ServeHTTP
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
if
req
.
URL
.
Path
!=
"/graph"
{
if
req
.
URL
.
Path
!=
"/graph"
{
w
.
WriteHeader
(
http
.
StatusNotFound
)
http
.
Error
(
w
,
""
,
http
.
StatusNotFound
)
return
return
}
}
...
@@ -270,8 +270,7 @@ func (h *debugHTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
...
@@ -270,8 +270,7 @@ func (h *debugHTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
data
,
err
:=
dot
.
Marshal
(
graph
,
"full"
,
""
,
" "
,
false
)
data
,
err
:=
dot
.
Marshal
(
graph
,
"full"
,
""
,
" "
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
w
.
Write
([]
byte
(
err
.
Error
()))
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusInternalServerError
)
w
.
WriteHeader
(
http
.
StatusInternalServerError
)
return
return
}
}
w
.
Write
(
data
)
w
.
Write
(
data
)
...
...
pkg/credentialprovider/gcp/metadata_test.go
View file @
2fb3ba71
...
@@ -70,7 +70,7 @@ func TestDockerKeyringFromGoogleDockerConfigMetadata(t *testing.T) {
...
@@ -70,7 +70,7 @@ func TestDockerKeyringFromGoogleDockerConfigMetadata(t *testing.T) {
w
.
Header
()
.
Set
(
"Content-Type"
,
"application/json"
)
w
.
Header
()
.
Set
(
"Content-Type"
,
"application/json"
)
fmt
.
Fprintln
(
w
,
sampleDockerConfig
)
fmt
.
Fprintln
(
w
,
sampleDockerConfig
)
}
else
{
}
else
{
w
.
WriteHeader
(
http
.
StatusNotFound
)
http
.
Error
(
w
,
""
,
http
.
StatusNotFound
)
}
}
}))
}))
defer
server
.
Close
()
defer
server
.
Close
()
...
@@ -148,7 +148,7 @@ func TestDockerKeyringFromGoogleDockerConfigMetadataUrl(t *testing.T) {
...
@@ -148,7 +148,7 @@ func TestDockerKeyringFromGoogleDockerConfigMetadataUrl(t *testing.T) {
w
.
Header
()
.
Set
(
"Content-Type"
,
"application/text"
)
w
.
Header
()
.
Set
(
"Content-Type"
,
"application/text"
)
fmt
.
Fprint
(
w
,
"http://foo.bar.com"
+
valueEndpoint
)
fmt
.
Fprint
(
w
,
"http://foo.bar.com"
+
valueEndpoint
)
}
else
{
}
else
{
w
.
WriteHeader
(
http
.
StatusNotFound
)
http
.
Error
(
w
,
""
,
http
.
StatusNotFound
)
}
}
}))
}))
defer
server
.
Close
()
defer
server
.
Close
()
...
@@ -232,7 +232,7 @@ func TestContainerRegistryBasics(t *testing.T) {
...
@@ -232,7 +232,7 @@ func TestContainerRegistryBasics(t *testing.T) {
w
.
WriteHeader
(
http
.
StatusOK
)
w
.
WriteHeader
(
http
.
StatusOK
)
fmt
.
Fprintln
(
w
,
"default/
\n
custom"
)
fmt
.
Fprintln
(
w
,
"default/
\n
custom"
)
}
else
{
}
else
{
w
.
WriteHeader
(
http
.
StatusNotFound
)
http
.
Error
(
w
,
""
,
http
.
StatusNotFound
)
}
}
}))
}))
defer
server
.
Close
()
defer
server
.
Close
()
...
@@ -291,7 +291,7 @@ func TestContainerRegistryNoServiceAccount(t *testing.T) {
...
@@ -291,7 +291,7 @@ func TestContainerRegistryNoServiceAccount(t *testing.T) {
}
}
fmt
.
Fprintln
(
w
,
string
(
bytes
))
fmt
.
Fprintln
(
w
,
string
(
bytes
))
}
else
{
}
else
{
w
.
WriteHeader
(
http
.
StatusNotFound
)
http
.
Error
(
w
,
""
,
http
.
StatusNotFound
)
}
}
}))
}))
defer
server
.
Close
()
defer
server
.
Close
()
...
@@ -335,7 +335,7 @@ func TestContainerRegistryNoStorageScope(t *testing.T) {
...
@@ -335,7 +335,7 @@ func TestContainerRegistryNoStorageScope(t *testing.T) {
w
.
WriteHeader
(
http
.
StatusOK
)
w
.
WriteHeader
(
http
.
StatusOK
)
fmt
.
Fprintln
(
w
,
"default/
\n
custom"
)
fmt
.
Fprintln
(
w
,
"default/
\n
custom"
)
}
else
{
}
else
{
w
.
WriteHeader
(
http
.
StatusNotFound
)
http
.
Error
(
w
,
""
,
http
.
StatusNotFound
)
}
}
}))
}))
defer
server
.
Close
()
defer
server
.
Close
()
...
@@ -380,7 +380,7 @@ func TestComputePlatformScopeSubstitutesStorageScope(t *testing.T) {
...
@@ -380,7 +380,7 @@ func TestComputePlatformScopeSubstitutesStorageScope(t *testing.T) {
w
.
Header
()
.
Set
(
"Content-Type"
,
"application/json"
)
w
.
Header
()
.
Set
(
"Content-Type"
,
"application/json"
)
fmt
.
Fprintln
(
w
,
"default/
\n
custom"
)
fmt
.
Fprintln
(
w
,
"default/
\n
custom"
)
}
else
{
}
else
{
w
.
WriteHeader
(
http
.
StatusNotFound
)
http
.
Error
(
w
,
""
,
http
.
StatusNotFound
)
}
}
}))
}))
defer
server
.
Close
()
defer
server
.
Close
()
...
@@ -410,7 +410,7 @@ func TestComputePlatformScopeSubstitutesStorageScope(t *testing.T) {
...
@@ -410,7 +410,7 @@ func TestComputePlatformScopeSubstitutesStorageScope(t *testing.T) {
func
TestAllProvidersNoMetadata
(
t
*
testing
.
T
)
{
func
TestAllProvidersNoMetadata
(
t
*
testing
.
T
)
{
server
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
server
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
WriteHeader
(
http
.
StatusNotFound
)
http
.
Error
(
w
,
""
,
http
.
StatusNotFound
)
}))
}))
defer
server
.
Close
()
defer
server
.
Close
()
...
...
pkg/kubectl/proxy/proxy_server.go
View file @
2fb3ba71
...
@@ -140,8 +140,7 @@ func (f *FilterServer) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
...
@@ -140,8 +140,7 @@ func (f *FilterServer) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
return
return
}
}
glog
.
V
(
3
)
.
Infof
(
"Filter rejecting %v %v %v"
,
req
.
Method
,
req
.
URL
.
Path
,
host
)
glog
.
V
(
3
)
.
Infof
(
"Filter rejecting %v %v %v"
,
req
.
Method
,
req
.
URL
.
Path
,
host
)
rw
.
WriteHeader
(
http
.
StatusForbidden
)
http
.
Error
(
rw
,
http
.
StatusText
(
http
.
StatusForbidden
),
http
.
StatusForbidden
)
rw
.
Write
([]
byte
(
"<h3>Unauthorized</h3>"
))
}
}
// Server is a http.Handler which proxies Kubernetes APIs to remote API server.
// Server is a http.Handler which proxies Kubernetes APIs to remote API server.
...
...
pkg/kubelet/server/remotecommand/httpstream.go
View file @
2fb3ba71
...
@@ -125,8 +125,7 @@ func createStreams(req *http.Request, w http.ResponseWriter, opts *Options, supp
...
@@ -125,8 +125,7 @@ func createStreams(req *http.Request, w http.ResponseWriter, opts *Options, supp
func
createHttpStreamStreams
(
req
*
http
.
Request
,
w
http
.
ResponseWriter
,
opts
*
Options
,
supportedStreamProtocols
[]
string
,
idleTimeout
,
streamCreationTimeout
time
.
Duration
)
(
*
context
,
bool
)
{
func
createHttpStreamStreams
(
req
*
http
.
Request
,
w
http
.
ResponseWriter
,
opts
*
Options
,
supportedStreamProtocols
[]
string
,
idleTimeout
,
streamCreationTimeout
time
.
Duration
)
(
*
context
,
bool
)
{
protocol
,
err
:=
httpstream
.
Handshake
(
req
,
w
,
supportedStreamProtocols
)
protocol
,
err
:=
httpstream
.
Handshake
(
req
,
w
,
supportedStreamProtocols
)
if
err
!=
nil
{
if
err
!=
nil
{
w
.
WriteHeader
(
http
.
StatusBadRequest
)
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusBadRequest
)
fmt
.
Fprint
(
w
,
err
.
Error
())
return
nil
,
false
return
nil
,
false
}
}
...
...
pkg/probe/http/http_test.go
View file @
2fb3ba71
...
@@ -57,7 +57,7 @@ func TestHTTPProbeChecker(t *testing.T) {
...
@@ -57,7 +57,7 @@ func TestHTTPProbeChecker(t *testing.T) {
if
r
.
URL
.
Path
==
"/"
{
if
r
.
URL
.
Path
==
"/"
{
http
.
Redirect
(
w
,
r
,
"/new"
,
s
)
http
.
Redirect
(
w
,
r
,
"/new"
,
s
)
}
else
if
bad
&&
r
.
URL
.
Path
==
"/new"
{
}
else
if
bad
&&
r
.
URL
.
Path
==
"/new"
{
w
.
WriteHeader
(
http
.
StatusInternalServerError
)
http
.
Error
(
w
,
""
,
http
.
StatusInternalServerError
)
}
}
}
}
}
}
...
...
staging/src/k8s.io/apimachinery/pkg/util/httpstream/httpstream.go
View file @
2fb3ba71
...
@@ -136,12 +136,12 @@ func Handshake(req *http.Request, w http.ResponseWriter, serverProtocols []strin
...
@@ -136,12 +136,12 @@ func Handshake(req *http.Request, w http.ResponseWriter, serverProtocols []strin
negotiatedProtocol
:=
negotiateProtocol
(
clientProtocols
,
serverProtocols
)
negotiatedProtocol
:=
negotiateProtocol
(
clientProtocols
,
serverProtocols
)
if
len
(
negotiatedProtocol
)
==
0
{
if
len
(
negotiatedProtocol
)
==
0
{
w
.
WriteHeader
(
http
.
StatusForbidden
)
for
i
:=
range
serverProtocols
{
for
i
:=
range
serverProtocols
{
w
.
Header
()
.
Add
(
HeaderAcceptedProtocolVersions
,
serverProtocols
[
i
])
w
.
Header
()
.
Add
(
HeaderAcceptedProtocolVersions
,
serverProtocols
[
i
])
}
}
fmt
.
Fprintf
(
w
,
"unable to upgrade: unable to negotiate protocol: client supports %v, server accepts %v"
,
clientProtocols
,
serverProtocols
)
err
:=
fmt
.
Errorf
(
"unable to upgrade: unable to negotiate protocol: client supports %v, server accepts %v"
,
clientProtocols
,
serverProtocols
)
return
""
,
fmt
.
Errorf
(
"unable to upgrade: unable to negotiate protocol: client supports %v, server supports %v"
,
clientProtocols
,
serverProtocols
)
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusForbidden
)
return
""
,
err
}
}
w
.
Header
()
.
Add
(
HeaderProtocolVersion
,
negotiatedProtocol
)
w
.
Header
()
.
Add
(
HeaderProtocolVersion
,
negotiatedProtocol
)
...
...
staging/src/k8s.io/apimachinery/pkg/util/httpstream/spdy/upgrade.go
View file @
2fb3ba71
...
@@ -74,15 +74,15 @@ func (u responseUpgrader) UpgradeResponse(w http.ResponseWriter, req *http.Reque
...
@@ -74,15 +74,15 @@ func (u responseUpgrader) UpgradeResponse(w http.ResponseWriter, req *http.Reque
connectionHeader
:=
strings
.
ToLower
(
req
.
Header
.
Get
(
httpstream
.
HeaderConnection
))
connectionHeader
:=
strings
.
ToLower
(
req
.
Header
.
Get
(
httpstream
.
HeaderConnection
))
upgradeHeader
:=
strings
.
ToLower
(
req
.
Header
.
Get
(
httpstream
.
HeaderUpgrade
))
upgradeHeader
:=
strings
.
ToLower
(
req
.
Header
.
Get
(
httpstream
.
HeaderUpgrade
))
if
!
strings
.
Contains
(
connectionHeader
,
strings
.
ToLower
(
httpstream
.
HeaderUpgrade
))
||
!
strings
.
Contains
(
upgradeHeader
,
strings
.
ToLower
(
HeaderSpdy31
))
{
if
!
strings
.
Contains
(
connectionHeader
,
strings
.
ToLower
(
httpstream
.
HeaderUpgrade
))
||
!
strings
.
Contains
(
upgradeHeader
,
strings
.
ToLower
(
HeaderSpdy31
))
{
w
.
WriteHeader
(
http
.
StatusBadRequest
)
errorMsg
:=
fmt
.
Sprintf
(
"unable to upgrade: missing upgrade headers in request: %#v"
,
req
.
Header
)
fmt
.
Fprintf
(
w
,
"unable to upgrade: missing upgrade headers in request: %#v"
,
req
.
Header
)
http
.
Error
(
w
,
errorMsg
,
http
.
StatusBadRequest
)
return
nil
return
nil
}
}
hijacker
,
ok
:=
w
.
(
http
.
Hijacker
)
hijacker
,
ok
:=
w
.
(
http
.
Hijacker
)
if
!
ok
{
if
!
ok
{
w
.
WriteHeader
(
http
.
StatusInternalServerError
)
errorMsg
:=
fmt
.
Sprintf
(
"unable to upgrade: unable to hijack response"
)
fmt
.
Fprintf
(
w
,
"unable to upgrade: unable to hijack response"
)
http
.
Error
(
w
,
errorMsg
,
http
.
StatusInternalServerError
)
return
nil
return
nil
}
}
...
...
staging/src/k8s.io/apiserver/pkg/endpoints/filters/authn_audit_test.go
View file @
2fb3ba71
...
@@ -33,7 +33,7 @@ func TestFailedAuthnAudit(t *testing.T) {
...
@@ -33,7 +33,7 @@ func TestFailedAuthnAudit(t *testing.T) {
policyChecker
:=
policy
.
FakeChecker
(
auditinternal
.
LevelRequestResponse
,
nil
)
policyChecker
:=
policy
.
FakeChecker
(
auditinternal
.
LevelRequestResponse
,
nil
)
handler
:=
WithFailedAuthenticationAudit
(
handler
:=
WithFailedAuthenticationAudit
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
WriteHeader
(
http
.
StatusUnauthorized
)
http
.
Error
(
w
,
""
,
http
.
StatusUnauthorized
)
}),
}),
sink
,
policyChecker
)
sink
,
policyChecker
)
req
,
_
:=
http
.
NewRequest
(
"GET"
,
"/api/v1/namespaces/default/pods"
,
nil
)
req
,
_
:=
http
.
NewRequest
(
"GET"
,
"/api/v1/namespaces/default/pods"
,
nil
)
...
@@ -65,7 +65,7 @@ func TestFailedMultipleAuthnAudit(t *testing.T) {
...
@@ -65,7 +65,7 @@ func TestFailedMultipleAuthnAudit(t *testing.T) {
policyChecker
:=
policy
.
FakeChecker
(
auditinternal
.
LevelRequestResponse
,
nil
)
policyChecker
:=
policy
.
FakeChecker
(
auditinternal
.
LevelRequestResponse
,
nil
)
handler
:=
WithFailedAuthenticationAudit
(
handler
:=
WithFailedAuthenticationAudit
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
WriteHeader
(
http
.
StatusUnauthorized
)
http
.
Error
(
w
,
""
,
http
.
StatusUnauthorized
)
}),
}),
sink
,
policyChecker
)
sink
,
policyChecker
)
req
,
_
:=
http
.
NewRequest
(
"GET"
,
"/api/v1/namespaces/default/pods"
,
nil
)
req
,
_
:=
http
.
NewRequest
(
"GET"
,
"/api/v1/namespaces/default/pods"
,
nil
)
...
@@ -98,7 +98,7 @@ func TestFailedAuthnAuditWithoutAuthorization(t *testing.T) {
...
@@ -98,7 +98,7 @@ func TestFailedAuthnAuditWithoutAuthorization(t *testing.T) {
policyChecker
:=
policy
.
FakeChecker
(
auditinternal
.
LevelRequestResponse
,
nil
)
policyChecker
:=
policy
.
FakeChecker
(
auditinternal
.
LevelRequestResponse
,
nil
)
handler
:=
WithFailedAuthenticationAudit
(
handler
:=
WithFailedAuthenticationAudit
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
WriteHeader
(
http
.
StatusUnauthorized
)
http
.
Error
(
w
,
""
,
http
.
StatusUnauthorized
)
}),
}),
sink
,
policyChecker
)
sink
,
policyChecker
)
req
,
_
:=
http
.
NewRequest
(
"GET"
,
"/api/v1/namespaces/default/pods"
,
nil
)
req
,
_
:=
http
.
NewRequest
(
"GET"
,
"/api/v1/namespaces/default/pods"
,
nil
)
...
@@ -129,7 +129,7 @@ func TestFailedAuthnAuditOmitted(t *testing.T) {
...
@@ -129,7 +129,7 @@ func TestFailedAuthnAuditOmitted(t *testing.T) {
policyChecker
:=
policy
.
FakeChecker
(
auditinternal
.
LevelRequestResponse
,
[]
auditinternal
.
Stage
{
auditinternal
.
StageResponseStarted
})
policyChecker
:=
policy
.
FakeChecker
(
auditinternal
.
LevelRequestResponse
,
[]
auditinternal
.
Stage
{
auditinternal
.
StageResponseStarted
})
handler
:=
WithFailedAuthenticationAudit
(
handler
:=
WithFailedAuthenticationAudit
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
WriteHeader
(
http
.
StatusUnauthorized
)
http
.
Error
(
w
,
""
,
http
.
StatusUnauthorized
)
}),
}),
sink
,
policyChecker
)
sink
,
policyChecker
)
req
,
_
:=
http
.
NewRequest
(
"GET"
,
"/api/v1/namespaces/default/pods"
,
nil
)
req
,
_
:=
http
.
NewRequest
(
"GET"
,
"/api/v1/namespaces/default/pods"
,
nil
)
...
...
staging/src/k8s.io/apiserver/pkg/server/filters/maxinflight.go
View file @
2fb3ba71
...
@@ -45,8 +45,8 @@ const (
...
@@ -45,8 +45,8 @@ const (
var
nonMutatingRequestVerbs
=
sets
.
NewString
(
"get"
,
"list"
,
"watch"
)
var
nonMutatingRequestVerbs
=
sets
.
NewString
(
"get"
,
"list"
,
"watch"
)
func
handleError
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
err
error
)
{
func
handleError
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
err
error
)
{
w
.
WriteHeader
(
http
.
StatusInternalServerError
)
errorMsg
:=
fmt
.
Sprintf
(
"Internal Server Error: %#v"
,
r
.
RequestURI
)
fmt
.
Fprintf
(
w
,
"Internal Server Error: %#v"
,
r
.
RequestURI
)
http
.
Error
(
w
,
errorMsg
,
http
.
StatusInternalServerError
)
glog
.
Errorf
(
err
.
Error
())
glog
.
Errorf
(
err
.
Error
())
}
}
...
...
staging/src/k8s.io/apiserver/pkg/storage/etcd/util/etcd_util_test.go
View file @
2fb3ba71
...
@@ -60,7 +60,7 @@ func TestGetEtcdVersion_ValidVersion(t *testing.T) {
...
@@ -60,7 +60,7 @@ func TestGetEtcdVersion_ValidVersion(t *testing.T) {
func
TestGetEtcdVersion_ErrorStatus
(
t
*
testing
.
T
)
{
func
TestGetEtcdVersion_ErrorStatus
(
t
*
testing
.
T
)
{
testServer
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testServer
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
WriteHeader
(
http
.
StatusServiceUnavailable
)
http
.
Error
(
w
,
""
,
http
.
StatusServiceUnavailable
)
}))
}))
defer
testServer
.
Close
()
defer
testServer
.
Close
()
...
...
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