/workbench-test/java/src/forceworkbench/tests/LoginTests.java

https://code.google.com/ · Java · 143 lines · 115 code · 27 blank · 1 comment · 9 complexity · 6a5732d02e4df7cbe8cb615fefed4412 MD5 · raw file

  1. package forceworkbench.tests;
  2. public class LoginTests extends WorkbenchSeleneseBaseTest {
  3. public void setUp() throws Exception{
  4. super.setUp();
  5. }
  6. public void testAutoLoginUnPw() throws Exception{
  7. setApiVersion(config.getApiVersion());
  8. selenium.open("login.php?&un=" + config.getUsername() + "&pw=" + config.getPassword());
  9. selenium.waitForPageToLoad(WAIT_TIMEOUT);
  10. assertTrue(selenium.getLocation().contains("select.php"));
  11. }
  12. public void testAutoLoginUnPwStartUrl() throws Exception{
  13. setApiVersion(config.getApiVersion());
  14. selenium.open("login.php?&un=" + config.getUsername() + "&pw=" + config.getPassword() + "&startUrl=query.php");
  15. selenium.waitForPageToLoad(WAIT_TIMEOUT);
  16. assertEquals("Workbench: SOQL Query", selenium.getTitle());
  17. }
  18. public void testAutoLoginApiVersions() throws Exception {
  19. selenium.open("login.php");
  20. selenium.click("loginType_adv");
  21. for(String ep : selenium.getSelectOptions("api")){
  22. if(Double.valueOf(ep) > Double.valueOf(config.getApiVersion())){
  23. continue;
  24. }
  25. selenium.open("login.php?&un=" + config.getUsername() + "&pw=" + config.getPassword() + "&inst=" + config.getInstance() + "&api=" + ep);
  26. selenium.waitForPageToLoad(WAIT_TIMEOUT);
  27. assertTrue(selenium.getLocation().contains("select.php"));
  28. assertNoPhpErrors();
  29. break;
  30. }
  31. }
  32. public void testStdLoginJumpTo() throws Exception {
  33. selenium.open("login.php");
  34. selenium.open("login.php");
  35. assertEquals("Workbench", selenium.getTitle());
  36. assertTrue(selenium.isTextPresent("Username:"));
  37. assertTrue(selenium.isTextPresent("Password:"));
  38. assertFalse(selenium.isVisible("sid"));
  39. assertNoPhpErrors();
  40. selenium.type("un", config.getUsername());
  41. selenium.type("pw", config.getPassword());
  42. selenium.click("loginBtn");
  43. selenium.waitForPageToLoad(WAIT_TIMEOUT);
  44. assertEquals("Workbench", selenium.getTitle());
  45. assertTrue(selenium.getLocation().contains("select.php"));
  46. assertNoPhpErrors();
  47. }
  48. public void testAdvLoginJumpTo() throws Exception {
  49. selenium.open("login.php");
  50. selenium.click("loginType_adv");
  51. selenium.open("login.php");
  52. assertEquals("Workbench", selenium.getTitle());
  53. selenium.click("loginType_adv");
  54. assertTrue(selenium.isTextPresent("Username:"));
  55. assertTrue(selenium.isTextPresent("Password:"));
  56. assertTrue(selenium.isVisible("sid"));
  57. assertNoPhpErrors();
  58. selenium.type("un", config.getUsername());
  59. selenium.type("pw", config.getPassword());
  60. selenium.click("loginBtn");
  61. selenium.waitForPageToLoad(WAIT_TIMEOUT);
  62. assertEquals("Workbench", selenium.getTitle());
  63. assertTrue(selenium.getLocation().contains("select.php"));
  64. assertNoPhpErrors();
  65. }
  66. public void testAdvLoginApiVersions() throws Exception {
  67. selenium.open("login.php");
  68. selenium.click("loginType_adv");
  69. for(String api : selenium.getSelectOptions("api")){
  70. if(Double.valueOf(api) > Double.valueOf(config.getApiVersion())) {
  71. continue;
  72. }
  73. selenium.open("login.php");
  74. assertEquals("Workbench", selenium.getTitle());
  75. selenium.click("loginType_adv");
  76. assertNoPhpErrors();
  77. selenium.select("api", "label=" + api);
  78. assertEquals("https://login.salesforce.com/services/Soap/u/" + api, selenium.getValue("serverUrl"));
  79. selenium.type("un", config.getUsername());
  80. selenium.type("pw", config.getPassword());
  81. selenium.click("loginBtn");
  82. selenium.waitForPageToLoad(WAIT_TIMEOUT);
  83. assertTrue(selenium.getLocation().contains("select.php"));
  84. assertNoPhpErrors();
  85. break;
  86. }
  87. }
  88. public void testAdvLoginInstances() throws Exception {
  89. selenium.open("login.php");
  90. selenium.click("loginType_adv");
  91. for (String inst : selenium.getSelectOptions("inst")){
  92. //skip future instances
  93. if(config.getIgnoredInstances().contains(inst)){
  94. continue;
  95. }
  96. selenium.open("login.php");
  97. assertEquals("Title should be Workbench", "Workbench", selenium.getTitle());
  98. selenium.click("loginType_adv");
  99. selenium.select("inst", "label=" + inst);
  100. selenium.type("un", config.getUsername());
  101. selenium.type("pw", config.getPassword());
  102. selenium.click("loginBtn");
  103. selenium.waitForPageToLoad(WAIT_TIMEOUT);
  104. final String location = selenium.getLocation();
  105. if(inst.contains(config.getInstance()) || inst.contains(config.getLoginInstance())){
  106. assertTrue("Should be on Select page for " + inst + ". Location was " + location,
  107. location.contains("select.php"));
  108. } else {
  109. assertTrue("Should have been an INVALID_LOGIN for " + inst + ". Location was " + location,
  110. selenium.isTextPresent("INVALID_LOGIN"));
  111. }
  112. assertNoPhpErrors();
  113. break;
  114. }
  115. }
  116. }