Esempio n. 1
0
 def test_parse_options_gets_secret_from_environment(self):
     """
     If the C{AWS_SECRET_ACCESS_KEY} environment variable is present, it
     will be used if the C{--secret} command-line argument isn't specified.
     """
     self.patch(os, "environ", {"AWS_SECRET_ACCESS_KEY": "secret"})
     options = parse_options([
         "txaws-discover", "--key", "key", "--endpoint", "endpoint",
         "--action", "action"])
     self.assertEqual({"key": "key", "secret": "secret",
                       "endpoint": "endpoint", "action": "action"},
                      options)
Esempio n. 2
0
 def test_parse_options_gets_key_from_environment(self):
     """
     If the C{AWS_ACCESS_KEY_ID} environment variable is present, it will
     be used if the C{--key} command-line argument isn't specified.
     """
     os.environ["AWS_ACCESS_KEY_ID"] = "key"
     options = parse_options([
         "txaws-discover", "--secret", "secret", "--endpoint", "endpoint",
         "--action", "action"])
     self.assertEqual({"key": "key", "secret": "secret",
                       "endpoint": "endpoint", "action": "action"},
                      options)
Esempio n. 3
0
 def test_parse_options_prefers_explicit_key(self):
     """
     If an explicit C{--key} command-line argument is specified it will be
     preferred over the value specified in the C{AWS_ACCESS_KEY_ID}
     environment variable.
     """
     self.patch(os, "environ", {"AWS_ACCESS_KEY_ID": "fail"})
     options = parse_options([
         "txaws-discover", "--key", "key", "--secret", "secret",
         "--endpoint", "endpoint", "--action", "action"])
     self.assertEqual({"key": "key", "secret": "secret",
                       "endpoint": "endpoint", "action": "action"},
                      options)
Esempio n. 4
0
 def test_parse_options(self):
     """
     L{parse_options} returns a C{dict} contains options parsed from the
     command-line.
     """
     options = parse_options([
         "txaws-discover", "--key", "key", "--secret", "secret",
         "--endpoint", "endpoint", "--action", "action",
         "--something.else", "something.else"])
     self.assertEqual({"key": "key", "secret": "secret",
                       "endpoint": "endpoint", "action": "action",
                       "something.else": "something.else"},
                      options)
Esempio n. 5
0
 def test_parse_options_prefers_explicit_endpoint(self):
     """
     If an explicit C{--endpoint} command-line argument is specified it
     will be preferred over the value specified in the C{AWS_ENDPOINT}
     environment variable.
     """
     os.environ["AWS_ENDPOINT"] = "fail"
     options = parse_options([
         "txaws-discover", "--key", "key", "--secret", "secret",
         "--endpoint", "endpoint", "--action", "action"])
     self.assertEqual({"key": "key", "secret": "secret",
                       "endpoint": "endpoint", "action": "action"},
                      options)
Esempio n. 6
0
 def test_parse_options_gets_key_from_environment(self):
     """
     If the C{AWS_ACCESS_KEY_ID} environment variable is present, it will
     be used if the C{--key} command-line argument isn't specified.
     """
     os.environ["AWS_ACCESS_KEY_ID"] = "key"
     options = parse_options([
         "txaws-discover", "--secret", "secret", "--endpoint", "endpoint",
         "--action", "action"
     ])
     self.assertEqual(
         {
             "key": "key",
             "secret": "secret",
             "endpoint": "endpoint",
             "action": "action"
         }, options)
Esempio n. 7
0
 def test_parse_options_gets_endpoint_from_environment(self):
     """
     If the C{AWS_ENDPOINT} environment variable is present, it will be
     used if the C{--endpoint} command-line argument isn't specified.
     """
     self.patch(os, "environ", {"AWS_ENDPOINT": "endpoint"})
     options = parse_options([
         "txaws-discover", "--key", "key", "--secret", "secret", "--action",
         "action"
     ])
     self.assertEqual(
         {
             "key": "key",
             "secret": "secret",
             "endpoint": "endpoint",
             "action": "action"
         }, options)
Esempio n. 8
0
 def test_parse_options_prefers_explicit_key(self):
     """
     If an explicit C{--key} command-line argument is specified it will be
     preferred over the value specified in the C{AWS_ACCESS_KEY_ID}
     environment variable.
     """
     os.environ["AWS_ACCESS_KEY_ID"] = "fail"
     options = parse_options([
         "txaws-discover", "--key", "key", "--secret", "secret",
         "--endpoint", "endpoint", "--action", "action"
     ])
     self.assertEqual(
         {
             "key": "key",
             "secret": "secret",
             "endpoint": "endpoint",
             "action": "action"
         }, options)
Esempio n. 9
0
 def test_parse_options(self):
     """
     L{parse_options} returns a C{dict} contains options parsed from the
     command-line.
     """
     options = parse_options([
         "txaws-discover", "--key", "key", "--secret", "secret",
         "--endpoint", "endpoint", "--action", "action", "--something.else",
         "something.else"
     ])
     self.assertEqual(
         {
             "key": "key",
             "secret": "secret",
             "endpoint": "endpoint",
             "action": "action",
             "something.else": "something.else"
         }, options)
Esempio n. 10
0
 def test_parse_options_prefers_explicit_endpoint(self):
     """
     If an explicit C{--endpoint} command-line argument is specified it
     will be preferred over the value specified in the C{AWS_ENDPOINT}
     environment variable.
     """
     self.patch(os, "environ", {"AWS_ENDPOINT": "fail"})
     options = parse_options([
         "txaws-discover", "--key", "key", "--secret", "secret",
         "--endpoint", "endpoint", "--action", "action"
     ])
     self.assertEqual(
         {
             "key": "key",
             "secret": "secret",
             "endpoint": "endpoint",
             "action": "action"
         }, options)