Skip to content

Commit 8e705c8

Browse files
committed
DataSourceMaaS: add test code for the oauth path
This adds to the 'main' in cloudinit/DataSourceMaaS.py a method for testing oauth_headers.
1 parent 3703ed7 commit 8e705c8

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

cloudinit/DataSourceMaaS.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,27 @@ def get_datasource_list(depends):
245245

246246
if __name__ == "__main__":
247247
def main():
248+
"""
249+
Call with single argument of directory or http or https url.
250+
If url is given additional arguments are allowed, which will be
251+
interpreted as consumer_key, token_key, token_secret, consumer_secret
252+
"""
248253
import sys
249254
import pprint
250255
seed = sys.argv[1]
251256
if seed.startswith("http://") or seed.startswith("https://"):
252-
(userdata, metadata) = read_maas_seed_url(seed)
257+
def my_headers(url):
258+
headers = oauth_headers(url, c_key, t_key, t_sec, c_sec)
259+
print "%s\n %s\n" % (url, headers)
260+
return headers
261+
cb = None
262+
(c_key, t_key, t_sec, c_sec) = (sys.argv + ["", "", "", ""])[2:6]
263+
if c_key:
264+
print "oauth headers (%s)" % str((c_key, t_key, t_sec, c_sec,))
265+
(userdata, metadata) = read_maas_seed_url(seed, my_headers)
266+
else:
267+
(userdata, metadata) = read_maas_seed_url(seed)
268+
253269
else:
254270
(userdata, metadata) = read_maas_seed_dir(seed)
255271

0 commit comments

Comments
 (0)