Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
5051916f
Commit
5051916f
authored
Jul 08, 2019
by
dreis2211
Committed by
Andy Wilkinson
Jul 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish Base64 usages
See gh-17459
parent
a40bc64f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
20 deletions
+21
-20
SampleActuatorLog4J2ApplicationTests.java
...actuator/log4j2/SampleActuatorLog4J2ApplicationTests.java
+3
-4
ManagementPortSampleSecureWebFluxTests.java
...ecure/webflux/ManagementPortSampleSecureWebFluxTests.java
+3
-4
SampleSecureWebFluxApplicationTests.java
...t/secure/webflux/SampleSecureWebFluxApplicationTests.java
+4
-5
SampleSecureWebFluxCustomSecurityTests.java
...ecure/webflux/SampleSecureWebFluxCustomSecurityTests.java
+6
-6
SampleSessionApplicationTests.java
...java/smoketest/session/SampleSessionApplicationTests.java
+5
-1
No files found.
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-log4j2/src/test/java/smoketest/actuator/log4j2/SampleActuatorLog4J2ApplicationTests.java
View file @
5051916f
...
...
@@ -31,7 +31,6 @@ import org.springframework.boot.test.system.OutputCaptureExtension;
import
org.springframework.test.web.servlet.MockMvc
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
get
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
content
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
...
...
@@ -61,12 +60,12 @@ class SampleActuatorLog4J2ApplicationTests {
@Test
void
validateLoggersEndpoint
()
throws
Exception
{
this
.
mvc
.
perform
(
get
(
"/actuator/loggers/org.apache.coyote.http11.Http11NioProtocol"
).
header
(
"Authorization"
,
"Basic "
+
getBasicAuth
())).
andExpect
(
status
().
isOk
()).
andExpect
(
content
().
string
(
equalTo
(
"{\"configuredLevel\":\"WARN\","
+
"\"effectiveLevel\":\"WARN\"}"
)
));
getBasicAuth
())).
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
string
(
"{\"configuredLevel\":\"WARN\","
+
"\"effectiveLevel\":\"WARN\"}"
));
}
private
String
getBasicAuth
()
{
return
new
String
(
Base64
.
getEncoder
().
encode
((
"user:password"
).
getBytes
()
));
return
"Basic "
+
Base64
.
getEncoder
().
encodeToString
(
"user:password"
.
getBytes
(
));
}
}
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-secure-webflux/src/test/java/smoketest/secure/webflux/ManagementPortSampleSecureWebFluxTests.java
View file @
5051916f
...
...
@@ -56,9 +56,8 @@ class ManagementPortSampleSecureWebFluxTests {
@Test
void
testHome
()
{
this
.
webClient
.
get
().
uri
(
"http://localhost:"
+
this
.
port
,
String
.
class
)
.
header
(
"Authorization"
,
"basic "
+
getBasicAuth
()).
exchange
().
expectStatus
().
isOk
()
.
expectBody
(
String
.
class
).
isEqualTo
(
"Hello user"
);
this
.
webClient
.
get
().
uri
(
"http://localhost:"
+
this
.
port
,
String
.
class
).
header
(
"Authorization"
,
getBasicAuth
())
.
exchange
().
expectStatus
().
isOk
().
expectBody
(
String
.
class
).
isEqualTo
(
"Hello user"
);
}
@Test
...
...
@@ -84,7 +83,7 @@ class ManagementPortSampleSecureWebFluxTests {
}
private
String
getBasicAuth
()
{
return
new
String
(
Base64
.
getEncoder
().
encode
((
"user:password"
).
getBytes
()
));
return
"Basic "
+
Base64
.
getEncoder
().
encodeToString
(
"user:password"
.
getBytes
(
));
}
@Configuration
(
proxyBeanMethods
=
false
)
...
...
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-secure-webflux/src/test/java/smoketest/secure/webflux/SampleSecureWebFluxApplicationTests.java
View file @
5051916f
...
...
@@ -63,20 +63,19 @@ class SampleSecureWebFluxApplicationTests {
@Test
void
userDefinedMappingsAccessibleOnLogin
()
{
this
.
webClient
.
get
().
uri
(
"/"
).
accept
(
MediaType
.
APPLICATION_JSON
)
.
header
(
"Authorization"
,
"basic "
+
getBasicAuth
()).
exchange
().
expectBody
(
String
.
class
)
.
isEqualTo
(
"Hello user"
);
this
.
webClient
.
get
().
uri
(
"/"
).
accept
(
MediaType
.
APPLICATION_JSON
).
header
(
"Authorization"
,
getBasicAuth
())
.
exchange
().
expectBody
(
String
.
class
).
isEqualTo
(
"Hello user"
);
}
@Test
void
actuatorsAccessibleOnLogin
()
{
this
.
webClient
.
get
().
uri
(
"/actuator/health"
).
accept
(
MediaType
.
APPLICATION_JSON
)
.
header
(
"Authorization"
,
"basic "
+
getBasicAuth
()).
exchange
().
expectBody
(
String
.
class
)
.
header
(
"Authorization"
,
getBasicAuth
()).
exchange
().
expectBody
(
String
.
class
)
.
isEqualTo
(
"{\"status\":\"UP\"}"
);
}
private
String
getBasicAuth
()
{
return
new
String
(
Base64
.
getEncoder
().
encode
((
"user:password"
).
getBytes
()
));
return
"Basic "
+
Base64
.
getEncoder
().
encodeToString
(
"user:password"
.
getBytes
(
));
}
}
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-secure-webflux/src/test/java/smoketest/secure/webflux/SampleSecureWebFluxCustomSecurityTests.java
View file @
5051916f
...
...
@@ -63,19 +63,19 @@ class SampleSecureWebFluxCustomSecurityTests {
@Test
void
actuatorsSecuredByRole
()
{
this
.
webClient
.
get
().
uri
(
"/actuator/env"
).
accept
(
MediaType
.
APPLICATION_JSON
)
.
header
(
"Authorization"
,
"basic "
+
getBasicAuth
()).
exchange
().
expectStatus
().
isForbidden
();
.
header
(
"Authorization"
,
getBasicAuth
()).
exchange
().
expectStatus
().
isForbidden
();
}
@Test
void
actuatorsAccessibleOnCorrectLogin
()
{
this
.
webClient
.
get
().
uri
(
"/actuator/env"
).
accept
(
MediaType
.
APPLICATION_JSON
)
.
header
(
"Authorization"
,
"basic "
+
getBasicAuthForAdmin
()).
exchange
().
expectStatus
().
isOk
();
.
header
(
"Authorization"
,
getBasicAuthForAdmin
()).
exchange
().
expectStatus
().
isOk
();
}
@Test
void
actuatorExcludedFromEndpointRequestMatcher
()
{
this
.
webClient
.
get
().
uri
(
"/actuator/mappings"
).
accept
(
MediaType
.
APPLICATION_JSON
)
.
header
(
"Authorization"
,
"basic "
+
getBasicAuth
()).
exchange
().
expectStatus
().
isOk
();
.
header
(
"Authorization"
,
getBasicAuth
()).
exchange
().
expectStatus
().
isOk
();
}
@Test
...
...
@@ -89,15 +89,15 @@ class SampleSecureWebFluxCustomSecurityTests {
this
.
webClient
.
get
().
uri
(
"/actuator"
).
accept
(
MediaType
.
APPLICATION_JSON
).
exchange
().
expectStatus
()
.
isUnauthorized
();
this
.
webClient
.
get
().
uri
(
"/actuator"
).
accept
(
MediaType
.
APPLICATION_JSON
)
.
header
(
"Authorization"
,
"basic "
+
getBasicAuthForAdmin
()).
exchange
().
expectStatus
().
isOk
();
.
header
(
"Authorization"
,
getBasicAuthForAdmin
()).
exchange
().
expectStatus
().
isOk
();
}
private
String
getBasicAuth
()
{
return
new
String
(
Base64
.
getEncoder
().
encode
((
"user:password"
).
getBytes
()
));
return
"Basic "
+
Base64
.
getEncoder
().
encodeToString
(
"user:password"
.
getBytes
(
));
}
private
String
getBasicAuthForAdmin
()
{
return
new
String
(
Base64
.
getEncoder
().
encode
((
"admin:admin"
).
getBytes
()
));
return
"Basic "
+
Base64
.
getEncoder
().
encodeToString
(
"admin:admin"
.
getBytes
(
));
}
@Configuration
(
proxyBeanMethods
=
false
)
...
...
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session/src/test/java/smoketest/session/SampleSessionApplicationTests.java
View file @
5051916f
...
...
@@ -65,7 +65,7 @@ class SampleSessionApplicationTests {
private
ResponseEntity
<
String
>
firstRequest
(
RestTemplate
restTemplate
,
URI
uri
)
{
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
set
(
"Authorization"
,
"Basic "
+
Base64
.
getEncoder
().
encodeToString
(
"user:password"
.
getBytes
()
));
headers
.
set
(
"Authorization"
,
getBasicAuth
(
));
RequestEntity
<
Object
>
request
=
new
RequestEntity
<>(
headers
,
HttpMethod
.
GET
,
uri
);
return
restTemplate
.
exchange
(
request
,
String
.
class
);
}
...
...
@@ -77,4 +77,8 @@ class SampleSessionApplicationTests {
return
restTemplate
.
exchange
(
request
,
String
.
class
);
}
private
String
getBasicAuth
()
{
return
"Basic "
+
Base64
.
getEncoder
().
encodeToString
(
"user:password"
.
getBytes
());
}
}
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