Example #1
0
    def test_add_expires_option(self):
        options = pwsafecli.parse_commandline(self.parsers,
                                             ["unittest", "add", "--file", "foo", "--title", "blah", "--username", "me", "--group", "foo.bar.baz", "--password", "secret", "--expires", "2012-01-01 00:00"])
        pwsafecli.add_validator(options)

        with AssertRaises(pwsafecli.PWSafeCLIValidationError) as cm:
            options = pwsafecli.parse_commandline(self.parsers,
                                                 ["unittest", "add", "--file", "foo", "--title", "blah", "--username", "me", "--group", "foo.bar.baz", "--password", "secret", "--expires", "2012-01-01 00:00:00 MDT"])
Example #2
0
    def test_get_display_option(self):
        options = pwsafecli.parse_commandline(self.parsers, "unittest get --file foo --uuid f2dee5f8-e964-402f-9fe7-78bd2b5cba2e --display username,password".split())
        pwsafecli.get_validator(options)

        options = pwsafecli.parse_commandline(self.parsers, "unittest get --file foo --uuid f2dee5f8-e964-402f-9fe7-78bd2b5cba2e --display username,password,uuid".split())
        pwsafecli.get_validator(options)

        options = pwsafecli.parse_commandline(self.parsers, "unittest get --file foo --uuid f2dee5f8-e964-402f-9fe7-78bd2b5cba2e --display username,password,uuid,missing".split())

        with AssertRaises(pwsafecli.PWSafeCLIValidationError) as cm:
            pwsafecli.get_validator(options)
Example #3
0
    def test_add_expires_option(self):
        options = pwsafecli.parse_commandline(self.parsers, [
            "unittest", "add", "--file", "foo", "--title", "blah",
            "--username", "me", "--group", "foo.bar.baz", "--password",
            "secret", "--expires", "2012-01-01 00:00"
        ])
        pwsafecli.add_validator(options)

        with AssertRaises(pwsafecli.PWSafeCLIValidationError) as cm:
            options = pwsafecli.parse_commandline(self.parsers, [
                "unittest", "add", "--file", "foo", "--title", "blah",
                "--username", "me", "--group", "foo.bar.baz", "--password",
                "secret", "--expires", "2012-01-01 00:00:00 MDT"
            ])
Example #4
0
 def test_add_missing_password(self):
     options = pwsafecli.parse_commandline(
         self.parsers,
         "unittest add --file foo --title blah --username me --group foo.bar.baz"
         .split())
     with AssertRaises(pwsafecli.PWSafeCLIValidationError) as cm:
         pwsafecli.add_validator(options)
Example #5
0
 def test_get_missing_options(self):
     for cmdline in ("unittest get --file foo", "unittest get --file foo --email foo@bar"):
         print cmdline
         options = pwsafecli.parse_commandline(self.parsers,
                                              cmdline.split())
         with AssertRaises(pwsafecli.PWSafeCLIValidationError):
             pwsafecli.get_validator(options)
Example #6
0
 def test_get_missing_options(self):
     for cmdline in ("unittest get --file foo",
                     "unittest get --file foo --email foo@bar"):
         print(cmdline)
         options = pwsafecli.parse_commandline(self.parsers,
                                               cmdline.split())
         with AssertRaises(pwsafecli.PWSafeCLIValidationError):
             pwsafecli.get_validator(options)
Example #7
0
    def test_get_display_option(self):
        options = pwsafecli.parse_commandline(
            self.parsers,
            "unittest get --file foo --uuid f2dee5f8-e964-402f-9fe7-78bd2b5cba2e --display username,password"
            .split())
        pwsafecli.get_validator(options)

        options = pwsafecli.parse_commandline(
            self.parsers,
            "unittest get --file foo --uuid f2dee5f8-e964-402f-9fe7-78bd2b5cba2e --display username,password,uuid"
            .split())
        pwsafecli.get_validator(options)

        options = pwsafecli.parse_commandline(
            self.parsers,
            "unittest get --file foo --uuid f2dee5f8-e964-402f-9fe7-78bd2b5cba2e --display username,password,uuid,missing"
            .split())

        with AssertRaises(pwsafecli.PWSafeCLIValidationError) as cm:
            pwsafecli.get_validator(options)
