Commit ee8bc7b7 authored by apupier's avatar apupier

BS-12002: update "encrypted" attribute when the password is updated, add

SWTbotTest to avoid regression
parent 8665a90a
......@@ -50,7 +50,9 @@ Require-Bundle: org.eclipse.core.runtime,
org.junit;bundle-version="4.11.0";resolution:=optional,
org.mockito;bundle-version="1.9.5";resolution:=optional,
org.bonitasoft.studio.expression.editor,
org.apache.commons.lang;bundle-version="2.6.0"
org.apache.commons.lang;bundle-version="2.6.0",
org.eclipse.emf.databinding,
org.eclipse.core.databinding.observable
Bundle-ActivationPolicy: lazy
Import-Package: org.bonitasoft.engine.api,
org.bonitasoft.engine.bpm,
......
/**
* Copyright (C) 2012 BonitaSoft S.A.
* BonitaSoft, 31 rue Gustave Eiffel - 38000 Grenoble
* Copyright (C) 2012-2014 BonitaSoft S.A.
* BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.actors.ui.wizard.page;
......@@ -53,6 +51,7 @@ import org.eclipse.core.databinding.observable.value.IValueChangeListener;
import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.internal.databinding.observable.masterdetail.DetailObservableValue;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.common.util.ECollections;
......@@ -117,9 +116,6 @@ public class UsersWizardPage extends AbstractOrganizationWizardPage {
private static final int CUSTOM_USER_DEFINITION_VALUE_LIMIT_SIZE = 255;
private static final String DEFAULT_USER_PASSWORD = "bpm";
private static final int MIN_SC_WIDTH = 426;
private static final int MIN_SC_HEIGHT = 268;
CustomUserInfoDefinitions infoDefinitions;
......@@ -455,7 +451,17 @@ public class UsersWizardPage extends AbstractOrganizationWizardPage {
final IObservableValue userPasswordObservableValue = EMFObservables.observeDetailValue(Realm.getDefault(), userSingleSelectionObservable, OrganizationPackage.Literals.USER__PASSWORD);
final IObservableValue passwordValueObservableValue = EMFObservables.observeDetailValue(Realm.getDefault(), userPasswordObservableValue, OrganizationPackage.Literals.PASSWORD_TYPE__VALUE);
final IObservableValue passwordValueObservableValue = EMFObservables.observeDetailValue(Realm.getDefault(), userPasswordObservableValue,
OrganizationPackage.Literals.PASSWORD_TYPE__VALUE);
passwordValueObservableValue.addValueChangeListener(new IValueChangeListener() {
@Override
public void handleValueChange(final ValueChangeEvent event) {
final IObservableValue value = event.getObservableValue();
final PasswordType password = (PasswordType) ((DetailObservableValue) value).getObserved();
password.setEncrypted(false);
}
});
final Binding binding = context.bindValue(SWTObservables.observeText(passwordText, SWT.Modify), passwordValueObservableValue,mandatoryStrategy,null);
ControlDecorationSupport.create(binding, SWT.LEFT, rightColumnComposite, new ControlDecorationUpdater(){
......
......@@ -23,6 +23,7 @@ Require-Bundle: org.bonitasoft.studio.common;bundle-version="1.0.0",
org.apache.log4j;bundle-version="1.2.15",
org.junit,
org.bonitasoft.studio.dependencies,
org.bonitasoft.studio.test.swtbot.util
org.bonitasoft.studio.test.swtbot.util,
org.bonitasoft.studio.swtbot.framework;bundle-version="6.4.1"
<?xml version="1.0" encoding="UTF-8"?>
<organization:Organization xmlns:organization="http://documentation.bonitasoft.com/organization-xml-schema/1.1">
<customUserInfoDefinitions/>
<users>
<user userName="User1">
<firstName>User1</firstName>
<lastName>User1</lastName>
<manager></manager>
<personalData/>
<professionalData/>
<password encrypted="true">thisIsAFakedEncryptedValue</password>
<customUserInfoValues/>
</user>
</users>
<roles>
<role name="Role1">
<displayName>Role1</displayName>
</role>
</roles>
<groups>
<group name="Group1">
<displayName>Group1</displayName>
</group>
</groups>
<memberships>
<membership>
<userName>User1</userName>
<roleName>Role1</roleName>
<groupName>Group1</groupName>
</membership>
</memberships>
</organization:Organization>
\ No newline at end of file
/**
* Copyright (C) 2014 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.actors.tests.SWTbot;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import org.bonitasoft.studio.actors.model.organization.PasswordType;
import org.bonitasoft.studio.actors.repository.OrganizationFileStore;
import org.bonitasoft.studio.actors.repository.OrganizationRepositoryStore;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.swtbot.framework.application.BotApplicationWorkbenchWindow;
import org.bonitasoft.studio.swtbot.framework.organization.BotManageOrganizationWizard;
import org.bonitasoft.studio.test.swtbot.util.SWTBotTestUtil;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.swtbot.eclipse.gef.finder.SWTBotGefTestCase;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(SWTBotJunit4ClassRunner.class)
public class TestOrganizationPassword extends SWTBotGefTestCase {
@Test
public void testImportExportWithPasswordUpdated() throws IOException {
importOrganizationProgrammatically();
final BotApplicationWorkbenchWindow botApplicationWorkbenchWindow = new BotApplicationWorkbenchWindow(bot);
final BotManageOrganizationWizard manageOrganizationWizard = botApplicationWorkbenchWindow.organizationMenu().manage();
manageOrganizationWizard.selectOrganization("OrganizationWithEncryptedPassword");
manageOrganizationWizard.next(/* Group page */).next(/* Role page */).next();
manageOrganizationWizard.manageUsers().selectUser("User1").setPassword("updatedPassord");
manageOrganizationWizard.finish();
SWTBotTestUtil.waitUntilBonitaBPmShellIsActive(bot);
final OrganizationRepositoryStore organizationStore = RepositoryManager.getInstance().getRepositoryStore(OrganizationRepositoryStore.class);
final OrganizationFileStore orgaFileStore = organizationStore.getChild("OrganizationWithEncryptedPassword."
+ OrganizationRepositoryStore.ORGANIZATION_EXT);
final PasswordType password = orgaFileStore.getContent().getUsers().getUser().get(0).getPassword();
Assert.assertEquals("The passsword value should have been updated.", "updatedPassord", password.getValue());
Assert.assertFalse("The password has been updated and the value of the attribute encrypted should be set to false", password.isEncrypted());
}
private void importOrganizationProgrammatically() throws IOException, FileNotFoundException {
final OrganizationRepositoryStore organizationStore = RepositoryManager.getInstance().getRepositoryStore(OrganizationRepositoryStore.class);
final String organizationName = "OrganizationWithEncryptedPassword.xml";
final URL archiveURL = TestOrganizationPassword.class.getResource(organizationName);
assertNotNull("filePath should not be null", archiveURL.getPath());
FileInputStream fis = null;
String id = null;
final File toImport = new File(FileLocator.toFileURL(archiveURL).getFile());
assertTrue("organization to import does not exist", toImport.exists());
fis = new FileInputStream(toImport);
id = toImport.getName();
organizationStore.importInputStream(id, fis);
if (fis != null) {
fis.close();
}
}
}
......@@ -57,5 +57,6 @@ Export-Package: org.bonitasoft.studio.swtbot.framework,
org.bonitasoft.studio.swtbot.framework.draw,
org.bonitasoft.studio.swtbot.framework.exception,
org.bonitasoft.studio.swtbot.framework.expression,
org.bonitasoft.studio.swtbot.framework.organization,
org.bonitasoft.studio.swtbot.framework.widget
......@@ -11,6 +11,7 @@ package org.bonitasoft.studio.swtbot.framework.application;
import org.bonitasoft.studio.common.jface.SWTBotConstants;
import org.bonitasoft.studio.swtbot.framework.application.menu.AbstractBotMenu;
import org.bonitasoft.studio.swtbot.framework.application.menu.BotEditMenu;
import org.bonitasoft.studio.swtbot.framework.application.menu.BotOrganizationMenu;
import org.bonitasoft.studio.swtbot.framework.diagram.BotProcessDiagramPerspective;
import org.eclipse.swtbot.eclipse.finder.waits.Conditions;
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
......@@ -112,4 +113,9 @@ public class BotApplicationWorkbenchWindow extends AbstractBotMenu {
return new BotEditMenu(bot);
}
public BotOrganizationMenu organizationMenu() {
openMenu("Organization");
return new BotOrganizationMenu(bot);
}
}
/**
* Copyright (C) 2014 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.swtbot.framework.application.menu;
import org.bonitasoft.studio.swtbot.framework.organization.BotManageOrganizationWizard;
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
public class BotOrganizationMenu extends AbstractBotMenu {
public BotOrganizationMenu(final SWTGefBot bot) {
super(bot);
}
public BotManageOrganizationWizard manage() {
openMenu("Manage...");
return new BotManageOrganizationWizard(bot);
}
}
/**
* Copyright (C) 2014 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.swtbot.framework.organization;
import org.bonitasoft.studio.actors.i18n.Messages;
import org.bonitasoft.studio.swtbot.framework.BotWizardDialog;
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
import org.eclipse.swtbot.swt.finder.waits.Conditions;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
public class BotManageOrganizationWizard extends BotWizardDialog {
public BotManageOrganizationWizard(final SWTGefBot bot) {
super(bot, Messages.manageOrganizationTitle);
}
public void selectOrganization(final String name) {
final int index = bot.table().indexOf(name, Messages.name);
bot.table().select(index);
}
public BotManageUserWizardpage manageUsers() {
return new BotManageUserWizardpage(bot);
}
@Override
public void finish() {
final SWTBotShell shell = bot.activeShell();
super.finish();
//this is a long-running operation, wait that the shell closes
bot.waitUntil(Conditions.shellCloses(shell));
}
}
/**
* Copyright (C) 2014 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.swtbot.framework.organization;
import org.bonitasoft.studio.actors.i18n.Messages;
import org.bonitasoft.studio.swtbot.framework.BotBase;
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
public class BotManageUserWizardPageDetailPanel extends BotBase {
public BotManageUserWizardPageDetailPanel(final SWTGefBot bot) {
super(bot);
}
public void setPassword(final String password) {
bot.textWithLabel(Messages.password + " *").setText(password);
}
}
/**
* Copyright (C) 2014 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.swtbot.framework.organization;
import org.bonitasoft.studio.swtbot.framework.AbstractBotWizardPage;
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
public class BotManageUserWizardpage extends AbstractBotWizardPage {
public BotManageUserWizardpage(final SWTGefBot bot) {
super(bot);
}
public BotManageUserWizardPageDetailPanel selectUser(final String username) {
final int index = bot.table().indexOf(username, 2);
bot.table().select(index);
return new BotManageUserWizardPageDetailPanel(bot);
}
}
package org.bonitasoft.studio.test.swtbot.suite2;
import org.bonitasoft.expressions.test.TestConnectorExpression;
import org.bonitasoft.studio.actors.tests.SWTbot.TestOrganizationPassword;
import org.bonitasoft.studio.commands.test.CopyPasteTests;
import org.bonitasoft.studio.commands.test.DeleteCommandTest;
import org.bonitasoft.studio.commands.test.DuplicateCommandTest;
......@@ -108,7 +109,8 @@ import org.junit.runners.Suite;
TestProcessDependencies.class,
RefactorWidgetIT.class,
ExportImportWithoutMigrationIT.class,
TestFormValidatorIT.class
TestFormValidatorIT.class,
TestOrganizationPassword.class
})
public class AllSWTBotTests2 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment