Skip to content

Commit

Permalink
fix(test): Use programmatically configured engine in passwordpolicy test
Browse files Browse the repository at this point in the history
related to CAM-9929, CAM-9930
  • Loading branch information
mboskamp committed Mar 22, 2019
1 parent 23fcbe9 commit 53360a8
Showing 1 changed file with 33 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,52 @@
*/
package org.camunda.bpm.engine.test.api.passwordpolicy;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.camunda.bpm.engine.IdentityService;
import org.camunda.bpm.engine.identity.User;
import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.camunda.bpm.engine.impl.pwpolicy.DefaultPasswordPolicyImpl;
import org.camunda.bpm.engine.impl.pwpolicy.PasswordPolicyException;
import org.camunda.bpm.engine.impl.test.ResourceProcessEngineTestCase;
import org.camunda.bpm.engine.pwpolicy.PasswordPolicy;
import org.camunda.bpm.engine.test.ProcessEngineRule;
import org.camunda.bpm.engine.test.util.ProvidedProcessEngineRule;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

/**
* @author Miklas Boskamp
*/
public class CustomPasswordPolicyTest extends ResourceProcessEngineTestCase {
public class CustomPasswordPolicyTest {

@Rule
public ProcessEngineRule engineRule = new ProvidedProcessEngineRule();

private ProcessEngineConfigurationImpl processEngineConfiguration;
private IdentityService identityService;

public CustomPasswordPolicyTest() {
super("org/camunda/bpm/engine/test/api/passwordpolicy/passwordpolicy.custom.camunda.cfg.xml");
@Before
public void init() {
identityService = engineRule.getIdentityService();
processEngineConfiguration = engineRule.getProcessEngineConfiguration();
processEngineConfiguration.setPasswordPolicy(new CustomPasswordPolicyImpl());
processEngineConfiguration.setDisablePasswordPolicy(false);
}

@Override
protected void tearDown() throws Exception {
@After
public void tearDown() {
// reset configuration
processEngineConfiguration.setPasswordPolicy(new DefaultPasswordPolicyImpl());
processEngineConfiguration.setDisablePasswordPolicy(true);
// reset database
identityService.deleteUser("user");
}

@Test
public void testCustomPasswordPolicy() {
PasswordPolicy policy = processEngineConfiguration.getPasswordPolicy();
assertTrue(policy.getClass().isAssignableFrom(CustomPasswordPolicyImpl.class));
Expand Down

0 comments on commit 53360a8

Please sign in to comment.