Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
Project
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
spring-cloud-netflix
Commits
4255c557
Unverified
Commit
4255c557
authored
Aug 10, 2016
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1244 from cah-oster/master
* pull1244: Fixed double-encoding issue in RibbonClientConfiguration
parents
b09b0bcd
5e698278
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
8 deletions
+64
-8
RibbonClientConfiguration.java
...ework/cloud/netflix/ribbon/RibbonClientConfiguration.java
+1
-1
RibbonClientConfigurationTests.java
.../cloud/netflix/ribbon/RibbonClientConfigurationTests.java
+63
-7
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonClientConfiguration.java
View file @
4255c557
...
...
@@ -200,7 +200,7 @@ public class RibbonClientConfiguration {
public
URI
reconstructURIWithServer
(
Server
server
,
URI
original
)
{
String
scheme
=
original
.
getScheme
();
if
(!
"https"
.
equals
(
scheme
)
&&
this
.
serverIntrospector
.
isSecure
(
server
))
{
original
=
UriComponentsBuilder
.
fromUri
(
original
).
scheme
(
"https"
).
build
()
original
=
UriComponentsBuilder
.
fromUri
(
original
).
scheme
(
"https"
).
build
(
true
)
.
toUri
();
}
return
super
.
reconstructURIWithServer
(
server
,
original
);
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/ribbon/RibbonClientConfigurationTests.java
View file @
4255c557
...
...
@@ -16,26 +16,46 @@
package
org
.
springframework
.
cloud
.
netflix
.
ribbon
;
import
static
org
.
hamcrest
.
Matchers
.*;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
java.net.URI
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.mockito.Mock
;
import
org.mockito.MockitoAnnotations
;
import
org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration.OverrideRestClient
;
import
com.netflix.client.config.CommonClientConfigKey
;
import
com.netflix.client.config.DefaultClientConfigImpl
;
import
com.netflix.client.config.IClientConfig
;
import
org.junit.Test
;
import
com.netflix.loadbalancer.Server
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
mockito
.
Mockito
.
when
;
/**
* @author Spencer Gibb
*/
public
class
RibbonClientConfigurationTests
{
@Test
public
void
restClientInitCalledOnce
()
{
CountingConfig
config
=
new
CountingConfig
();
private
CountingConfig
config
;
@Mock
private
ServerIntrospector
inspector
;
@Before
public
void
setup
()
{
MockitoAnnotations
.
initMocks
(
this
);
config
=
new
CountingConfig
();
config
.
setProperty
(
CommonClientConfigKey
.
ConnectTimeout
,
"1"
);
config
.
setProperty
(
CommonClientConfigKey
.
ReadTimeout
,
"1"
);
config
.
setProperty
(
CommonClientConfigKey
.
MaxHttpConnectionsPerHost
,
"1"
);
config
.
setClientName
(
"testClient"
);
}
@Test
public
void
restClientInitCalledOnce
()
{
new
TestRestClient
(
config
);
assertThat
(
config
.
count
,
is
(
equalTo
(
1
)));
}
...
...
@@ -44,7 +64,43 @@ public class RibbonClientConfigurationTests {
int
count
=
0
;
}
static
class
TestRestClient
extends
RibbonClientConfiguration
.
OverrideRestClient
{
@Test
public
void
testSecureUriFromClientConfig
()
throws
Exception
{
Server
server
=
new
Server
(
"foo"
,
7777
);
when
(
inspector
.
isSecure
(
server
)).
thenReturn
(
true
);
OverrideRestClient
overrideRestClient
=
new
OverrideRestClient
(
this
.
config
,
inspector
);
URI
uri
=
overrideRestClient
.
reconstructURIWithServer
(
server
,
new
URI
(
"http://foo/"
));
assertThat
(
uri
,
is
(
new
URI
(
"https://foo:7777/"
)));
}
@Test
public
void
testInSecureUriFromClientConfig
()
throws
Exception
{
Server
server
=
new
Server
(
"foo"
,
7777
);
when
(
inspector
.
isSecure
(
server
)).
thenReturn
(
false
);
OverrideRestClient
overrideRestClient
=
new
OverrideRestClient
(
this
.
config
,
inspector
);
URI
uri
=
overrideRestClient
.
reconstructURIWithServer
(
server
,
new
URI
(
"http://foo/"
));
assertThat
(
uri
,
is
(
new
URI
(
"http://foo:7777/"
)));
}
@Test
public
void
testNotDoubleEncodedWhenSecure
()
throws
Exception
{
Server
server
=
new
Server
(
"foo"
,
7777
);
when
(
inspector
.
isSecure
(
server
)).
thenReturn
(
true
);
OverrideRestClient
overrideRestClient
=
new
OverrideRestClient
(
this
.
config
,
inspector
);
URI
uri
=
overrideRestClient
.
reconstructURIWithServer
(
server
,
new
URI
(
"http://foo/%20bar"
));
assertThat
(
uri
,
is
(
new
URI
(
"https://foo:7777/%20bar"
)));
}
static
class
TestRestClient
extends
OverrideRestClient
{
private
TestRestClient
(
IClientConfig
ncc
)
{
super
(
ncc
,
new
DefaultServerIntrospector
());
...
...
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