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
771343e3
Commit
771343e3
authored
May 10, 2017
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update OAuth2 sample following breaking API change in Spring Security
See gh-8714 and
9480e09c
parent
918a11ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
SampleSecureOAuth2ApplicationTests.java
...ple/secure/oauth2/SampleSecureOAuth2ApplicationTests.java
+5
-3
No files found.
spring-boot-samples/spring-boot-sample-secure-oauth2/src/test/java/sample/secure/oauth2/SampleSecureOAuth2ApplicationTests.java
View file @
771343e3
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
package
sample
.
secure
.
oauth2
;
package
sample
.
secure
.
oauth2
;
import
java.util.Base64
;
import
java.util.Map
;
import
java.util.Map
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
...
@@ -29,7 +30,6 @@ import org.springframework.boot.test.context.SpringBootTest;
...
@@ -29,7 +30,6 @@ import org.springframework.boot.test.context.SpringBootTest;
import
org.springframework.boot.test.context.SpringBootTest.WebEnvironment
;
import
org.springframework.boot.test.context.SpringBootTest.WebEnvironment
;
import
org.springframework.hateoas.MediaTypes
;
import
org.springframework.hateoas.MediaTypes
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.crypto.codec.Base64
;
import
org.springframework.security.web.FilterChainProxy
;
import
org.springframework.security.web.FilterChainProxy
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.MockMvc
;
...
@@ -85,7 +85,8 @@ public class SampleSecureOAuth2ApplicationTests {
...
@@ -85,7 +85,8 @@ public class SampleSecureOAuth2ApplicationTests {
@Test
@Test
@Ignore
@Ignore
public
void
accessingRootUriPossibleWithUserAccount
()
throws
Exception
{
public
void
accessingRootUriPossibleWithUserAccount
()
throws
Exception
{
String
header
=
"Basic "
+
new
String
(
Base64
.
encode
(
"greg:turnquist"
.
getBytes
()));
String
header
=
"Basic "
+
new
String
(
Base64
.
getEncoder
().
encode
(
"greg:turnquist"
.
getBytes
()));
this
.
mvc
.
perform
(
this
.
mvc
.
perform
(
get
(
"/"
).
accept
(
MediaTypes
.
HAL_JSON
).
header
(
"Authorization"
,
header
))
get
(
"/"
).
accept
(
MediaTypes
.
HAL_JSON
).
header
(
"Authorization"
,
header
))
.
andExpect
(
.
andExpect
(
...
@@ -95,7 +96,8 @@ public class SampleSecureOAuth2ApplicationTests {
...
@@ -95,7 +96,8 @@ public class SampleSecureOAuth2ApplicationTests {
@Test
@Test
public
void
useAppSecretsPlusUserAccountToGetBearerToken
()
throws
Exception
{
public
void
useAppSecretsPlusUserAccountToGetBearerToken
()
throws
Exception
{
String
header
=
"Basic "
+
new
String
(
Base64
.
encode
(
"foo:bar"
.
getBytes
()));
String
header
=
"Basic "
+
new
String
(
Base64
.
getEncoder
().
encode
(
"foo:bar"
.
getBytes
()));
MvcResult
result
=
this
.
mvc
MvcResult
result
=
this
.
mvc
.
perform
(
post
(
"/oauth/token"
).
header
(
"Authorization"
,
header
)
.
perform
(
post
(
"/oauth/token"
).
header
(
"Authorization"
,
header
)
.
param
(
"grant_type"
,
"password"
).
param
(
"scope"
,
"read"
)
.
param
(
"grant_type"
,
"password"
).
param
(
"scope"
,
"read"
)
...
...
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