|
30 | 30 | import org.labkey.test.Locator; |
31 | 31 | import org.labkey.test.TestFileUtils; |
32 | 32 | import org.labkey.test.components.FilesWebPart; |
| 33 | +import org.labkey.test.pages.core.admin.ShowAdminPage; |
| 34 | +import org.labkey.test.pages.core.login.LoginConfigurePage; |
| 35 | +import org.labkey.test.util.ApiPermissionsHelper; |
33 | 36 | import org.labkey.test.util.DataRegionTable; |
34 | 37 | import org.labkey.test.util.Ext4Helper; |
35 | 38 | import org.labkey.test.util.FileBrowserHelper; |
|
47 | 50 | import java.util.Set; |
48 | 51 |
|
49 | 52 | import static org.junit.Assert.assertEquals; |
| 53 | +import static org.junit.Assert.assertFalse; |
50 | 54 | import static org.junit.Assert.assertNull; |
51 | 55 | import static org.junit.Assert.assertTrue; |
52 | 56 | import static org.labkey.test.util.DataRegionTable.DataRegion; |
| 57 | +import static org.labkey.test.util.PermissionsHelper.READER_ROLE; |
53 | 58 |
|
54 | 59 | @Category({}) |
55 | 60 | @BaseWebDriverTest.ClassTimeout(minutes = 8) |
@@ -96,6 +101,9 @@ public void testSteps() throws IOException, CommandException |
96 | 101 | // Verify product ion labels |
97 | 102 | importData(SKY_FILE3, ++jobCount); |
98 | 103 | verifyFragmentIonLabels(SKY_FILE3); |
| 104 | + |
| 105 | + // Verify that guests access is blocked on some actions |
| 106 | + verifyGuestAccess(); |
99 | 107 | } |
100 | 108 |
|
101 | 109 | @LogMethod |
@@ -799,4 +807,89 @@ private void verifyFragmentIonLabels(String fileName) |
799 | 807 |
|
800 | 808 | assertTrue("Missing legend items in chromatogram plot - " + missing, missing.isEmpty()); |
801 | 809 | } |
| 810 | + |
| 811 | + @LogMethod |
| 812 | + private void verifyGuestAccess() |
| 813 | + { |
| 814 | + // Enable self sign up |
| 815 | + ShowAdminPage adminPage = goToAdminConsole(); |
| 816 | + LoginConfigurePage loginConfigurePage = adminPage.clickAuthentication(); |
| 817 | + loginConfigurePage.setSelfSignup(true); |
| 818 | + loginConfigurePage.clickSaveAndFinish(); |
| 819 | + |
| 820 | + // Make folder public |
| 821 | + goToProjectHome(getProjectName()); |
| 822 | + ApiPermissionsHelper permissionsHelper = new ApiPermissionsHelper(this); |
| 823 | + permissionsHelper.setSiteGroupPermissions("Guests", READER_ROLE); |
| 824 | + |
| 825 | + // Signout |
| 826 | + signOut(); |
| 827 | + verifyGuestAccess(true); |
| 828 | + |
| 829 | + // Disable self-signup |
| 830 | + signIn(); |
| 831 | + adminPage = goToAdminConsole(); |
| 832 | + loginConfigurePage = adminPage.clickAuthentication(); |
| 833 | + loginConfigurePage.setSelfSignup(false); |
| 834 | + loginConfigurePage.clickSaveAndFinish(); |
| 835 | + |
| 836 | + // Message on blocked pages should not include link to register |
| 837 | + signOut(); |
| 838 | + verifyGuestAccess(false); |
| 839 | + } |
| 840 | + |
| 841 | + private void verifyGuestAccess(boolean selfSignupEnabled) |
| 842 | + { |
| 843 | + goToProjectHome(getProjectName()); |
| 844 | + goToDashboard(); |
| 845 | + |
| 846 | + // Verify guest CAN view the document details page (ShowPrecursorListAction) |
| 847 | + clickAndWait(Locator.linkWithText(SKY_FILE)); |
| 848 | + assertTextPresent("Document Summary"); |
| 849 | + |
| 850 | + // Verify guest CAN view the protein details page (ShowProteinAction) |
| 851 | + String targetProtein = "YAL038W"; |
| 852 | + clickAndWait(Locator.linkWithText(targetProtein)); |
| 853 | + assertTextPresentInThisOrder(targetProtein, |
| 854 | + "Protein", |
| 855 | + "Sequence Coverage", |
| 856 | + "Annotations for " + targetProtein, |
| 857 | + "Peptides", |
| 858 | + "Chromatograms", |
| 859 | + "Summary Charts"); |
| 860 | + |
| 861 | + // Verify guest CAN view the peptide details page (ShowPeptideAction) |
| 862 | + String targetPeptide = "LTSLNVVAGSDLR"; |
| 863 | + clickAndWait(Locator.linkWithText(targetPeptide)); |
| 864 | + assertTextPresentInThisOrder(targetPeptide, |
| 865 | + "Peptide Summary", |
| 866 | + "Chromatograms", |
| 867 | + "Summary Charts", |
| 868 | + "LTSLNVVAGSDLR, Charge 2"); // Title of the MS/MS spectrum viewer panel |
| 869 | + |
| 870 | + // Verify guest CANNOT view the precursor details page (PrecursorAllChromatogramsChartAction) |
| 871 | + clickAndWait(Locator.linkWithImage("TransitionGroupLib.png")); |
| 872 | + verifyNoGuestAccessMessage(selfSignupEnabled); |
| 873 | + |
| 874 | + // Go back to the document details page and in Document Summary click the transitions link |
| 875 | + // Verify guest CANNOT view the transitions list (ShowTransitionListAction) |
| 876 | + goToDashboard(); |
| 877 | + clickAndWait(Locator.linkWithText(SKY_FILE)); |
| 878 | + clickAndWait(Locator.linkWithText("296 transitions")); |
| 879 | + verifyNoGuestAccessMessage(selfSignupEnabled); |
| 880 | + } |
| 881 | + |
| 882 | + private void verifyNoGuestAccessMessage(boolean selfSignupEnabled) |
| 883 | + { |
| 884 | + String fullBodyText = getBodyText(); |
| 885 | + if (selfSignupEnabled) |
| 886 | + { |
| 887 | + assertTrue(fullBodyText.contains("Login to view this data" + "\n" + "Don't have an account? Register")); |
| 888 | + } |
| 889 | + else |
| 890 | + { |
| 891 | + assertTrue(fullBodyText.contains("Login to view this data")); |
| 892 | + assertFalse(fullBodyText.contains("Don't have an account? Register")); |
| 893 | + } |
| 894 | + } |
802 | 895 | } |
0 commit comments