New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JBIDE-25194 OpenShift IO Integration test #1615
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
...g/jboss/tools/openshift/ui/bot/test/integration/openshift/io/GetOpenShiftIOTokenTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2007-2017 Red Hat, Inc. | ||
* Distributed under license by Red Hat, Inc. All rights reserved. | ||
* This program is made available under the terms of the | ||
* Eclipse Public License v 1.0 which accompanies this distribution, | ||
* and is available at http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributor: | ||
* Red Hat, Inc. - initial API and implementation | ||
******************************************************************************/ | ||
package org.jboss.tools.openshift.ui.bot.test.integration.openshift.io; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.eclipse.reddeer.common.wait.TimePeriod; | ||
import org.eclipse.reddeer.common.wait.WaitUntil; | ||
import org.eclipse.reddeer.common.wait.WaitWhile; | ||
import org.eclipse.reddeer.core.exception.CoreLayerException; | ||
import org.eclipse.reddeer.eclipse.equinox.security.ui.storage.StoragePreferencePage; | ||
import org.eclipse.reddeer.junit.runner.RedDeerSuite; | ||
import org.eclipse.reddeer.swt.impl.browser.InternalBrowser; | ||
import org.eclipse.reddeer.swt.impl.button.OkButton; | ||
import org.eclipse.reddeer.swt.impl.shell.DefaultShell; | ||
import org.eclipse.reddeer.swt.impl.toolbar.DefaultToolItem; | ||
import org.eclipse.reddeer.swt.impl.tree.DefaultTree; | ||
import org.eclipse.reddeer.swt.impl.tree.DefaultTreeItem; | ||
import org.eclipse.reddeer.workbench.core.condition.JobIsRunning; | ||
import org.eclipse.reddeer.workbench.impl.shell.WorkbenchShell; | ||
import org.eclipse.reddeer.workbench.ui.dialogs.WorkbenchPreferenceDialog; | ||
import org.jboss.tools.openshift.reddeer.condition.BrowserContainsText; | ||
import org.jboss.tools.openshift.reddeer.preference.page.OpenShifIOPreferencePage; | ||
import org.jboss.tools.openshift.reddeer.utils.DatastoreOS3; | ||
import org.jboss.tools.openshift.reddeer.utils.SecureStorage; | ||
import org.jboss.tools.openshift.reddeer.utils.SystemProperties; | ||
import org.junit.AfterClass; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* | ||
* @author jkopriva@redhat.com | ||
*/ | ||
@RunWith(RedDeerSuite.class) | ||
public class GetOpenShiftIOTokenTest { | ||
|
||
@Test | ||
public void testGetToken() { | ||
new DefaultToolItem(new WorkbenchShell(), "Connect to OpenShift.io").click(); | ||
DefaultShell browser = new DefaultShell(); | ||
InternalBrowser internalBrowser = new InternalBrowser(browser); | ||
|
||
new WaitWhile(new JobIsRunning(), TimePeriod.LONG); | ||
new WaitUntil(new BrowserContainsText("OpenShift.io Developer Preview"), TimePeriod.LONG); | ||
|
||
internalBrowser.execute(String.format("document.getElementById(\"username\").value=\"%s\"", DatastoreOS3.OPENSHIFT_IO_USERNAME)); | ||
internalBrowser.execute(String.format("document.getElementById(\"password\").value=\"%s\"", DatastoreOS3.OPENSHIFT_IO_PASSWORD)); | ||
internalBrowser.execute("document.getElementById(\"password\").parentElement.parentElement.parentElement.submit()"); | ||
|
||
new WaitWhile(new JobIsRunning(), TimePeriod.LONG); | ||
|
||
try { | ||
new DefaultShell("OpenShift.io"); | ||
} catch (CoreLayerException ex) { | ||
//Secure storage has been triggered | ||
SecureStorage.handleSecureStoragePasswordAndHint(SystemProperties.SECURE_STORAGE_PASSWORD); | ||
new DefaultShell("OpenShift.io"); | ||
} | ||
new OkButton().click(); | ||
|
||
checkAccountInProperties(); | ||
checkPluginInSecureStorage(); | ||
|
||
} | ||
|
||
private void checkPluginInSecureStorage() { | ||
WorkbenchPreferenceDialog preferences = new WorkbenchPreferenceDialog(); | ||
preferences.open(); | ||
StoragePreferencePage storagePreferencePage = new StoragePreferencePage(preferences); | ||
preferences.select(storagePreferencePage); | ||
storagePreferencePage.selectContentTab(); | ||
DefaultTreeItem account = new DefaultTreeItem(new DefaultTree(storagePreferencePage, 1), "[Default Secure Storage]","org.jboss.tools.openshift.io.core", "accounts", "OpenShift.io", DatastoreOS3.OPENSHIFT_IO_USERNAME); | ||
account.select(); | ||
assertNotNull("Account does not exists in secure storage", account); | ||
preferences.ok(); | ||
} | ||
|
||
private void checkAccountInProperties() { | ||
WorkbenchPreferenceDialog preferences = new WorkbenchPreferenceDialog(); | ||
preferences.open(); | ||
OpenShifIOPreferencePage page = new OpenShifIOPreferencePage(preferences); | ||
preferences.select(page); | ||
assertTrue("Account is not configured!",page.existsOpenShiftIOAccount()); | ||
preferences.ok(); | ||
} | ||
|
||
@AfterClass | ||
public static void cleanUp() { | ||
removeAccountFromOpenShiftIOPreferencePage(); | ||
} | ||
|
||
private static void removeAccountFromOpenShiftIOPreferencePage() { | ||
WorkbenchPreferenceDialog preferences = new WorkbenchPreferenceDialog(); | ||
preferences.open(); | ||
OpenShifIOPreferencePage page = new OpenShifIOPreferencePage(preferences); | ||
preferences.select(page); | ||
if (page.existsOpenShiftIOAccount()) { | ||
page.remove(); | ||
} | ||
preferences.ok(); | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
...ddeer/src/org/jboss/tools/openshift/reddeer/preference/page/OpenShifIOPreferencePage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2007-2017 Red Hat, Inc. | ||
* Distributed under license by Red Hat, Inc. All rights reserved. | ||
* This program is made available under the terms of the | ||
* Eclipse Public License v 1.0 which accompanies this distribution, | ||
* and is available at http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributor: | ||
* Red Hat, Inc. - initial API and implementation | ||
******************************************************************************/ | ||
package org.jboss.tools.openshift.reddeer.preference.page; | ||
|
||
import org.eclipse.reddeer.core.reference.ReferencedComposite; | ||
import org.eclipse.reddeer.jface.preference.PreferencePage; | ||
import org.eclipse.reddeer.swt.impl.button.PushButton; | ||
|
||
/** | ||
* OpenShift.io preference page its used for showing information about OpenShift.io account. | ||
* @author jkopriva@redhat.com | ||
*/ | ||
public class OpenShifIOPreferencePage extends PreferencePage { | ||
|
||
public OpenShifIOPreferencePage(ReferencedComposite composite) { | ||
super(composite, "JBoss Tools", "OpenShift.io"); | ||
} | ||
|
||
/** | ||
* Remove OpenShift.io account. | ||
*/ | ||
public OpenShifIOPreferencePage remove() { | ||
new PushButton(this, "Remove").click(); | ||
return this; | ||
} | ||
|
||
public boolean existsOpenShiftIOAccount() { | ||
return new PushButton(this, "Remove").isEnabled(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ | |
|
||
import static org.jboss.tools.openshift.reddeer.utils.SystemProperties.KEY_SERVER; | ||
import static org.jboss.tools.openshift.reddeer.utils.SystemProperties.KEY_USERNAME; | ||
import static org.jboss.tools.openshift.reddeer.utils.SystemProperties.KEY_OPENSHIFT_IO_USERNAME; | ||
import static org.jboss.tools.openshift.reddeer.utils.SystemProperties.KEY_OPENSHIFT_IO_PASSWORD; | ||
import static org.jboss.tools.openshift.reddeer.utils.SystemProperties.getRequiredProperty; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
|
@@ -62,6 +64,10 @@ public class DatastoreOS3 { | |
public static final String GIT_USERNAME = System.getProperty("github.username", "openshift-tools-testing-account"); | ||
public static final String GIT_PASSWORD = System.getProperty("github.password"); | ||
|
||
//OpenShift IO credentials | ||
public static String OPENSHIFT_IO_USERNAME = System.getProperty(KEY_OPENSHIFT_IO_USERNAME); | ||
public static String OPENSHIFT_IO_PASSWORD = System.getProperty(KEY_OPENSHIFT_IO_PASSWORD); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
public static String PROJECT1 = "project-name01-" + System.currentTimeMillis(); | ||
public static String PROJECT1_DISPLAYED_NAME = "displayedName-" + System.currentTimeMillis(); | ||
public static String PROJECT2 = "project-name02-" + System.currentTimeMillis(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,8 @@ public class SystemProperties { | |
public static final String KEY_USERNAME = "openshift.username"; | ||
public static final String KEY_PASSWORD = "openshift.password"; | ||
private static final String KEY_SECURE_STORAGE_PASSWORD = "securestorage.password"; | ||
public static final String KEY_OPENSHIFT_IO_USERNAME = "openshift.io.username"; | ||
public static final String KEY_OPENSHIFT_IO_PASSWORD = "openshift.io.password"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
// secure storage | ||
public static final String SECURE_STORAGE_PASSWORD = getRequiredProperty(KEY_SECURE_STORAGE_PASSWORD, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename this field "OPENSHIFT_IO_USERNAME" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
Make this "public static OPENSHIFT_IO_USERNAME" field final
Make OPENSHIFT_IO_USERNAME a static final constant or non-public and provide accessors if needed.