Example #8
0
 def test_add_filename_no_options(self):
     options = pwsafecli.parse_commandline(
         self.parsers, "unittest add --file foo".split())
     with AssertRaises(pwsafecli.PWSafeCLIValidationError) as cm:
         pwsafecli.add_validator(options)
Example #9
0
 def test_no_action_help(self):
     with AssertRaises(pwsafecli.PWSafeCLIValidationError) as cm:
         pwsafecli.parse_commandline(self.parsers,
                                     "unittest --help".split())
Example #10
0
 def test_update_missing_uuid(self):
     options = pwsafecli.parse_commandline(
         self.parsers, "unittest update --file foo --username test".split())
     with AssertRaises(pwsafecli.PWSafeCLIValidationError) as cm:
         pwsafecli.update_validator(options)
Example #11
0
 def test_add_no_options(self):
     with AssertRaises(SystemExit) as cm:
         options = pwsafecli.parse_commandline(self.parsers,
                                              "unittest add".split())
Example #12
0
 def test_unknown_command(self):
     with AssertRaises(pwsafecli.PWSafeCLIValidationError) as cm:
         pwsafecli.parse_commandline(self.parsers,
                                    "unittest unknown".split())
Example #13
0
 def test_no_action_help(self):
     with AssertRaises(pwsafecli.PWSafeCLIValidationError) as cm:
         pwsafecli.parse_commandline(self.parsers, "unittest --help".split())
Example #14
0
 def test_no_action(self):
     with AssertRaises(pwsafecli.PWSafeCLIValidationError) as cm:
         pwsafecli.parse_commandline(self.parsers, ['unittest',])
Example #15
0
 def test_update_missing_uuid(self):
     options = pwsafecli.parse_commandline(self.parsers,
                                          "unittest update --file foo --username test".split())
     with AssertRaises(pwsafecli.PWSafeCLIValidationError) as cm:
         pwsafecli.update_validator(options)
Example #16
0
 def test_init_options(self):
     options = pwsafecli.parse_commandline(self.parsers, "unittest init --file foo".split())
     pwsafecli.init_validator(options)
Example #17
0
 def test_init_options(self):
     options = pwsafecli.parse_commandline(
         self.parsers, "unittest init --file foo".split())
     pwsafecli.init_validator(options)
Example #18
0
 def test_add_filename_no_options(self):
     options = pwsafecli.parse_commandline(self.parsers,
                                          "unittest add --file foo".split())
     with AssertRaises(pwsafecli.PWSafeCLIValidationError) as cm:
         pwsafecli.add_validator(options)
Example #19
0
 def test_no_action(self):
     with AssertRaises(pwsafecli.PWSafeCLIValidationError) as cm:
         pwsafecli.parse_commandline(self.parsers, [
             'unittest',
         ])
Example #20
0
 def test_add_missing_password(self):
     options = pwsafecli.parse_commandline(self.parsers,
                                          "unittest add --file foo --title blah --username me --group foo.bar.baz".split())
     with AssertRaises(pwsafecli.PWSafeCLIValidationError) as cm:
         pwsafecli.add_validator(options)
Example #21
0
 def test_unknown(self):
     with AssertRaises(pwsafecli.PWSafeCLIValidationError) as cm:
         pwsafecli.parse_commandline(self.parsers,
                                     "unittest --what".split())
Example #22
0
 def test_add_no_options(self):
     with AssertRaises(SystemExit) as cm:
         options = pwsafecli.parse_commandline(self.parsers,
                                               "unittest add".split())