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
99beb9d0
Unverified
Commit
99beb9d0
authored
Jun 23, 2016
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1127 from william-tran/schemeless-uri
* schemeless-uri: Without explicit client config of IsSecure, lookup from registration
parents
34dff916
4cada7c8
Hide 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 @
99beb9d0
...
...
@@ -114,7 +114,10 @@ public class RibbonLoadBalancerClient implements LoadBalancerClient {
private
boolean
isSecure
(
Server
server
,
String
serviceId
)
{
IClientConfig
config
=
this
.
clientFactory
.
getClientConfig
(
serviceId
);
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
);
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/ribbon/RibbonLoadBalancerClientTests.java
View file @
99beb9d0
...
...
@@ -112,7 +112,7 @@ public class RibbonLoadBalancerClientTests {
public
void
testReconstructUriWithSecureClientConfig
()
{
RibbonServer
server
=
getRibbonServer
();
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
);
RibbonLoadBalancerClient
client
=
getRibbonLoadBalancerClient
(
server
);
...
...
@@ -125,6 +125,33 @@ public class RibbonLoadBalancerClientTests {
}
@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
()
{
RibbonServer
server
=
getRibbonServer
();
RibbonLoadBalancerClient
client
=
getRibbonLoadBalancerClient
(
server
);
...
...
@@ -206,6 +233,11 @@ public class RibbonLoadBalancerClientTests {
Collections
.
singletonMap
(
"mykey"
,
"myvalue"
));
}
protected
RibbonServer
getSecureRibbonServer
()
{
return
new
RibbonServer
(
"testService"
,
new
Server
(
"myhost"
,
8443
),
false
,
Collections
.
singletonMap
(
"mykey"
,
"myvalue"
));
}
protected
void
verifyServerStats
()
{
verify
(
this
.
serverStats
).
incrementActiveRequestsCount
();
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