Merge pull request #13 from sobolevn/staging

Version 0.1.1 released
pull/16/merge
Sobolev Nikita 8 years ago
commit 1f549d350d

@ -1,13 +1,16 @@
language: c
sudo: false
env:
- SECRETS_GPG_COMMAND=gpg
- SECRETS_GPG_COMMAND=gpg2
branches:
only:
- master
- develop
install:
- test $SECRETS_GPG_COMMAND = gpg2 && sudo apt-get install gnupg2 || echo 0
- make install-test
script:

@ -0,0 +1,14 @@
# Changelog
## Version 0.1.1
- Added `--dry-run` option to the `git secret` command, which prevents any actions.
- Now `install_full_fixture()` returns a fingerprint
- Now `uninstall_full_fixture()` receives two args
- Fixed bug, when tests were failing with `gpg2`
- New travis strategy: testing both `gpg` and `gpg2`
- Removed animation from docs, now using `asciinema.org`
## Version 0.1.0
- Initial release

@ -4,7 +4,7 @@
## Preview
![git-secret terminal preview](https://raw.githubusercontent.com/sobolevn/git-secret/gh-pages/images/gitsecret_terminal.gif)
[![git-secret terminal preview](https://asciinema.org/a/41811.png)](https://asciinema.org/a/41811?autoplay=1)
## Usage
@ -25,7 +25,6 @@ This project is still under development. Current objectives:
- integrate [`shellcheck`](https://github.com/koalaman/shellcheck) for code style tests
- create `CONTRIBUTING.md` with development process explained
- сygwin support (?)
- add `CHANGELOG.md` with semantic versioning
## Testing
@ -35,6 +34,4 @@ To run tests call: `make test`. It will download and install `bats` into `vendor
## Changelog
### Version 0.1.0
- Initial release
See [CHANGELOG.md](CHANGELOG.md)

@ -1,6 +1,6 @@
#!/usr/bin/env bash
GITSECRET_VERSION="0.1.0"
GITSECRET_VERSION="0.1.1"
# Global variables:

@ -16,7 +16,7 @@ function tell {
h) _show_manual_for "tell";;
m) # Set email of the git current user:
email=$(git config user.email) || _abort "'git congig user.email' is not set."
email=$(git config user.email) || _abort "'git config user.email' is not set."
;;
d) homedir=$OPTARG;;

@ -1,5 +1,6 @@
#!/usr/bin/env bash
set -e
function _check_setup {
# Checking git and secret-plugin setup:
@ -40,23 +41,39 @@ function _init_script {
_incorrect_usage "no input parameters provided." 126
fi
if [[ $1 == "--version" ]]; then
_show_version
fi
# Parse plugin-level options:
local dry_run=0
while [[ $# > 0 ]]; do
local opt="$1"
case "$opt" in
# options for quick-exit strategy:
--dry-run)
dry_run=1
shift;;
# checking for proper set-up:
_check_setup
--version) _show_version;;
# load dependencies:
# for f in ${0%/*}/src/*/*; do [[ -f "$f" ]] && . "$f"; done
*) break;; # do nothing
esac
done
# routing the input command:
if [[ $(_function_exists $1) == 0 ]] && [[ ! $1 == _* ]]; then
$1 "${@:2}"
else
_incorrect_usage "command $1 not found." 126
if [[ "$dry_run" == 0 ]]; then
# checking for proper set-up:
_check_setup
# load dependencies:
# for f in ${0%/*}/src/*/*; do [[ -f "$f" ]] && . "$f"; done
# routing the input command:
if [[ $(_function_exists $1) == 0 ]] && [[ ! $1 == _* ]]; then
$1 "${@:2}"
else # TODO: elif [[ $(_plugin_exists $1) == 0 ]]; then
_incorrect_usage "command $1 not found." 126
fi
fi
}
set -e
_init_script $@

@ -63,14 +63,21 @@ function install_fixture_full_key {
local private_key="$BATS_TMPDIR/private-${1}.key"
local email=$(test_user_email "$1")
# local fingerprint=`_get_gpg_fingerprint_by_email "$email"`
$SECRETS_GPG_COMMAND --homedir="$FIXTURES_DIR/gpg/${1}" \
--no-permission-warning --output "$private_key" --armor \
--yes --export-secret-key "$email" > /dev/null 2>&1
$GPGTEST --allow-secret-key-import --import "$private_key" > /dev/null 2>&1
local fp=$($GPGTEST --with-fingerprint "$private_key")
# since 0.1.2 fingerprint is returned:
local fingerprint=$(echo "$fp" | tr -d ' ' | sed -n '2p' | sed -e 's/.*=//g')
install_fixture_key "$1"
# return fingerprint to delete it later:
echo "$fingerprint"
}
@ -82,7 +89,13 @@ function uninstall_fixture_key {
function uninstall_fixture_full_key {
local email=$(test_user_email "$1")
local fingerprint=$(_get_gpg_fingerprint_by_email "$email")
local fingerprint="$2"
if [[ -z "$fingerprint" ]]; then
# see issue_12, fingerprint on `gpg2` has different format:
fingerprint=$(_get_gpg_fingerprint_by_email "$email")
fi
$GPGTEST --batch --yes --delete-secret-keys "$fingerprint" > /dev/null 2>&1
uninstall_fixture_key "$1"

@ -5,9 +5,11 @@ load _test_base
FILE_TO_HIDE="file_to_hide"
FILE_CONTENTS="hidden content юникод"
FINGERPRINT=""
function setup {
install_fixture_full_key "$TEST_DEFAULT_USER"
FINGERPRINT=$(install_fixture_full_key "$TEST_DEFAULT_USER")
set_state_git
set_state_secret_init
@ -18,7 +20,7 @@ function setup {
function teardown {
uninstall_fixture_full_key "$TEST_DEFAULT_USER"
uninstall_fixture_full_key "$TEST_DEFAULT_USER" "$FINGERPRINT"
unset_current_state
rm -f "$FILE_TO_HIDE"
}
@ -53,7 +55,7 @@ function teardown {
rm -f "$FILE_TO_HIDE"
local attacker="attacker1"
install_fixture_full_key "$attacker"
local atacker_fingerprint=$(install_fixture_full_key "$attacker")
local password=$(test_user_password "$attacker")
run git secret reveal -d "$TEST_GPG_HOMEDIR" -p "$password"
@ -61,7 +63,7 @@ function teardown {
[ "$status" -eq 2 ]
[ ! -f "$FILE_TO_HIDE" ]
uninstall_fixture_full_key "$attacker"
uninstall_fixture_full_key "$attacker" "$atacker_fingerprint"
}
@ -71,7 +73,7 @@ function teardown {
set_state_secret_tell "$new_user"
set_state_secret_hide
uninstall_fixture_full_key "$TEST_DEFAULT_USER"
uninstall_fixture_full_key "$TEST_DEFAULT_USER" "$FINGERPRINT"
local password=$(test_user_password "$new_user")
run git secret reveal -d "$TEST_GPG_HOMEDIR" -p "$password"

Loading…
Cancel
Save