Skip to content

Commit ceffd10

Browse files
committed
Merge branch '523-geode-cluster-operator'
2 parents 8d94765 + 0fc33ec commit ceffd10

File tree

2 files changed

+44
-6
lines changed

2 files changed

+44
-6
lines changed

lib/java_buildpack/container/tomcat/tomcat_geode_store.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ def compile
3838
def release
3939
return unless supports?
4040
credentials = @application.services.find_service(FILTER, KEY_LOCATORS, KEY_USERS)['credentials']
41-
user = credentials[KEY_USERS].find { |u| u['username'] == 'cluster_operator' }
41+
user = credentials[KEY_USERS].find { |u| cluster_operator?(u) }
4242

43-
@droplet.java_opts.add_system_property 'gemfire.security-username', 'cluster_operator'
43+
@droplet.java_opts.add_system_property 'gemfire.security-username', user['username']
4444
@droplet.java_opts.add_system_property 'gemfire.security-password', user['password']
4545
@droplet.java_opts.add_system_property 'gemfire.security-client-auth-init',
4646
'io.pivotal.cloudcache.ClientAuthInitialize.create'
@@ -78,6 +78,10 @@ def supports?
7878
:CACHE_CLIENT_LISTENER_CLASS_NAME, :SCHEMA_URL, :SCHEMA_INSTANCE_URL, :SCHEMA_LOCATION,
7979
:LOCATOR_REGEXP, :FUNCTION_SERVICE_CLASS_NAMES
8080

81+
def cluster_operator?(user)
82+
user['username'] == 'cluster_operator' || user['roles'] && (user['roles'].include? 'cluster_operator')
83+
end
84+
8185
def add_client_cache(document)
8286
client_cache = document.add_element 'client-cache',
8387
'xmlns' => SCHEMA_URL,

spec/java_buildpack/container/tomcat/tomcat_geode_store_spec.rb

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@
4141
'locators' => ['some-locator[some-port]', 'some-other-locator[some-other-port]'],
4242
'users' =>
4343
[
44-
{ 'password' => 'fake-password',
45-
'username' => 'cluster_operator' }
44+
{
45+
'password' => 'some-password',
46+
'username' => 'some-username',
47+
'roles' => ['cluster_operator']
48+
}
4649
]
4750
}
4851
)
@@ -102,9 +105,40 @@
102105
expect(java_opts).to include(
103106
'-Dgemfire.security-client-auth-init=io.pivotal.cloudcache.ClientAuthInitialize.create'
104107
)
105-
expect(java_opts).to include('-Dgemfire.security-username=cluster_operator')
106-
expect(java_opts).to include('-Dgemfire.security-password=fake-password')
108+
expect(java_opts).to include('-Dgemfire.security-username=some-username')
109+
expect(java_opts).to include('-Dgemfire.security-password=some-password')
107110
end
111+
end
108112

113+
context 'when there is session replication service and service credentials do not include roles' do
114+
before do
115+
allow(services).to receive(:one_service?).with(/session-replication/, 'locators', 'users')
116+
.and_return(true)
117+
allow(services).to receive(:find_service).and_return(
118+
'credentials' => {
119+
'locators' => ['some-locator[some-port]', 'some-other-locator[some-other-port]'],
120+
'users' =>
121+
[
122+
{
123+
'password' => 'some-password',
124+
'username' => 'cluster_operator'
125+
}
126+
]
127+
}
128+
)
129+
end
130+
131+
it 'assumes usernames represent roles and passes security properties to the release',
132+
app_fixture: 'container_tomcat_geode_store',
133+
cache_fixture: 'stub-geode-store.tar' do
134+
135+
component.release
136+
137+
expect(java_opts).to include(
138+
'-Dgemfire.security-client-auth-init=io.pivotal.cloudcache.ClientAuthInitialize.create'
139+
)
140+
expect(java_opts).to include('-Dgemfire.security-username=cluster_operator')
141+
expect(java_opts).to include('-Dgemfire.security-password=some-password')
142+
end
109143
end
110144
end

0 commit comments

Comments
 (0)