예제 #1
0
    def testClosingOneNotificationLeavesAnotherIntact(self):
        with self.ACLChecksDisabled():
            with aff4.FACTORY.Create(
                    aff4.GlobalNotificationStorage.DEFAULT_PATH,
                    aff4_type="GlobalNotificationStorage",
                    mode="rw",
                    token=self.token) as storage:
                storage.AddNotification(
                    rdfvalue.GlobalNotification(
                        type=rdfvalue.GlobalNotification.Type.ERROR,
                        header="Oh no, we're doomed!",
                        content="Houston, Houston, we have a prob...",
                        link="http://www.google.com"))
                storage.AddNotification(
                    rdfvalue.GlobalNotification(
                        type=rdfvalue.GlobalNotification.Type.INFO,
                        header="Nothing to worry about!",
                        link="http://www.google.com"))

        self.Open("/")
        self.WaitUntil(self.IsTextPresent,
                       "Houston, Houston, we have a prob...")

        self.Click("css=#global-notification .alert-error button.close")
        self.WaitUntilNot(self.IsTextPresent,
                          "Houston, Houston, we have a prob...")
        self.WaitUntil(self.IsTextPresent, "Nothing to worry about!")

        self.Open("/")
        self.WaitUntil(self.IsTextPresent, "Nothing to worry about!")
        self.assertFalse(
            self.IsTextPresent("Houston, Houston, we have a prob..."))
예제 #2
0
    def testNewNotificationReplacesPreviousNotificationOfTheSameType(self):
        with self.ACLChecksDisabled():
            with aff4.FACTORY.Create(
                    aff4.GlobalNotificationStorage.DEFAULT_PATH,
                    aff4_type="GlobalNotificationStorage",
                    mode="rw",
                    token=self.token) as storage:
                storage.AddNotification(
                    rdfvalue.GlobalNotification(
                        type=rdfvalue.GlobalNotification.Type.ERROR,
                        header="Oh no, we're doomed!",
                        content="Houston, Houston, we have a prob...",
                        link="http://www.google.com"))

        self.Open("/")
        self.WaitUntil(self.IsTextPresent,
                       "Houston, Houston, we have a prob...")

        with self.ACLChecksDisabled():
            with aff4.FACTORY.Create(
                    aff4.GlobalNotificationStorage.DEFAULT_PATH,
                    aff4_type="GlobalNotificationStorage",
                    mode="rw",
                    token=self.token) as storage:
                storage.AddNotification(
                    rdfvalue.GlobalNotification(
                        type=rdfvalue.GlobalNotification.Type.ERROR,
                        content="Too late to do anything!",
                        link="http://www.google.com"))

        self.Open("/")
        self.WaitUntil(self.IsTextPresent, "Too late to do anything!")
        self.assertFalse(
            self.IsTextPresent("Houston, Houston, we have a prob..."))
예제 #3
0
    def testGlobalNotificationDisappearsAfterClosing(self):
        with self.ACLChecksDisabled():
            with aff4.FACTORY.Create(
                    aff4.GlobalNotificationStorage.DEFAULT_PATH,
                    aff4_type="GlobalNotificationStorage",
                    mode="rw",
                    token=self.token) as storage:
                storage.AddNotification(
                    rdfvalue.GlobalNotification(
                        type=rdfvalue.GlobalNotification.Type.ERROR,
                        header="Oh no, we're doomed!",
                        content="Houston, Houston, we have a prob...",
                        link="http://www.google.com"))

        self.Open("/")
        self.WaitUntil(self.IsTextPresent,
                       "Houston, Houston, we have a prob...")

        self.Click("css=#global-notification button.close")
        self.WaitUntilNot(self.IsTextPresent,
                          "Houston, Houston, we have a prob...")

        self.Open("/")
        self.WaitUntil(self.IsElementPresent, "client_query")
        self.WaitUntilNot(self.IsTextPresent,
                          "Houston, Houston, we have a prob...")
예제 #4
0
파일: users_test.py 프로젝트: mikeatm/grr
  def testNotificationIsReturnedWhenItIsSet(self):
    with aff4.FACTORY.Create(aff4.GlobalNotificationStorage.DEFAULT_PATH,
                             aff4_type="GlobalNotificationStorage", mode="rw",
                             token=self.token) as storage:
      storage.AddNotification(rdfvalue.GlobalNotification(
          type=rdfvalue.GlobalNotification.Type.ERROR, header="foo",
          content="bar", link="http://www.google.com"))

    notifications = self.user.GetPendingGlobalNotifications()
    self.assertTrue(notifications)
    self.assertEqual(len(notifications), 1)
    self.assertEqual(notifications[0].header, "foo")
    self.assertEqual(notifications[0].content, "bar")
예제 #5
0
    def testNotificationsOfDifferentTypesAreShownTogether(self):
        with self.ACLChecksDisabled():
            with aff4.FACTORY.Create(
                    aff4.GlobalNotificationStorage.DEFAULT_PATH,
                    aff4_type="GlobalNotificationStorage",
                    mode="rw",
                    token=self.token) as storage:
                storage.AddNotification(
                    rdfvalue.GlobalNotification(
                        type=rdfvalue.GlobalNotification.Type.ERROR,
                        header="Oh no, we're doomed!",
                        content="Houston, Houston, we have a prob...",
                        link="http://www.google.com"))
                storage.AddNotification(
                    rdfvalue.GlobalNotification(
                        type=rdfvalue.GlobalNotification.Type.INFO,
                        header="Nothing to worry about!",
                        link="http://www.google.com"))

        self.Open("/")
        self.WaitUntil(self.IsTextPresent,
                       "Houston, Houston, we have a prob...")
        self.WaitUntil(self.IsTextPresent, "Nothing to worry about!")
예제 #6
0
파일: users_test.py 프로젝트: mikeatm/grr
  def testNotificationIsNotReturnedWhenItExpires(self):
    with test_lib.FakeTime(100):
      with aff4.FACTORY.Create(aff4.GlobalNotificationStorage.DEFAULT_PATH,
                               aff4_type="GlobalNotificationStorage", mode="rw",
                               token=self.token) as storage:
        storage.AddNotification(rdfvalue.GlobalNotification(
            type=rdfvalue.GlobalNotification.Type.ERROR, header="foo",
            content="bar", duration=rdfvalue.Duration("1h"),))

    with test_lib.FakeTime(101):
      notifications = self.user.GetPendingGlobalNotifications()
      self.assertTrue(notifications)

    with test_lib.FakeTime(100 + 3600 + 1):
      notifications = self.user.GetPendingGlobalNotifications()
      self.assertFalse(notifications)