Skip to content
Permalink
Browse files
renaming API
  • Loading branch information
Markus Geiss committed Mar 18, 2017
1 parent b3c5559 commit 6198dfc813ca5c4d767bec089e72328643b9a507
Showing 10 changed files with 74 additions and 74 deletions.
@@ -37,7 +37,7 @@
*/
@SuppressWarnings("unused")
@FeignClient(name="provisioner-v1", path="/provisioner/v1", configuration=CustomFeignClientsConfiguration.class)
public interface ProvisionerService {
public interface Provisioner {


@RequestMapping(
@@ -16,7 +16,7 @@
package io.mifos.provisioner;

import io.mifos.core.test.env.TestEnvironment;
import io.mifos.provisioner.api.v1.client.ProvisionerService;
import io.mifos.provisioner.api.v1.client.Provisioner;
import io.mifos.provisioner.config.ProvisionerServiceConfig;
import org.junit.BeforeClass;
import org.junit.ClassRule;
@@ -68,7 +68,7 @@ public Logger logger() {
.around(cassandraInitializer);

@Autowired
protected ProvisionerService provisionerService;
protected Provisioner provisioner;

public AbstractServiceTest() {
super();
@@ -41,23 +41,23 @@ public TestApplications() {
@Before
public void before()
{
final AuthenticationResponse authentication = provisionerService.authenticate(
final AuthenticationResponse authentication = provisioner.authenticate(
this.getClientId(), ApiConstants.SYSTEM_SU, ProvisionerConstants.INITIAL_PWD);
autoSeshat = new AutoSeshat(authentication.getToken());
}

@After
public void after() {
provisionerService.deleteApplication(Fixture.getApplication().getName());
provisioner.deleteApplication(Fixture.getApplication().getName());
autoSeshat.close();
}

@Test
public void shouldCreateApplication() {
final Application application = Fixture.getApplication();
provisionerService.createApplication(application);
provisioner.createApplication(application);

final Application createdApplication = provisionerService.getApplication(application.getName());
final Application createdApplication = provisioner.getApplication(application.getName());

Assert.assertNotNull(createdApplication);
Assert.assertEquals(application.getName(), createdApplication.getName());
@@ -68,44 +68,44 @@ public void shouldCreateApplication() {

@Test
public void shouldFindApplication() {
provisionerService.createApplication(Fixture.getApplication());
Assert.assertNotNull(provisionerService.getApplication(Fixture.getApplication().getName()));
provisioner.createApplication(Fixture.getApplication());
Assert.assertNotNull(provisioner.getApplication(Fixture.getApplication().getName()));
}

@Test
public void shouldFetchAll() {
provisionerService.createApplication(Fixture.getApplication());
Assert.assertFalse(provisionerService.getApplications().isEmpty());
provisioner.createApplication(Fixture.getApplication());
Assert.assertFalse(provisioner.getApplications().isEmpty());
}

@Test(expected = DuplicateIdentifierException.class)
public void shouldFailCreateDuplicate() {
provisionerService.createApplication(Fixture.getApplication());
provisionerService.createApplication(Fixture.getApplication());
provisioner.createApplication(Fixture.getApplication());
provisioner.createApplication(Fixture.getApplication());
}

@Test(expected = NotFoundException.class)
public void shouldFailFindUnknown() {
provisionerService.getApplication("unknown");
provisioner.getApplication("unknown");
}

@Test
public void shouldDeleteApplication() {
final Application applicationToDelete = new Application();
applicationToDelete.setName("deleteme");

provisionerService.createApplication(applicationToDelete);
provisioner.createApplication(applicationToDelete);

try {
provisionerService.getApplication(applicationToDelete.getName());
provisioner.getApplication(applicationToDelete.getName());
} catch (final RuntimeException ignored) {
Assert.fail();
}

provisionerService.deleteApplication(applicationToDelete.getName());
provisioner.deleteApplication(applicationToDelete.getName());

try {
provisionerService.getApplication(applicationToDelete.getName());
provisioner.getApplication(applicationToDelete.getName());
Assert.fail();
}
catch (final RuntimeException ex) {
@@ -38,25 +38,25 @@ public TestClients() {
@Before
public void before()
{
final AuthenticationResponse authentication = provisionerService.authenticate(
final AuthenticationResponse authentication = provisioner.authenticate(
this.getClientId(), ApiConstants.SYSTEM_SU, ProvisionerConstants.INITIAL_PWD);
autoSeshat = new AutoSeshat(authentication.getToken());
}

@After
public void after() {
provisionerService.deleteClient(Fixture.getCompTestClient().getName());
provisioner.deleteClient(Fixture.getCompTestClient().getName());
autoSeshat.close();
}

@Test
public void shouldCreateClient() {
final Client client = Fixture.getCompTestClient();

provisionerService.createClient(client);
provisioner.createClient(client);
//TODO: add waiting?

final Client newlyCreatedClient = provisionerService.getClient(client.getName());
final Client newlyCreatedClient = provisioner.getClient(client.getName());

Assert.assertEquals(client.getName(), newlyCreatedClient.getName());
Assert.assertEquals(client.getDescription(), newlyCreatedClient.getDescription());
@@ -70,43 +70,43 @@ public void shouldFailCreateClientAlreadyExists() {
final Client client = new Client();
client.setName("duplicate-client");

provisionerService.createClient(client);
provisionerService.createClient(client);
provisioner.createClient(client);
provisioner.createClient(client);
}

@Test
public void shouldFindClient() {
provisionerService.createClient(Fixture.getCompTestClient());
Assert.assertNotNull(provisionerService.getClient(Fixture.getCompTestClient().getName()));
provisioner.createClient(Fixture.getCompTestClient());
Assert.assertNotNull(provisioner.getClient(Fixture.getCompTestClient().getName()));
}

@Test(expected = NotFoundException.class)
public void shouldNotFindClientUnknown() {
provisionerService.getClient("unknown-client");
provisioner.getClient("unknown-client");
}

@Test
public void shouldFetchAllClients() {
Assert.assertFalse(provisionerService.getClients().isEmpty());
Assert.assertFalse(provisioner.getClients().isEmpty());
}

@Test
public void shouldDeleteClient() {
final Client clientToDelete = new Client();
clientToDelete.setName("deleteme");

provisionerService.createClient(clientToDelete);
provisioner.createClient(clientToDelete);

try {
provisionerService.getClient(clientToDelete.getName());
provisioner.getClient(clientToDelete.getName());
} catch (final Exception ex) {
Assert.fail();
}

provisionerService.deleteClient(clientToDelete.getName());
provisioner.deleteClient(clientToDelete.getName());

try {
provisionerService.getClient(clientToDelete.getName());
provisioner.getClient(clientToDelete.getName());
Assert.fail();
}
catch (final RuntimeException ex) {
@@ -34,22 +34,22 @@ public TestAuthentication() {
@Test
public void shouldLoginAdmin() {
final AuthenticationResponse authenticate
= provisionerService.authenticate(this.getClientId(), ApiConstants.SYSTEM_SU, ProvisionerConstants.INITIAL_PWD);
= provisioner.authenticate(this.getClientId(), ApiConstants.SYSTEM_SU, ProvisionerConstants.INITIAL_PWD);
Assert.assertNotNull(authenticate.getToken());
}

@Test(expected = InvalidProvisionerCredentialsException.class)
public void shouldFailLoginWrongClientId() {
provisionerService.authenticate("wrong-client", ApiConstants.SYSTEM_SU, ProvisionerConstants.INITIAL_PWD);
provisioner.authenticate("wrong-client", ApiConstants.SYSTEM_SU, ProvisionerConstants.INITIAL_PWD);
}

@Test(expected = InvalidProvisionerCredentialsException.class)
public void shouldFailLoginWrongUser() {
provisionerService.authenticate(this.getClientId(), "wrong-user", ProvisionerConstants.INITIAL_PWD);
provisioner.authenticate(this.getClientId(), "wrong-user", ProvisionerConstants.INITIAL_PWD);
}

@Test(expected = InvalidProvisionerCredentialsException.class)
public void shouldFailLoginWrongPassword() {
provisionerService.authenticate(this.getClientId(), ApiConstants.SYSTEM_SU, Base64Utils.encodeToString("wrong-pwd".getBytes()));
provisioner.authenticate(this.getClientId(), ApiConstants.SYSTEM_SU, Base64Utils.encodeToString("wrong-pwd".getBytes()));
}
}
@@ -45,7 +45,7 @@ public void shouldUpdatePassword() {
currentPassword = Base64Utils.encodeToString("new-pwd".getBytes());

final AuthenticationResponse authenticate =
provisionerService.authenticate(this.getClientId(), ApiConstants.SYSTEM_SU, currentPassword);
provisioner.authenticate(this.getClientId(), ApiConstants.SYSTEM_SU, currentPassword);

checkAuthenticationResponse(authenticate);
}
@@ -58,7 +58,7 @@ public void shouldUpdatePasswordExpiration() {
setPasswordPolicy(passwordPolicy);

final AuthenticationResponse authenticate =
provisionerService.authenticate(this.getClientId(), ApiConstants.SYSTEM_SU, currentPassword);
provisioner.authenticate(this.getClientId(), ApiConstants.SYSTEM_SU, currentPassword);

checkAuthenticationResponse(authenticate);
}
@@ -73,16 +73,16 @@ public void shouldUpdatePasswordPolicy() {
currentPassword = Base64Utils.encodeToString("new-pwd".getBytes());

final AuthenticationResponse authenticate =
provisionerService.authenticate(this.getClientId(), ApiConstants.SYSTEM_SU, currentPassword);
provisioner.authenticate(this.getClientId(), ApiConstants.SYSTEM_SU, currentPassword);

checkAuthenticationResponse(authenticate);
}

private void setPasswordPolicy(final PasswordPolicy passwordPolicy)
{
final AuthenticationResponse authenticate = provisionerService.authenticate(this.getClientId(), ApiConstants.SYSTEM_SU, currentPassword);
final AuthenticationResponse authenticate = provisioner.authenticate(this.getClientId(), ApiConstants.SYSTEM_SU, currentPassword);
try (final AutoUserContext ignore = new AutoUserContext(ApiConstants.SYSTEM_SU, authenticate.getToken())) {
provisionerService.updatePasswordPolicy(ApiConstants.SYSTEM_SU, passwordPolicy);
provisioner.updatePasswordPolicy(ApiConstants.SYSTEM_SU, passwordPolicy);
}
}

@@ -30,7 +30,7 @@
import io.mifos.identity.api.v1.domain.PermittableGroup;
import io.mifos.provisioner.ProvisionerCassandraInitializer;
import io.mifos.provisioner.ProvisionerMariaDBInitializer;
import io.mifos.provisioner.api.v1.client.ProvisionerService;
import io.mifos.provisioner.api.v1.client.Provisioner;
import io.mifos.provisioner.api.v1.domain.*;
import io.mifos.provisioner.config.ProvisionerConstants;
import io.mifos.provisioner.config.ProvisionerServiceConfig;
@@ -116,7 +116,7 @@ public TokenProvider tokenProviderSpy(final @Qualifier("tokenProvider") TokenPro
.around(cassandraInitializer);

@Autowired
private ProvisionerService provisionerService;
private Provisioner provisioner;

@Autowired
@Qualifier("tokenProviderSpy")
@@ -145,14 +145,14 @@ public static void setup() throws Exception {
@Before
public void before()
{
final AuthenticationResponse authentication = this.provisionerService.authenticate(
final AuthenticationResponse authentication = this.provisioner.authenticate(
CLIENT_ID, ApiConstants.SYSTEM_SU, ProvisionerConstants.INITIAL_PWD);
autoSeshat = new AutoSeshat(authentication.getToken());
}

@After
public void after() throws InterruptedException {
this.provisionerService.deleteTenant(Fixture.getCompTestTenant().getIdentifier());
this.provisioner.deleteTenant(Fixture.getCompTestTenant().getIdentifier());
Thread.sleep(500L);
autoSeshat.close();
}
@@ -241,7 +241,7 @@ boolean isValidSecurityContext() {
public void testTenantApplicationAssignment() throws InterruptedException {
//Create io.mifos.provisioner.tenant
final Tenant tenant = Fixture.getCompTestTenant();
provisionerService.createTenant(tenant);
provisioner.createTenant(tenant);


//Create identity service application
@@ -251,7 +251,7 @@ public void testTenantApplicationAssignment() throws InterruptedException {
identityServiceApp.setDescription("identity manager");
identityServiceApp.setVendor("fineract");

provisionerService.createApplication(identityServiceApp);
provisioner.createApplication(identityServiceApp);


//Assign identity service application. This requires some mocking since we can't actually call initialize in a component test.
@@ -275,7 +275,7 @@ public void testTenantApplicationAssignment() throws InterruptedException {

{
final IdentityManagerInitialization identityServiceAdminInitialization
= provisionerService.assignIdentityManager(tenant.getIdentifier(), identityServiceAssigned);
= provisioner.assignIdentityManager(tenant.getIdentifier(), identityServiceAssigned);

Assert.assertTrue(verifyInitializeContextAndReturnSignature.isValidSecurityContext());
Assert.assertNotNull(identityServiceAdminInitialization);
@@ -292,7 +292,7 @@ public void testTenantApplicationAssignment() throws InterruptedException {
officeApp.setDescription("organization manager");
officeApp.setVendor("fineract");

provisionerService.createApplication(officeApp);
provisioner.createApplication(officeApp);


//Assign horus application.
@@ -318,7 +318,7 @@ public void testTenantApplicationAssignment() throws InterruptedException {
doAnswer(verifyAnubisPermittablesContext).when(anubisMock).getPermittableEndpoints();

{
provisionerService.assignApplications(tenant.getIdentifier(), Collections.singletonList(officeAssigned));
provisioner.assignApplications(tenant.getIdentifier(), Collections.singletonList(officeAssigned));
Thread.sleep(500L); //Application assigning is asynchronous.
}

0 comments on commit 6198dfc

Please sign in to comment.