Skip to content
Permalink
Browse files
Various changes to get Rhythm working in integration test.
  • Loading branch information
mifosio-04-04-2018 committed May 22, 2017
1 parent d193cd1 commit 49ade43a5fc2de58444524054943f87a3267a048
Showing 6 changed files with 116 additions and 10 deletions.
@@ -23,7 +23,6 @@
import io.mifos.core.test.fixture.mariadb.MariaDBInitializer;
import io.mifos.core.test.listener.EnableEventRecording;
import io.mifos.core.test.listener.EventRecorder;
import io.mifos.identity.api.v1.client.IdentityManager;
import io.mifos.rhythm.api.v1.client.RhythmManager;
import io.mifos.rhythm.api.v1.domain.Beat;
import io.mifos.rhythm.api.v1.events.BeatEvent;
@@ -112,9 +111,6 @@ public Logger logger() {
@MockBean
BeatPublisherService beatPublisherServiceSpy;

@MockBean
IdentityManager identityManager;

@Before
public void prepTest() {
userContext = tenantApplicationSecurityEnvironment.createAutoUserContext(TEST_USER);
@@ -0,0 +1,32 @@
/*
* Copyright 2017 The Mifos Initiative.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.mifos.rhythm.service;

import org.springframework.boot.SpringApplication;

/**
* @author Myrle Krantz
*/
public class RhythmApplication {

public RhythmApplication() {
super();
}

public static void main(String[] args) {
SpringApplication.run(RhythmConfiguration.class, args);
}
}
@@ -26,6 +26,7 @@
import io.mifos.permittedfeignclient.service.ApplicationAccessTokenService;
import io.mifos.rhythm.service.config.RhythmProperties;
import io.mifos.rhythm.service.internal.identity.ApplicationPermissionRequestCreator;
import io.mifos.rhythm.spi.v1.PermittableGroupIds;
import io.mifos.rhythm.spi.v1.client.BeatListener;
import io.mifos.rhythm.spi.v1.domain.BeatPublish;
import org.slf4j.Logger;
@@ -88,7 +89,7 @@ public BeatPublisherService(
public Optional<String> requestPermissionForBeats(final String tenantIdentifier, final String applicationName) {
try (final AutoTenantContext ignored = new AutoTenantContext(tenantIdentifier)) {
try (final AutoUserContext ignored2 = new AutoUserContext(properties.getUser(), "")) {
final String consumerPermittableGroupIdentifier = getPermittableGroupIdentifier(applicationName);
final String consumerPermittableGroupIdentifier = PermittableGroupIds.forApplication(applicationName);
final Permission publishBeatPermission = new Permission();
publishBeatPermission.setAllowedOperations(Collections.singleton(AllowedOperation.CHANGE));
publishBeatPermission.setPermittableEndpointGroupIdentifier(consumerPermittableGroupIdentifier);
@@ -105,10 +106,6 @@ public Optional<String> requestPermissionForBeats(final String tenantIdentifier,
}
}

private static String getPermittableGroupIdentifier(final String beatConsumingApplicationName) {
return beatConsumingApplicationName.replace("-", "__") + "__khepri";
}

/**
* Authenticate with identity and publish the beat to the application. This function performs all the scheduled
* interprocess communication in rhythm, and therefore most be mocked in unit and component tests.
@@ -0,0 +1,55 @@
<!--
Copyright 2017 The Mifos Initiative.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<configuration>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs/rhythm.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>rhythm.%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>7</maxHistory>
<totalSizeCap>2GB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<logger name="com" level="INFO">
<appender-ref ref="STDOUT" />
</logger>

<logger name="org" level="INFO">
<appender-ref ref="STDOUT" />
</logger>

<logger name="io" level="INFO">
<appender-ref ref="STDOUT" />
</logger>

<logger name="net" level="INFO">
<appender-ref ref="STDOUT" />
</logger>

<root level="DEBUG">
<appender-ref ref="FILE"/>
</root>
</configuration>
@@ -1,5 +1,5 @@
group 'io.mifos.rhythm'
version '0.1.0.BUILD-SNAPSHOT'
version '0.1.0-BUILD-SNAPSHOT'

ext.versions = [
frameworkapi : '0.1.0-BUILD-SNAPSHOT',
@@ -0,0 +1,26 @@
/*
* Copyright 2017 The Mifos Initiative.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.mifos.rhythm.spi.v1;

/**
* @author Myrle Krantz
*/
@SuppressWarnings("unused")
public interface PermittableGroupIds {
static String forApplication(final String beatConsumingApplicationName) {
return beatConsumingApplicationName.replace("-", "__") + "__khepri";
}
}

0 comments on commit 49ade43

Please sign in to comment.