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
dfbfcfec
Unverified
Commit
dfbfcfec
authored
Jun 23, 2016
by
Will Tran
Committed by
Spencer Gibb
Jun 23, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Without explicit client config of IsSecure, lookup from registration
instead of defaulting to false. Fixes gh-1126
parent
7ac81f8f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
2 deletions
+37
-2
RibbonLoadBalancerClient.java
...mework/cloud/netflix/ribbon/RibbonLoadBalancerClient.java
+4
-1
RibbonLoadBalancerClientTests.java
...k/cloud/netflix/ribbon/RibbonLoadBalancerClientTests.java
+33
-1
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonLoadBalancerClient.java
View file @
dfbfcfec
...
@@ -114,7 +114,10 @@ public class RibbonLoadBalancerClient implements LoadBalancerClient {
...
@@ -114,7 +114,10 @@ public class RibbonLoadBalancerClient implements LoadBalancerClient {
private
boolean
isSecure
(
Server
server
,
String
serviceId
)
{
private
boolean
isSecure
(
Server
server
,
String
serviceId
)
{
IClientConfig
config
=
this
.
clientFactory
.
getClientConfig
(
serviceId
);
IClientConfig
config
=
this
.
clientFactory
.
getClientConfig
(
serviceId
);
if
(
config
!=
null
)
{
if
(
config
!=
null
)
{
return
config
.
get
(
CommonClientConfigKey
.
IsSecure
,
false
);
Boolean
isSecure
=
config
.
get
(
CommonClientConfigKey
.
IsSecure
);
if
(
isSecure
!=
null
)
{
return
isSecure
;
}
}
}
return
serverIntrospector
(
serviceId
).
isSecure
(
server
);
return
serverIntrospector
(
serviceId
).
isSecure
(
server
);
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/ribbon/RibbonLoadBalancerClientTests.java
View file @
dfbfcfec
...
@@ -112,7 +112,7 @@ public class RibbonLoadBalancerClientTests {
...
@@ -112,7 +112,7 @@ public class RibbonLoadBalancerClientTests {
public
void
testReconstructUriWithSecureClientConfig
()
{
public
void
testReconstructUriWithSecureClientConfig
()
{
RibbonServer
server
=
getRibbonServer
();
RibbonServer
server
=
getRibbonServer
();
IClientConfig
config
=
mock
(
IClientConfig
.
class
);
IClientConfig
config
=
mock
(
IClientConfig
.
class
);
when
(
config
.
get
(
CommonClientConfigKey
.
IsSecure
,
false
)).
thenReturn
(
true
);
when
(
config
.
get
(
CommonClientConfigKey
.
IsSecure
)).
thenReturn
(
true
);
when
(
clientFactory
.
getClientConfig
(
server
.
getServiceId
())).
thenReturn
(
config
);
when
(
clientFactory
.
getClientConfig
(
server
.
getServiceId
())).
thenReturn
(
config
);
RibbonLoadBalancerClient
client
=
getRibbonLoadBalancerClient
(
server
);
RibbonLoadBalancerClient
client
=
getRibbonLoadBalancerClient
(
server
);
...
@@ -125,6 +125,33 @@ public class RibbonLoadBalancerClientTests {
...
@@ -125,6 +125,33 @@ public class RibbonLoadBalancerClientTests {
}
}
@Test
@Test
@SneakyThrows
public
void
testReconstructSecureUriWithoutScheme
()
{
testReconstructSchemelessUriWithoutClientConfig
(
getSecureRibbonServer
(),
"https"
);
}
@Test
@SneakyThrows
public
void
testReconstructUnsecureSchemelessUri
()
{
testReconstructSchemelessUriWithoutClientConfig
(
getRibbonServer
(),
"http"
);
}
@SneakyThrows
public
void
testReconstructSchemelessUriWithoutClientConfig
(
RibbonServer
server
,
String
expectedScheme
)
{
IClientConfig
config
=
mock
(
IClientConfig
.
class
);
when
(
config
.
get
(
CommonClientConfigKey
.
IsSecure
)).
thenReturn
(
null
);
when
(
clientFactory
.
getClientConfig
(
server
.
getServiceId
())).
thenReturn
(
config
);
RibbonLoadBalancerClient
client
=
getRibbonLoadBalancerClient
(
server
);
ServiceInstance
serviceInstance
=
client
.
choose
(
server
.
getServiceId
());
URI
uri
=
client
.
reconstructURI
(
serviceInstance
,
new
URI
(
"//"
+
server
.
getServiceId
()));
assertEquals
(
server
.
getHost
(),
uri
.
getHost
());
assertEquals
(
server
.
getPort
(),
uri
.
getPort
());
assertEquals
(
expectedScheme
,
uri
.
getScheme
());
}
@Test
public
void
testChoose
()
{
public
void
testChoose
()
{
RibbonServer
server
=
getRibbonServer
();
RibbonServer
server
=
getRibbonServer
();
RibbonLoadBalancerClient
client
=
getRibbonLoadBalancerClient
(
server
);
RibbonLoadBalancerClient
client
=
getRibbonLoadBalancerClient
(
server
);
...
@@ -206,6 +233,11 @@ public class RibbonLoadBalancerClientTests {
...
@@ -206,6 +233,11 @@ public class RibbonLoadBalancerClientTests {
Collections
.
singletonMap
(
"mykey"
,
"myvalue"
));
Collections
.
singletonMap
(
"mykey"
,
"myvalue"
));
}
}
protected
RibbonServer
getSecureRibbonServer
()
{
return
new
RibbonServer
(
"testService"
,
new
Server
(
"myhost"
,
8443
),
false
,
Collections
.
singletonMap
(
"mykey"
,
"myvalue"
));
}
protected
void
verifyServerStats
()
{
protected
void
verifyServerStats
()
{
verify
(
this
.
serverStats
).
incrementActiveRequestsCount
();
verify
(
this
.
serverStats
).
incrementActiveRequestsCount
();
verify
(
this
.
serverStats
).
decrementActiveRequestsCount
();
verify
(
this
.
serverStats
).
decrementActiveRequestsCount
();
...
...
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