Skip to content

Instantly share code, notes, and snippets.

@dolph
Created August 24, 2015 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dolph/0910160219063429d22f to your computer and use it in GitHub Desktop.
Save dolph/0910160219063429d22f to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
unset OS_TOKEN
unset OS_ENDPOINT
# mysql -ukeystone -pkeystone -e "drop database keystone; create database keystone;"
# ~/openstack/keystone/.tox/py27/bin/keystone-manage db_sync
export OS_IDENTITY_API_VERSION=2.0
keystone --os-endpoint="http://localhost:35357/v2.0/" --os-token="ADMIN" bootstrap --user-name=admin --pass=admin --role-name=admin --tenant-name=admin
export OS_AUTH_URL=http://localhost:35357/v3/
export OS_IDENTITY_API_VERSION=3
export OS_USERNAME=admin
export OS_PASSWORD=admin
export OS_TENANT_NAME=admin
export OS_PROJECT_NAME=admin
export OS_PROJECT_DOMAIN_ID=default
export OS_USER_DOMAIN_ID=default
ADMIN_TOKEN=`openstack token issue | grep id | grep -v project_id | grep -v user_id | awk '{ print $4 }'`
while true
do
# mysql -ukeystone -pkeystone -e "use keystone; truncate revocation_event; commit;"
# generate a new subject token
echo "Creating a subject token..."
SUBJECT_TOKEN=`openstack token issue | grep id | grep -v project_id | grep -v user_id | awk '{ print $4 }'`
echo $SUBJECT_TOKEN
# the "fix"!
# sleep 0.5
# try to delete the token
echo "Deleting the subject token..."
http --verbose delete ${OS_AUTH_URL}auth/tokens --x-auth-token=$ADMIN_TOKEN --x-subject-token=$SUBJECT_TOKEN | grep "Status: 204"
echo "Validating the deleted token..."
set +e
http --verbose get ${OS_AUTH_URL}auth/tokens --x-auth-token=$ADMIN_TOKEN --x-subject-token=$SUBJECT_TOKEN | grep "Status: 404"
if [ $? -ne 0 ]; then
echo "Token is unexpectedly valid! Bug!"
break
fi
echo "Token is correctly invalid. Trying again with another token..."
set -e
done
echo "Token remains valid!"
# mysql -ukeystone -pkeystone -e "use keystone; select * from revocation_event;"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment