summaryrefslogtreecommitdiff
path: root/test-credential.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-12-19 16:05:16 -0800
committerJunio C Hamano <gitster@pobox.com>2011-12-19 16:05:16 -0800
commit367d20ec6b9e8e297537f665fb528346bd0aff27 (patch)
treebce97747bf55c8b3adffa0a058984aba5ea3225f /test-credential.c
parentd16520499d2652b5b59dfb25f9cf2d56a4c6913a (diff)
parent861444f6d702b15713d0875ce9dc5aff64885fba (diff)
downloadgit-367d20ec6b9e8e297537f665fb528346bd0aff27.tar.gz
Merge branch 'jk/credentials'
* jk/credentials: t: add test harness for external credential helpers credentials: add "store" helper strbuf: add strbuf_add*_urlencode Makefile: unix sockets may not available on some platforms credentials: add "cache" helper docs: end-user documentation for the credential subsystem credential: make relevance of http path configurable credential: add credential.*.username credential: apply helper config http: use credential API to get passwords credential: add function for parsing url components introduce credentials API t5550: fix typo test-lib: add test_config_global variant Conflicts: strbuf.c
Diffstat (limited to 'test-credential.c')
-rw-r--r--test-credential.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/test-credential.c b/test-credential.c
new file mode 100644
index 0000000000..dee200e7f2
--- /dev/null
+++ b/test-credential.c
@@ -0,0 +1,38 @@
+#include "cache.h"
+#include "credential.h"
+#include "string-list.h"
+
+static const char usage_msg[] =
+"test-credential <fill|approve|reject> [helper...]";
+
+int main(int argc, const char **argv)
+{
+ const char *op;
+ struct credential c = CREDENTIAL_INIT;
+ int i;
+
+ op = argv[1];
+ if (!op)
+ usage(usage_msg);
+ for (i = 2; i < argc; i++)
+ string_list_append(&c.helpers, argv[i]);
+
+ if (credential_read(&c, stdin) < 0)
+ die("unable to read credential from stdin");
+
+ if (!strcmp(op, "fill")) {
+ credential_fill(&c);
+ if (c.username)
+ printf("username=%s\n", c.username);
+ if (c.password)
+ printf("password=%s\n", c.password);
+ }
+ else if (!strcmp(op, "approve"))
+ credential_approve(&c);
+ else if (!strcmp(op, "reject"))
+ credential_reject(&c);
+ else
+ usage(usage_msg);
+
+ return 0;
+}