Skip to content

Commit

Permalink
feat(CLI): --debug-auth flag
Browse files Browse the repository at this point in the history
* Allow to see all authentication related communication, similar to
  --debug flag otherwise.
* fixed broken generator when handling request value parsing.

Fixes #70
  • Loading branch information
Byron committed Apr 21, 2015
1 parent 159c659 commit 03f35bd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
3 changes: 3 additions & 0 deletions src/mako/cli/lib/docopt.mako
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,8 @@ Configuration:
--debug
Output all server communication to standard error. `tx` and `rx` are placed into
the same stream.
--debug-auth
Output all communication related to authentication to standard error. `tx` and `rx` are placed into
the same stream.
");
</%def>
34 changes: 19 additions & 15 deletions src/mako/cli/lib/engine.mako
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,15 @@ self.opt.${cmd_ident(method)} {
}
};
let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
hyper::Client::new(),
JsonTokenStorage {
program_name: "${util.program_name()}",
db_dir: config_dir.clone(),
}, None);
let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate,
${self._debug_client('debug_auth') | indent_all_but_first_by(10)},
JsonTokenStorage {
program_name: "${util.program_name()}",
db_dir: config_dir.clone(),
}, None);
let client =
if opt.flag_debug {
hyper::Client::with_connector(mock::TeeConnector {
connector: hyper::net::HttpConnector(None)
})
} else {
hyper::Client::new()
};
${self._debug_client('debug') | indent_all_but_first_by(3)};
let engine = Engine {
opt: opt,
hub: ${hub_type_name}::new(client, auth),
Expand All @@ -140,6 +134,16 @@ self.opt.${cmd_ident(method)} {
}
</%def>

<%def name="_debug_client(flag_name)" buffered="True">\
if opt.flag_${flag_name} {
hyper::Client::with_connector(mock::TeeConnector {
connector: hyper::net::HttpConnector(None)
})
} else {
hyper::Client::new()
}\
</%def>

<%def name="_method_call_impl(c, resource, method)" buffered="True">\
<%
mc = new_method_context(resource, method, c)
Expand Down Expand Up @@ -247,7 +251,7 @@ ${value_unwrap}\
}
% endif # handle call parameters
% if mc.request_value:
${self._request_value_impl(c, request_cli_schema)}\
${self._request_value_impl(c, request_cli_schema, request_prop_type)}\
% endif # handle struct parsing
% if mc.media_params:
let protocol =
Expand Down Expand Up @@ -319,7 +323,7 @@ if dry_run {
}\
</%def>

<%def name="_request_value_impl(c, request_cli_schema)">
<%def name="_request_value_impl(c, request_cli_schema, request_prop_type)">
<%
allow_optionals_fn = lambda s: is_schema_with_optionals(schema_markers(s, c, transitive=False))
Expand Down

0 comments on commit 03f35bd

Please sign in to comment.