/mandos/release

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/release

« back to all changes in this revision

Viewing changes to mandos-ctl

  • Committer: Teddy Hogeborn
  • Date: 2019-03-12 19:15:52 UTC
  • mto: This revision was merged to the branch mainline in revision 382.
  • Revision ID: teddy@recompile.se-20190312191552-f1di4dzya1pzxc9a
mandos-ctl: Refactor

* mandos-ctl (TestPrintTableCmd.test_verbose): Reformat for easier
                                               editing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
934
934
    def test_verbose(self):
935
935
        output = PrintTableCmd(verbose=True).output(
936
936
            self.clients.values())
937
 
        expected_output = "\n".join((
938
 
            # First line (headers)
939
 
            "Name   Enabled Timeout  Last Successful Check Created   "
940
 
            "          Interval Host            Key ID               "
941
 
            "                                            Fingerprint "
942
 
            "                             Check Is Running Last Enabl"
943
 
            "ed        Approval Is Pending Approved By Default Last A"
944
 
            "pproval Request Approval Delay Approval Duration Checker"
945
 
            "              Extended Timeout Expires             Last "
946
 
            "Checker Status",
947
 
            # Second line (client "foo")
948
 
            "foo    Yes     00:05:00 2019-02-03T00:00:00   2019-01-02"
949
 
            "T00:00:00 00:02:00 foo.example.org 92ed150794387c03ce684"
950
 
            "574b1139a6594a34f895daaaf09fd8ea90a27cddb12 778827225BA7"
951
 
            "DE539C5A7CFA59CFF7CDBD9A5920 No               2019-01-03"
952
 
            "T00:00:00 No                  Yes                       "
953
 
            "                00:00:00       00:00:01          fping -"
954
 
            "q -- %(host)s 00:15:00         2019-02-04T00:00:00 0    "
955
 
            "              ",
956
 
            # Third line (client "barbar")
957
 
            "barbar Yes     00:05:00 2019-02-04T00:00:00   2019-01-03"
958
 
            "T00:00:00 00:02:00 192.0.2.3       0558568eedd67d622f5c8"
959
 
            "3b35a115f796ab612cff5ad227247e46c2b020f441c 3E393AEAEFB8"
960
 
            "4C7E89E2F547B3A107558FCA3A27 Yes              2019-01-04"
961
 
            "T00:00:00 No                  No                  2019-0"
962
 
            "1-03T00:00:00   00:00:30       00:00:01          :      "
963
 
            "              00:15:00         2019-02-05T00:00:00 -2   "
964
 
            "              ",
965
 
        ))
 
937
        columns = (
 
938
            (
 
939
                "Name   ",
 
940
                "foo    ",
 
941
                "barbar ",
 
942
            ),(
 
943
                "Enabled ",
 
944
                "Yes     ",
 
945
                "Yes     ",
 
946
            ),(
 
947
                "Timeout  ",
 
948
                "00:05:00 ",
 
949
                "00:05:00 ",
 
950
            ),(
 
951
                "Last Successful Check ",
 
952
                "2019-02-03T00:00:00   ",
 
953
                "2019-02-04T00:00:00   ",
 
954
            ),(
 
955
                "Created             ",
 
956
                "2019-01-02T00:00:00 ",
 
957
                "2019-01-03T00:00:00 ",
 
958
            ),(
 
959
                "Interval ",
 
960
                "00:02:00 ",
 
961
                "00:02:00 ",
 
962
            ),(
 
963
                "Host            ",
 
964
                "foo.example.org ",
 
965
                "192.0.2.3       ",
 
966
            ),(
 
967
                ("Key ID                                             "
 
968
                 "              "),
 
969
                ("92ed150794387c03ce684574b1139a6594a34f895daaaf09fd8"
 
970
                 "ea90a27cddb12 "),
 
971
                ("0558568eedd67d622f5c83b35a115f796ab612cff5ad227247e"
 
972
                 "46c2b020f441c "),
 
973
            ),(
 
974
                "Fingerprint                              ",
 
975
                "778827225BA7DE539C5A7CFA59CFF7CDBD9A5920 ",
 
976
                "3E393AEAEFB84C7E89E2F547B3A107558FCA3A27 ",
 
977
            ),(
 
978
                "Check Is Running ",
 
979
                "No               ",
 
980
                "Yes              ",
 
981
            ),(
 
982
                "Last Enabled        ",
 
983
                "2019-01-03T00:00:00 ",
 
984
                "2019-01-04T00:00:00 ",
 
985
            ),(
 
986
                "Approval Is Pending ",
 
987
                "No                  ",
 
988
                "No                  ",
 
989
            ),(
 
990
                "Approved By Default ",
 
991
                "Yes                 ",
 
992
                "No                  ",
 
993
            ),(
 
994
                "Last Approval Request ",
 
995
                "                      ",
 
996
                "2019-01-03T00:00:00   ",
 
997
            ),(
 
998
                "Approval Delay ",
 
999
                "00:00:00       ",
 
1000
                "00:00:30       ",
 
1001
            ),(
 
1002
                "Approval Duration ",
 
1003
                "00:00:01          ",
 
1004
                "00:00:01          ",
 
1005
            ),(
 
1006
                "Checker              ",
 
1007
                "fping -q -- %(host)s ",
 
1008
                ":                    ",
 
1009
            ),(
 
1010
                "Extended Timeout ",
 
1011
                "00:15:00         ",
 
1012
                "00:15:00         ",
 
1013
            ),(
 
1014
                "Expires             ",
 
1015
                "2019-02-04T00:00:00 ",
 
1016
                "2019-02-05T00:00:00 ",
 
1017
            ),(
 
1018
                "Last Checker Status",
 
1019
                "0                  ",
 
1020
                "-2                 ",
 
1021
            )
 
1022
        )
 
1023
        num_lines = max(len(rows) for rows in columns)
 
1024
        expected_output = "\n".join("".join(rows[line]
 
1025
                                            for rows in columns)
 
1026
                                    for line in range(num_lines))
966
1027
        self.assertEqual(output, expected_output)
967
1028
    def test_one_client(self):
968
1029
        output = PrintTableCmd().output(self.one_client.values())