def testCreatePrivateProgramOwner(self): self.testname="TestCreatePrivateProgramOwner" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) grcobject = GRCObject() do.setUtils(util) do.login() email = config.creator1 password = config.same_password private_prgm_1 = do.createPrivateProgramPermission(email, "", "ProgramOwner") print private_prgm_1 # map any object so that we can check that reader can see do.mapAObjectLHN("Contract") # now log out and then log in with the ProgramEditor user do.selectMenuInTopRight("Logout") do.refresh() # Log in with new user do.login(email, password) print "Log in as : " + do.whoAmI() do.assertEquals("ProgramCreator", do.getRoleLabelInTopRight(), "Label does not says 'ProgramCreator'.") do.selectMenuInTopRight("My Work") # verify that user can see program tab and some programs; by seeing counts do.selectInnerNavTab("program") count = do.countOfAnyObjectInWidget("Program") do.assertGreater(count, 0, "Fail because count is expected to be non-zero if programs indeed exist.") # and being able to navigate to the expanded program row index = do.expandItemWidget("program", private_prgm_1) do.clickViewProgram("program", index) # can see mapped objects do.selectInnerNavTab("contract") count = do.countOfAnyObjectInWidget("Contract") do.assertGreater(count, 0, "Fail because count is expected to be non-zero if programs indeed exist.") # can map an object to program do.mapAObjectWidget("Product", "", True, ("Control", "Objective", "System")) # map link and edit authorization link should not exist do.selectInnerNavTab("person") do.assertTrue(do.isMapLinkPresent("Person"), "Expect map link present since it's a ProgramOwner role.") do.expandItemWidget("Person", email) do.assertTrue(do.isEditAuthorizationPresent(), "Expect Edit Authorization link present since it's a ProgramOwner role.") # can edit info page do.selectInnerNavTab("info") do.assertTrue(do.isSubmitForReviewPresent(), "Expect Submit For Review link not present since it's a ProgramOwner role.") do.clickOnInfoPageEditLink() do.populateObjectInEditWindow(private_prgm_1 , grcobject.program_elements, grcobject.program_values) do.openObjectEditWindow() do.verifyObjectValues(grcobject.program_elements, grcobject.program_values) do.deleteObject()
def testNoAccessRole(self): self.testname="TestNoAccessRole" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() email = config.reader1 reader = config.reader2 password = config.same_password title = "Auto_Private_" + do.getTimeId() + str(do.getRandomNumber()) do.createObject("Program", title, "checked") do.verifyObjectIsCreatedinLHN("Program", title) do.assertEqual(1, do.countOfAnyObjectLHS("Program"), "Expect count to be 1 but don't see it.") # now log out and then log in with the new account and try to create a program do.selectMenuInTopRight("Logout") # Refresh the page do.refresh() # Log in with new user do.login(reader, password) print "Log in as : " + do.whoAmI() do.uncheckMyWorkBox() try: do.verifyObjectIsCreatedinLHN("Program", title) except: do.assertEqual(0, do.countOfAnyObjectLHS("Program"), "Expect count to be 0 but don't see it.") print "Good...private program should not be visible to reader role unless permitted."
def testCreatePersonProgramCreatorLogInOut(self): self.testname="TestCreatePersonProgramCreatorLogInOut" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() aEmail = "auto_email_" + str(do.getRandomNumber(65535)) + "@gmail.com" aName = do.getUniqueString("name") aCompany = do.getUniqueString("company") do.selectMenuInTopRight("Admin Dashboard") do.selectMenuItemInnerNavDashBoard("People") do.addPersonInAdminDB(aName, aEmail, aCompany) self.assertTrue(do.searchPersonInAdminDB(aName), "Fail searching for newly created person in Admin Dashboard.") # edit person authorization do.selectMenuItemInnerNavDashBoard("People") # on the roles selection do.clickOnEditAuthorization(aName) do.assignUserRole("ProgramCreator") # now log out and then log in with the new account and try to create a program oldEmail = "*****@*****.**" oldName = "Example User" absFilePath = expanduser("~") + "/ggrc-core/src/ggrc/login/noop.py" do.changeUsernameEmail(oldName, aName, oldEmail, aEmail, absFilePath) do.selectMenuInTopRight("Logout") # Refresh the page do.refresh() # Log in with new user do.login() print "Log in as : " + do.whoAmI() object_list = ["Program", "Workflow", "Audit", "Regulation", "Policy", "Standard", "Contract", "Clause", "Section", "Objective", "Control", "Person", "OrgGroup", "System","Process", "DataAsset", "Product", "Project", "Facility", "Market"] for object in object_list: # cannot create audit; it requires other non-system wide role if object == "Audit": do.assertFalse(do.doesCreateNewExist(object), "Create New button exists for " + str(object)) else: do.assertTrue(do.doesCreateNewExist(object), "Create New button does not exist for " + str(object)) # should be able to create a program object last_created_object_link = do.createObject("Program") object_name = str(do.util.getTextFromXpathString(last_created_object_link)).strip() self.assertTrue(do.partialMatch("program-auto-test", object_name), "Fail to match program name.") # Restore old login information do.changeUsernameEmail(aName, oldName, aEmail, oldEmail, absFilePath) do.selectMenuInTopRight("Logout")
def testCreateObjectsAsSetup(self): self.testname="TestCreateObjectsAsSetup" self.setup() object_list = ["Contract","Control","DataAsset","Facility","Market","Objective","OrgGroup","Policy","Process","Product","Program", "Project","Regulation","System","Standard","Clause"] util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() print "First: Log in as : " + do.whoAmI() for obj in object_list: count = 0; #initalize to 0 currentCount = do.countOfAnyObjectLHS(obj) if currentCount < 2: count = 2 - currentCount; while count > 0: do.createObject(obj) count = count - 1 # now log out and then log in with the new account and try to create a program do.selectMenuInTopRight("Logout") # Refresh the page do.refresh() # Log in with new user and create objects # This support other tests scripts checking for objects created by different users, and also object counts update do.login(config.creator2, config.same_password) print "Second: Log in as : " + do.whoAmI() for obj in object_list: do.createObject(obj) # just create one more to test that contract count differ between "all objects" and "my objects" do.createObject("Contract")
def testCreatePrivateProgramReader(self): self.testname="TestCreatePrivateProgramReader" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() email = config.reader1 password = config.same_password private_prgm_1 = do.createPrivateProgramPermission(email, "", "ProgramReader") print private_prgm_1 # map any object so that we can check if read can see it or not do.mapAObjectLHN("Contract") # now log out and then log in with the ProgramReader user do.selectMenuInTopRight("Logout") do.refresh() # Log in with new user do.login(email, password) print "Log in as : " + do.whoAmI() do.assertEquals("Reader", do.getRoleLabelInTopRight(), "Label does not says 'Reader'.") do.selectMenuInTopRight("My Work") # verify that user can see program tab and some programs; by seeing counts do.selectInnerNavTab("program") count = do.countOfAnyObjectInWidget("Program") do.assertGreater(count, 0, "Fail because count is expected to be non-zero if programs indeed exist.") # and being able to navigate to the expanded program row index = do.expandItemWidget("program", private_prgm_1) do.clickViewProgram("program", index) # can see mapped objects do.selectInnerNavTab("contract") count = do.countOfAnyObjectInWidget("Contract") do.assertGreater(count, 0, "Fail because count is expected to be non-zero if programs indeed exist.") # map link and edit authorization link should not exist do.selectInnerNavTab("person") do.assertFalse(do.isMapLinkPresent("person"), "Expect map link not present since it's a ProgramReader role.") do.assertFalse(do.isEditAuthorizationPresent(), "Expect Edit Authorization link not present since it's a ProgramReader role.") # go to program info page do.selectInnerNavTab("program") do.assertFalse(do.isInfoPageEditLinkPresent(), "Expect Edit link not present since it's a ProgramReader role.") do.assertFalse(do.isSubmitForReviewPresent(), "Expect Submit For Review link not present since it's a ProgramReader role.")
def testCreatePersonNoAccessLogInOut(self): self.testname="TestCreatePersonNoAccessLogInOut" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() aEmail = "auto_email_" + str(do.getRandomNumber(65535)) + "@gmail.com" aName = do.getUniqueString("name") aCompany = do.getUniqueString("company") do.selectMenuInTopRight("Admin Dashboard") do.selectMenuItemInnerNavDashBoard("People") do.addPersonInAdminDB(aName, aEmail, aCompany) self.assertTrue(do.searchPersonInAdminDB(aName), "Fail searching for newly created person in Admin Dashboard.") # edit person authorization do.selectMenuItemInnerNavDashBoard("People") # on the roles selection do.clickOnEditAuthorization(aName) do.assignUserRole("No access") # now log out and then log in with the new account and try to create a program oldEmail = "*****@*****.**" oldName = "Example User" absFilePath = expanduser("~") + "/ggrc-core/src/ggrc/login/noop.py" do.changeUsernameEmail(oldName, aName, oldEmail, aEmail, absFilePath) do.selectMenuInTopRight("Logout") # Refresh the page do.refresh() # Log in with new user do.login() print "Log in as : " + do.whoAmI() object_list = ["Program", "Task", "Audit", "Regulation", "Policy", "Standard", "Contract", "Clause", "Section", "Objective", "Control", "Person", "OrgGroup", "System","Process", "DataAsset", "Product", "Project", "Facility", "Market"] # no Create New occurs for object in object_list: do.navigateLHSMenu4NoAccess(object) do.assertFalse(do.doesThisElementExist(str(Elements.left_nav_object_section_add_button).replace("OBJECT", object), 8)) # Restore old login information do.changeUsernameEmail(aName, oldName, aEmail, oldEmail, absFilePath) do.selectMenuInTopRight("Logout")
def testPersonCreate(self): self.testname="TestPersonCreate" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() print "Log in as : " + do.whoAmI() number = str(do.getRandomNumber()) aEmail = "auto_email_" + number + "@gmail.com" aName = do.getUniqueString("name") aCompany = do.getUniqueString("company") do.createPersonLHN(aName, aEmail, aCompany)
def testCreatePersonObjectEditorLogInOut(self): self.testname="TestCreatePersonObjectEditorLogInOut" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() # ***************************** run this block of codes if run locally ***************************** if "localhost" in config.url: print "Executing the block of codes locally ..." aEmail = "auto_email_" + str(do.getRandomNumber(65535)) + "@gmail.com" aName = do.getUniqueString("name") aCompany = do.getUniqueString("company") do.selectMenuInTopRight("Admin Dashboard") do.selectMenuItemInnerNavDashBoard("People") do.addPersonInAdminDB(aName, aEmail, aCompany) self.assertTrue(do.searchPersonInAdminDB(aName), "Fail searching for newly created person in Admin Dashboard.") # edit person authorization do.selectMenuItemInnerNavDashBoard("People") # on the roles selection do.clickOnEditAuthorization(aName) do.assignUserRole("ObjectEditor") # now log out and then log in with the new account and try to create a program oldEmail = "Example user" oldName = "*****@*****.**" absFilePath = expanduser("~") + "/ggrc-core/src/ggrc/login/noop.py" do.changeUsernameEmail(oldName, aName, oldEmail, aEmail, absFilePath) do.selectMenuInTopRight("Logout") # Refresh the page do.refresh() # Log in with new user do.login() print "Log in as : " + do.whoAmI() object_list = ["Workflow", "Vendor", "Regulation", "Policy", "Standard", "Contract", "Clause", "Section", "Section", "Objective", "Control", "Person", "OrgGroup", "System","Process", "DataAsset", "Product", "Project", "Facility", "Market", "Program", "Audit"] # since it's an object editor role, the Create New button won't show for certain types for object in object_list: if object=="Program" or object=="Audit": do.assertFalse(do.doesCreateNewExist(object), "Create New button exists for " + str(object)) else: do.assertTrue(do.doesCreateNewExist(object), "Create New button does not exist for " + str(object)) # should be able to create an object that is not Program or Audit last_created_object_link = do.createObject("Contract") object_name = str(do.util.getTextFromXpathString(last_created_object_link)).strip() self.assertTrue(do.partialMatch("contract-auto-test", object_name), "Fail to match contract name.") # Restore old login information do.changeUsernameEmail(aName, oldName, aEmail, oldEmail, absFilePath) do.selectMenuInTopRight("Logout") # ******************* execute this else block of codes if not run locally ******************* else: print "Executing the block of codes for non-local ..." aEmail = config.editor2 aName = do.getUniqueString("name") aCompany = do.getUniqueString("company") do.selectMenuInTopRight("Admin Dashboard") do.selectMenuItemInnerNavDashBoard("People") do.addPersonInAdminDB(aName, aEmail, aCompany) self.assertTrue(do.searchPersonInAdminDB(aName), "Fail searching for newly created person in Admin Dashboard.") # edit person authorization do.selectMenuItemInnerNavDashBoard("People") # on the roles selection do.clickOnEditAuthorization(aName) do.assignUserRole("ObjectEditor") # now log out and then log in with the new account and try to create a program do.selectMenuInTopRight("Logout") # Refresh the page do.refresh() # Log in with new user do.login(aEmail, config.password) print "Log in as : " + do.whoAmI() object_list = ["Workflow", "Vendor", "Regulation", "Policy", "Standard", "Contract", "Clause", "Section", "Section", "Objective", "Control", "Person", "OrgGroup", "System","Process", "DataAsset", "Product", "Project", "Facility", "Market", "Program", "Audit"] # since it's an object editor role, the Create New button won't show for certain types for object in object_list: do.ensureLHNSectionExpanded(object) if object=="Program" or object=="Audit": do.assertFalse(do.doesCreateNewExist(object), "Create New button exists for " + str(object)) else: do.assertTrue(do.doesCreateNewExist(object), "Create New button does not exist for " + str(object)) # should be able to create an object that is not Program or Audit last_created_object_link = do.createObject("Contract") object_name = str(do.util.getTextFromXpathString(last_created_object_link)).strip() self.assertTrue(do.partialMatch("contract-auto-test", object_name), "Fail to match contract name.") if "localhost" in config.url: # Restore old login information do.changeUsernameEmail(aName, oldName, aEmail, oldEmail, absFilePath) do.selectMenuInTopRight("Logout")
def testCreatePersonReaderLogInOut(self): self.testname="TestCreatePersonReaderLogInOut" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() # run this block of codes if run locally if "localhost" in config.url: print "Executing the block of codes locally ..." aEmail = "auto_email_" + str(do.getRandomNumber(65535)) + "@gmail.com" aName = do.getUniqueString("name") aCompany = do.getUniqueString("company") do.selectMenuInTopRight("Admin Dashboard") do.selectMenuItemInnerNavDashBoard("People") do.addPersonInAdminDB(aName, aEmail, aCompany) self.assertTrue(do.searchPersonInAdminDB(aName), "Fail searching for newly created person in Admin Dashboard.") # edit person authorization do.selectMenuItemInnerNavDashBoard("People") # on the roles selection do.clickOnEditAuthorization(aName) do.assignUserRole("Reader") # now log out and then log in with the new account and try to create a program oldEmail = "*****@*****.**" oldName = "Example User" absFilePath = expanduser("~") + "/ggrc-core/src/ggrc/login/noop.py" do.changeUsernameEmail(oldName, aName, oldEmail, aEmail, absFilePath) do.selectMenuInTopRight("Logout") # Refresh the page do.refresh() # Log in with new user do.login() print "Log in as : " + do.whoAmI() object_list = ["Vendor", "Regulation", "Policy", "Standard", "Contract", "Clause", "Section", "Section", "Objective", "Control", "Person", "OrgGroup", "System","Process", "DataAsset", "Product", "Project", "Facility", "Market", "Program", "Audit"] # since it's a reader role, the Create New button won't show for object in object_list: do.assertFalse(do.doesCreateNewExist(object), "Create New button exists for " + str(object)) print "hi" # Restore old login information do.changeUsernameEmail(aName, oldName, aEmail, oldEmail, absFilePath) do.selectMenuInTopRight("Logout") else: print "Executing the block of codes for non-local ..." aEmail = config.reader2 aName = do.getUniqueString("name") aCompany = do.getUniqueString("company") do.selectMenuInTopRight("Admin Dashboard") do.selectMenuItemInnerNavDashBoard("People") do.addPersonInAdminDB(aName, aEmail, aCompany) self.assertTrue(do.searchPersonInAdminDB(aName), "Fail searching for newly created person in Admin Dashboard.") # edit person authorization do.selectMenuItemInnerNavDashBoard("People") # on the roles selection do.clickOnEditAuthorization(aName) do.assignUserRole("Reader") # now log out and then log in with the new account and try to create a program do.selectMenuInTopRight("Logout") # Refresh the page do.refresh() # Log in with new user do.login(aEmail, config.same_password) print "Log in as : " + do.whoAmI() # Workflow is left out on purpose because Create New is there but reader can't create object anyway object_list = ["Vendor", "Regulation", "Policy", "Standard", "Contract", "Clause", "Section", "Section", "Objective", "Control", "Person", "OrgGroup", "System","Process", "DataAsset", "Product", "Project", "Facility", "Market", "Program", "Audit"] # since it's a reader role, the Create New button won't show for object in object_list: do.ensureLHNSectionExpanded(object) do.assertFalse(do.doesCreateNewExist(object), "Create New button exists for " + str(object))
def testCreatePersonAuthorizationLogInOut(self): self.testname="TestCreatePersonAuthorizationLogInOut" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() aEmail = "*****@*****.**" aName = do.getUniqueString("name") aCompany = do.getUniqueString("company") role = "ProgramCreator" do.selectMenuInTopRight("Admin Dashboard") # verify people tab do.selectMenuItemInnerNavDashBoard("People") # SETUP: if that email is already used change it to something else do.zeroizeThePersonEmail(aEmail) # you can add a person do.addPersonInAdminDB(aName, aEmail, aCompany) # the Next and PREVIOUS page buttons work self.assertTrue(do.verifyPrevNextOperation("people"), "Fail verifying Prev and Next buttons.") # search or filter works self.assertTrue(do.searchPersonInAdminDB(aName), "Fail searching for newly created person in Admin Dashboard.") # edit person authorization do.clickOnEditAuthorization(aName) do.assignUserRole(role) # at this point, 2nd tier is expanded and it's the only row displayed... do.verifyPersonInfoOnSecondTier(aName, aEmail, aCompany, role) if 'local' not in config.url: do.selectMenuInTopRight("Logout") do.refresh() do.login(aEmail, config.password) self.assertEqual(aEmail, do.whoAmI(), "Expect: " + aEmail + ", but see: " + do.whoAmI()) # I can test login with the new user locally but not on on grc-test.appspot.com because it requires actual email # and that email has to be unique. I can't automatically create new fake email account with google that's fraud else: oldEmail = "*****@*****.**" oldName = "Example User" absFilePath = expanduser("~") + "/ggrc-core/src/ggrc/login/noop.py" do.changeUsernameEmail(oldName, aName, oldEmail, aEmail, absFilePath) # now log out and then log in with the new account and try to create a program do.selectMenuInTopRight("Logout") # Refresh the page do.refresh() # Log back in do.login() print "Log in as : " + do.whoAmI() last_created_object_link = do.createObject("Program") object_name = str(do.util.getTextFromXpathString(last_created_object_link)).strip() self.assertTrue(do.partialMatch("program-auto-test", object_name), "Fail to match program name.") self.assertEqual(do.whoAmI(), aEmail, "Mismatched. I am: " + do.whoAmI() + ", " + "aEmail: " + aEmail) do.selectMenuInTopRight("Logout") # Restore old login information do.changeUsernameEmail(aName, oldName, aEmail, oldEmail, absFilePath)