{"thread":{"id":"28475","subject":"credential helper tests","startedAt":"2011-09-23T22:15:13Z","lastAt":"2011-09-23T22:26:16Z","messageCount":2,"participants":["Jeff King","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"176104","messageId":"20110923221513.GA3087@sigill.intra.peff.net","threadId":"28475","inReplyTo":null,"subject":"credential helper tests","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-09-23T22:15:13Z","receivedAt":"2011-09-23T22:15:13Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"Since we've had a few credential helpers posted to the list recently, I\nreally want to try them all out. This can be a little bit tricky for\nautomated testing, though, for two reasons:\n\n  - they run on lots of platforms with lots of dependencies\n\n  - they interact with parts of the systems that are opaque to git. So\n    we can't make a test that reliably simulates \"and then the user\n    types 'foo' into a dialog box\" across all platforms.\n\nInstead, I came up with a separate test script that is intended to be\nrun interactively with the user. It runs the helpers through a battery\nof tests, and tells the user what to expect and what to input to any\ndialogs or prompts.\n\nI've run it already on the helpers I've written. I plan on running it\nwith the helpers that have been posted, as well. But I also wanted to\nmake it public so that authors could use it as a development aid.\n\nIt's not integrated with git's tests at all. In theory it could be part\nof t/, but disabled unless the user asks for it. However, I'm not sure\nthat makes much sense. It's intended to test helpers that aren't\nnecessarily even shipped with git, and wouldn't necessarily even need\ngit to run.\n\nAlso, it is by no means a strict set of tests. A helper that did not\nstore credentials, but only presented dialogs in a different way, or one\nthat was about accessing a read-only store of credentials would not\npass. So think of it as a best-practices guide and an exercise script\nfor certain types of helpers, not necessarily as a set of tests that\nmust be passed.\n\n-- >8 --\n#!/bin/sh\n\n# e.g., \"cache\"\nhelper=$1\n\nsay() {\n  echo >&2 \"==> $*\"\n}\n\ncheck() {\n  for i in username password; do\n    v=$1; shift\n    case \"$v\" in\n    auto:*)\n      v=${v#auto:}\n      say \"  $i should be automatic ($v)\"\n      ;;\n    *)\n      say \"  Input $i=$v\"\n      ;;\n    esac\n    echo $i=$v\n  done >expect\n  if git credential-$helper \"$@\" >actual &&\n     git --no-pager diff --no-index expect actual; then\n    say OK\n  else\n    say FAIL\n  fi\n}\n\nreject() {\n  git credential-$helper --reject \"$@\" || exit 1\n}\n\nsay 'Cleaning old invocations...'\nreject --unique=https:foo.tld\nreject --unique=https:bar.tld\n\nsay 'No context (initial, should ask)'\ncheck user pass\nsay 'No context (again, should ask)'\ncheck user2 pass2\n\nsay 'Context foo.tld (initial, should ask)'\ncheck foo-user foo-pass --unique=https:foo.tld\nsay 'Context foo.tld (again)'\ncheck auto:foo-user auto:foo-pass --unique=https:foo.tld\n\nsay 'Context bar.tld (should ask)'\ncheck bar-user bar-pass --unique=https:bar.tld\nsay 'Context bar.tld (again)'\ncheck auto:bar-user auto:bar-pass --unique=https:bar.tld\nsay 'Context foo.tld (should still remember)'\ncheck auto:foo-user auto:foo-pass --unique=https:foo.tld\n\nsay 'Forget foo.tld (should ask)'\nreject --unique=https:foo.tld\ncheck foo-user2 foo-pass2 --unique=https:foo.tld\nsay 'Context foo.tld (again)'\ncheck auto:foo-user2 auto:foo-pass2 --unique=https:foo.tld\nsay 'Context bar.tld (should still remember)'\ncheck auto:bar-user auto:bar-pass --unique=https:bar.tld\n\nsay 'Alternate user at foo.tld (should ask)'\ncheck auto:foo-user3 foo-pass3 --unique=https:foo.tld --username=foo-user3\nsay 'Remember new user'\ncheck auto:foo-user3 auto:foo-pass3 --unique=https:foo.tld --username=foo-user3\nsay 'Remember old user'\ncheck auto:foo-user2 auto:foo-pass2 --unique=https:foo.tld --username=foo-user2\nsay 'Forget new user (should ask)'\nreject --unique=https:foo.tld --username=foo-user3\ncheck auto:foo-user3 foo-pass4 --unique=https:foo.tld --username=foo-user3\nsay 'New user is now remembered'\ncheck auto:foo-user3 auto:foo-pass4 --unique=https:foo.tld --username=foo-user3\nsay 'Remember old user'\ncheck auto:foo-user2 auto:foo-pass2 --unique=https:foo.tld --username=foo-user2\n"},{"id":"176106","messageId":"7v7h4yuc8n.fsf@alter.siamese.dyndns.org","threadId":"28475","inReplyTo":"20110923221513.GA3087@sigill.intra.peff.net","subject":"Re: credential helper tests","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-09-23T22:26:16Z","receivedAt":"2011-09-23T22:26:16Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> Since we've had a few credential helpers posted to the list recently, I\n> really want to try them all out. This can be a little bit tricky for\n> automated testing, though, for two reasons:\n>\n>   - they run on lots of platforms with lots of dependencies\n>\n>   - they interact with parts of the systems that are opaque to git. So\n>     we can't make a test that reliably simulates \"and then the user\n>     types 'foo' into a dialog box\" across all platforms.\n>\n> Instead, I came up with a separate test script that is intended to be\n> run interactively with the user. It runs the helpers through a battery\n> of tests, and tells the user what to expect and what to input to any\n> dialogs or prompts.\n>\n> I've run it already on the helpers I've written. I plan on running it\n> with the helpers that have been posted, as well. But I also wanted to\n> make it public so that authors could use it as a development aid.\n>\n> It's not integrated with git's tests at all. In theory it could be part\n> of t/, but disabled unless the user asks for it. However, I'm not sure\n> that makes much sense. It's intended to test helpers that aren't\n> necessarily even shipped with git, and wouldn't necessarily even need\n> git to run.\n\nPerhaps throw it in somewhere under contrib/ hierarchy?\n"}]}