/mandos/trunk

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

« back to all changes in this revision

Viewing changes to mandos-ctl

  • Committer: Teddy Hogeborn
  • Date: 2019-03-07 20:37:15 UTC
  • Revision ID: teddy@recompile.se-20190307203715-nilyilg9adr8q7bm
mandos-ctl: Add tests for short options

* mandos-ctl
  (Test_command_from_options.test_print_table_verbose_short): New.
  (Test_command_from_options.test_enable_short): - '' -
  (Test_command_from_options.test_disable_short): - '' -
  (Test_command_from_options.test_bump_timeout_short): - '' -
  (Test_command_from_options.test_remove_short): - '' -
  (Test_command_from_options.test_checker_short): - '' -
  (Test_command_from_options.test_timeout_short): - '' -
  (Test_command_from_options.test_interval_short): - '' -
  (Test_command_from_options.test_host_short): - '' -
  (Test_command_from_options.test_secret_devnull_short): - '' -
  (Test_command_from_options.test_secret_tempfile_short): - '' -
  (Test_command_from_options.test_approve_short): - '' -
  (Test_command_from_options.test_deny_short): - '' -
  (Test_command_from_options.test_is_enabled_short): - '' -

Show diffs side-by-side

added added

removed removed

Lines of Context:
1169
1169
        self.assert_command_from_args(["--verbose"], PrintTableCmd,
1170
1170
                                      verbose=True)
1171
1171
 
 
1172
    def test_print_table_verbose_short(self):
 
1173
        self.assert_command_from_args(["-v"], PrintTableCmd,
 
1174
                                      verbose=True)
 
1175
 
1172
1176
    def test_enable(self):
1173
1177
        self.assert_command_from_args(["--enable", "foo"], EnableCmd)
1174
1178
 
 
1179
    def test_enable_short(self):
 
1180
        self.assert_command_from_args(["-e", "foo"], EnableCmd)
 
1181
 
1175
1182
    def test_disable(self):
1176
1183
        self.assert_command_from_args(["--disable", "foo"],
1177
1184
                                      DisableCmd)
1178
1185
 
 
1186
    def test_disable_short(self):
 
1187
        self.assert_command_from_args(["-d", "foo"], DisableCmd)
 
1188
 
1179
1189
    def test_bump_timeout(self):
1180
1190
        self.assert_command_from_args(["--bump-timeout", "foo"],
1181
1191
                                      BumpTimeoutCmd)
1182
1192
 
 
1193
    def test_bump_timeout_short(self):
 
1194
        self.assert_command_from_args(["-b", "foo"], BumpTimeoutCmd)
 
1195
 
1183
1196
    def test_start_checker(self):
1184
1197
        self.assert_command_from_args(["--start-checker", "foo"],
1185
1198
                                      StartCheckerCmd)
1192
1205
        self.assert_command_from_args(["--remove", "foo"],
1193
1206
                                      RemoveCmd)
1194
1207
 
 
1208
    def test_remove_short(self):
 
1209
        self.assert_command_from_args(["-r", "foo"], RemoveCmd)
 
1210
 
1195
1211
    def test_checker(self):
1196
1212
        self.assert_command_from_args(["--checker", ":", "foo"],
1197
1213
                                      SetCheckerCmd, value_to_set=":")
1200
1216
        self.assert_command_from_args(["--checker", "", "foo"],
1201
1217
                                      SetCheckerCmd, value_to_set="")
1202
1218
 
 
1219
    def test_checker_short(self):
 
1220
        self.assert_command_from_args(["-c", ":", "foo"],
 
1221
                                      SetCheckerCmd, value_to_set=":")
 
1222
 
1203
1223
    def test_timeout(self):
1204
1224
        self.assert_command_from_args(["--timeout", "PT5M", "foo"],
1205
1225
                                      SetTimeoutCmd,
1206
1226
                                      value_to_set=300000)
1207
1227
 
 
1228
    def test_timeout_short(self):
 
1229
        self.assert_command_from_args(["-t", "PT5M", "foo"],
 
1230
                                      SetTimeoutCmd,
 
1231
                                      value_to_set=300000)
 
1232
 
1208
1233
    def test_extended_timeout(self):
1209
1234
        self.assert_command_from_args(["--extended-timeout", "PT15M",
1210
1235
                                       "foo"],
1216
1241
                                      SetIntervalCmd,
1217
1242
                                      value_to_set=120000)
1218
1243
 
 
1244
    def test_interval_short(self):
 
1245
        self.assert_command_from_args(["-i", "PT2M", "foo"],
 
1246
                                      SetIntervalCmd,
 
1247
                                      value_to_set=120000)
 
1248
 
1219
1249
    def test_approve_by_default(self):
1220
1250
        self.assert_command_from_args(["--approve-by-default", "foo"],
1221
1251
                                      ApproveByDefaultCmd)
1239
1269
                                       "foo"], SetHostCmd,
1240
1270
                                      value_to_set="foo.example.org")
1241
1271
 
 
1272
    def test_host_short(self):
 
1273
        self.assert_command_from_args(["-H", "foo.example.org",
 
1274
                                       "foo"], SetHostCmd,
 
1275
                                      value_to_set="foo.example.org")
 
1276
 
1242
1277
    def test_secret_devnull(self):
1243
1278
        self.assert_command_from_args(["--secret", os.path.devnull,
1244
1279
                                       "foo"], SetSecretCmd,
1253
1288
                                           "foo"], SetSecretCmd,
1254
1289
                                          value_to_set=value)
1255
1290
 
 
1291
    def test_secret_devnull_short(self):
 
1292
        self.assert_command_from_args(["-s", os.path.devnull, "foo"],
 
1293
                                      SetSecretCmd, value_to_set=b"")
 
1294
 
 
1295
    def test_secret_tempfile_short(self):
 
1296
        with tempfile.NamedTemporaryFile(mode="r+b") as f:
 
1297
            value = b"secret\0xyzzy\nbar"
 
1298
            f.write(value)
 
1299
            f.seek(0)
 
1300
            self.assert_command_from_args(["-s", f.name, "foo"],
 
1301
                                          SetSecretCmd,
 
1302
                                          value_to_set=value)
 
1303
 
1256
1304
    def test_approve(self):
1257
1305
        self.assert_command_from_args(["--approve", "foo"],
1258
1306
                                      ApproveCmd)
1259
1307
 
 
1308
    def test_approve_short(self):
 
1309
        self.assert_command_from_args(["-A", "foo"], ApproveCmd)
 
1310
 
1260
1311
    def test_deny(self):
1261
1312
        self.assert_command_from_args(["--deny", "foo"], DenyCmd)
1262
1313
 
 
1314
    def test_deny_short(self):
 
1315
        self.assert_command_from_args(["-D", "foo"], DenyCmd)
 
1316
 
1263
1317
    def test_dump_json(self):
1264
1318
        self.assert_command_from_args(["--dump-json"], DumpJSONCmd)
1265
1319
 
1267
1321
        self.assert_command_from_args(["--is-enabled", "foo"],
1268
1322
                                      IsEnabledCmd)
1269
1323
 
 
1324
    def test_is_enabled_short(self):
 
1325
        self.assert_command_from_args(["-V", "foo"], IsEnabledCmd)
 
1326
 
1270
1327
 
1271
1328
 
1272
1329
def should_only_run_tests():