这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
89012bd
1) Support both X-Hasura-Access-Key and X-Hasura-Admin-Secret as head…
nizar-m Jan 29, 2019
f42d064
In server and docs
nizar-m Jan 29, 2019
ede9ff4
Test to check whether header X-Hasura-Access-Key still works
nizar-m Jan 31, 2019
cd157e1
Add tests for
nizar-m Jan 31, 2019
c148e26
Change access key to admin secret in community folder
nizar-m Feb 1, 2019
af611d8
1) Change 'access key' to 'admin secret' in cli
nizar-m Feb 2, 2019
05494fc
Change 'access key' to 'admin secret' in console
nizar-m Feb 2, 2019
443eae0
Merge branch 'master' of github.com:hasura/graphql-engine into issue-…
nizar-m Feb 3, 2019
8547823
Move tests for deprecated server flags to another file
nizar-m Feb 4, 2019
c5fba85
Revert changes to the console
nizar-m Feb 4, 2019
a7b80ff
Merge branch 'master' into issue-1347
shahidhk Feb 5, 2019
c7e25c6
change acces-key to admin-secret in console
wawhal Feb 5, 2019
96eb737
refactor some code
shahidhk Feb 5, 2019
a90fd41
Merge branch 'issue-1347' of github.com:nizar-m/graphql-engine into i…
shahidhk Feb 5, 2019
2b1cb7c
fix access-key -> admin-secret in analyze filter
wawhal Feb 5, 2019
c88a1ec
Merge branch 'issue-1347' of github.com:nizar-m/graphql-engine into i…
shahidhk Feb 5, 2019
3294f77
fix typo
wawhal Feb 5, 2019
d61d5ec
add tests for cli with the last release
shahidhk Feb 5, 2019
35a1350
Merge branch 'issue-1347' of github.com:nizar-m/graphql-engine into i…
shahidhk Feb 5, 2019
ad83887
store artifacts to see log, change admin_secret to acces_key
shahidhk Feb 5, 2019
c76ce60
change adminSecretName to adminSecretLabel
wawhal Feb 5, 2019
b43516b
Merge branch 'issue-1347' of github.com:nizar-m/graphql-engine into i…
wawhal Feb 5, 2019
0b83807
Merge branch 'master' of github.com:hasura/graphql-engine into issue-…
nizar-m Feb 5, 2019
c9f7389
Merge branch 'master' of github.com:hasura/graphql-engine into issue-…
nizar-m Feb 7, 2019
b236b66
handle edge case in analyze headers filter
wawhal Feb 7, 2019
6555e94
add server feature flags
shahidhk Feb 7, 2019
1ce4721
add admin secret header switch for cli based on server version
shahidhk Feb 8, 2019
7024408
Merge branch 'issue-1347' of github.com:nizar-m/graphql-engine into i…
shahidhk Feb 8, 2019
b54c241
fix console tests
shahidhk Feb 8, 2019
8759532
fix cli tests
shahidhk Feb 8, 2019
4100e3d
change artifact directory
shahidhk Feb 8, 2019
05e186c
Merge branch 'master' into issue-1347
shahidhk Feb 8, 2019
ca98798
fix syntax in docs
rikinsk Feb 8, 2019
053474a
fix bug with backwards compatibility
wawhal Feb 8, 2019
52fe219
update console assets
shahidhk Feb 8, 2019
d75c442
Merge branch 'issue-1347' of github.com:nizar-m/graphql-engine into i…
shahidhk Feb 8, 2019
49b11e7
change access key to admin secret
shahidhk Feb 8, 2019
dce88ad
reset dotenv for local dev
wawhal Feb 8, 2019
943f0d8
Merge branch 'issue-1347' of github.com:nizar-m/graphql-engine into i…
wawhal Feb 8, 2019
8c86450
rename an internal variable
shahidhk Feb 8, 2019
cdcd1c3
Merge branch 'master' into issue-1347
shahidhk Feb 8, 2019
c8f6b67
add cors headers
shahidhk Feb 8, 2019
4b008f9
Merge branch 'master' into issue-1347
0x777 Feb 12, 2019
0252abe
update flag help for cli
shahidhk Feb 12, 2019
de71b0a
Merge branch 'master' into issue-1347
shahidhk Feb 12, 2019
5467900
Merge branch 'issue-1347' of github.com:nizar-m/graphql-engine into i…
shahidhk Feb 12, 2019
9666679
add backwards compatibility for f2g
wawhal Feb 12, 2019
877bd98
add backwards compatibility for json2graphql
wawhal Feb 12, 2019
c4c2ee7
Console readme change access key -> admin secret
nizar-m Feb 12, 2019
4af3059
Error message 'invalid X-Hasura-Admin-Secret/X-Hasura-Access-Key' on …
nizar-m Feb 12, 2019
31ba2b2
fix typo in local dev setup
wawhal Feb 14, 2019
1f391ce
Merge branch 'master' into issue-1347
shahidhk Feb 14, 2019
d2d2fa1
Merge branch 'issue-1347' of github.com:nizar-m/graphql-engine into i…
shahidhk Feb 14, 2019
41c39aa
Merge branch 'master' into issue-1347
shahidhk Feb 14, 2019
1f656e0
test-server.sh Change ACCESS_KEY to ADMIN_SECRET on cors test
nizar-m Feb 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ refs:
GRAPHQL_ENGINE: '/build/_server_output/graphql-engine'
command: |
apt-get update
apt install --yes jq
apt install --yes jq curl
OUTPUT_FOLDER=/build/_server_test_output/$PG_VERSION .circleci/test-server.sh
- run:
name: Generate coverage report
Expand Down Expand Up @@ -214,6 +214,37 @@ jobs:
- image: circleci/postgres:9.5-alpine-postgis
<<: *test_pg_env

test_cli_with_last_release:
docker:
- image: hasura/graphql-engine-cli-builder:v0.3
- image: circleci/postgres:10-alpine
environment:
POSTGRES_USER: gql_test
POSTGRES_DB: gql_test
working_directory: /go/src/github.com/hasura/graphql-engine
steps:
- checkout
- attach_workspace:
at: /build
- restore_cache:
keys:
- cli-vendor-{{ checksum "cli/Gopkg.toml" }}-{{ checksum "cli/Gopkg.lock" }}
- run:
name: get cli dependencies
working_directory: cli
command: make deps
- save_cache:
key: cli-vendor-{{ checksum "cli/Gopkg.toml" }}-{{ checksum "cli/Gopkg.lock" }}
paths:
- cli/vendor
- *wait_for_postgres
- run:
name: test cli
command: .circleci/test-cli-with-last-release.sh
- store_artifacts:
path: /build/_cli_output
destination: cli

# test and build cli
test_and_build_cli:
docker:
Expand Down Expand Up @@ -350,6 +381,8 @@ workflows:
- pytest_server_pg_10.6
- pytest_server_pg_9.6
- pytest_server_pg_9.5
- test_cli_with_last_release:
<<: *filter_only_vtags
- test_and_build_cli:
<<: *filter_only_vtags
requires:
Expand All @@ -358,6 +391,7 @@ workflows:
<<: *filter_only_vtags
requires:
- test_and_build_cli
- test_cli_with_last_release
- deploy:
<<: *filter_only_vtags_dev_release_branches
requires:
Expand Down
7 changes: 7 additions & 0 deletions .circleci/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ setup_gcloud() {
gcloud --quiet config set project ${GOOGLE_PROJECT_ID}
}

# push the server binary to google cloud storage
push_server_binary() {
gsutil cp /build/_server_output/graphql-engine \
gs://graphql-engine-cdn.hasura.io/server/latest/linux-amd64
}

# skip deploy for pull requests
if [[ -n "${CIRCLE_PR_NUMBER:-}" ]]; then
echo "not deploying for PRs"
Expand Down Expand Up @@ -134,6 +140,7 @@ deploy_console
deploy_server
if [[ ! -z "$CIRCLE_TAG" ]]; then
deploy_server_latest
push_server_binary
build_and_push_cli_migrations_image
CHANGELOG_TEXT=$(changelog server)
CHANGELOG_TEXT+=$(changelog cli)
Expand Down
51 changes: 51 additions & 0 deletions .circleci/test-cli-with-last-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash

set -euo pipefail
IFS=$'\n\t'
CLI_ROOT="${BASH_SOURCE[0]%/*}/../cli"

wait_for_port() {
local PORT=$1
echo "waiting for $PORT"
for i in `seq 1 60`;
do
nc -z localhost $PORT && echo "port $PORT is ready" && return
echo -n .
sleep 1
done
echo "Failed waiting for $PORT" && exit 1
}

# get latest cli
wget -O /bin/graphql-engine https://graphql-engine-cdn.hasura.io/server/latest/linux-amd64
chmod +x /bin/graphql-engine

cd "$CLI_ROOT"
mkdir -p /build/_cli_output
touch /build/_cli_output/server-last-release.log
touch /build/_cli_output/server-last-release-secret.log

# start graphql-engine without admin secret
/bin/graphql-engine \
--database-url postgres://gql_test@localhost:5432/gql_test serve > /build/_cli_output/server-last-release.log 2>&1 &
PID=$!

wait_for_port 8080

# test cli
HASURA_GRAPHQL_TEST_ENDPOINT="http://localhost:8080" make test

# kill the running server
kill $PID

# start graphql-engine with admin secret
psql -U gql_test -h localhost -c 'CREATE DATABASE "gql_test_with_admin_secret";'
/bin/graphql-engine \
--database-url postgres://gql_test@localhost:5432/gql_test_with_admin_secret serve --access-key "abcd" > /build/_cli_output/server-last-release-secret.log 2>&1 &
PID=$!

wait_for_port 8080

# test cli
GOCACHE=off HASURA_GRAPHQL_TEST_ENDPOINT="http://localhost:8080" HASURA_GRAPHQL_TEST_ADMIN_SECRET="abcd" make test
kill $PID
11 changes: 6 additions & 5 deletions .circleci/test-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ wait_for_port() {
cd "$CLI_ROOT"
mkdir -p /build/_cli_output
touch /build/_cli_output/server.log
touch /build/_cli_output/server-secret.log

# start graphql-engine without access key
# start graphql-engine without admin secret
/build/_server_output/graphql-engine \
--database-url postgres://gql_test@localhost:5432/gql_test serve > /build/_cli_output/server.log 2>&1 &
PID=$!
Expand All @@ -31,14 +32,14 @@ wait_for_port 8080
HASURA_GRAPHQL_TEST_ENDPOINT="http://localhost:8080" make test
kill $PID

# start graphql-engine with access key
psql -U gql_test -h localhost -c 'CREATE DATABASE "gql_test_with_access";'
# start graphql-engine with admin secret
psql -U gql_test -h localhost -c 'CREATE DATABASE "gql_test_with_admin_secret";'
/build/_server_output/graphql-engine \
--database-url postgres://gql_test@localhost:5432/gql_test_with_access serve --access-key "abcd" > /build/_cli_output/server.log 2>&1 &
--database-url postgres://gql_test@localhost:5432/gql_test_with_admin_secret serve --admin-secret "abcd" > /build/_cli_output/server-secret.log 2>&1 &
PID=$!

wait_for_port 8080

# test cli
GOCACHE=off HASURA_GRAPHQL_TEST_ENDPOINT="http://localhost:8080" HASURA_GRAPHQL_TEST_ACCESS_KEY="abcd" make test
GOCACHE=off HASURA_GRAPHQL_TEST_ENDPOINT="http://localhost:8080" HASURA_GRAPHQL_TEST_ADMIN_SECRET="abcd" make test
kill $PID
105 changes: 105 additions & 0 deletions .circleci/test-deprecated-server-flags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/usr/bin/env bash
set -euo pipefail

CIRCLECI_FOLDER="${BASH_SOURCE[0]%/*}"
cd $CIRCLECI_FOLDER
CIRCLECI_FOLDER="$PWD"

SERVER_ROOT="$CIRCLECI_FOLDER/../server"

i=1
echoInfo() {
echo -e "\033[36m$i. $*\033[0m"
i=$[i+1]
}

fail_if_port_busy() {
local PORT=$1
if nc -z localhost $PORT ; then
echo "Port $PORT is busy. Exiting"
exit 1
fi
}

wait_for_port() {
local PORT=$1
echo "waiting for $PORT"
for _ in $(seq 1 30);
do
nc -z localhost $PORT && echo "port $PORT is ready" && return
echo -n .
sleep 0.2
done
echo "Failed waiting for $PORT" && exit 1
}

test_export_metadata_with_access_key() {
curl -f -d'{"type" : "export_metadata", "args" : {} }' localhost:8080/v1/query -H "X-Hasura-Access-Key: $1" > /dev/null
}

cd $SERVER_ROOT

if [ -z "${HASURA_GRAPHQL_DATABASE_URL:-}" ] ; then
echo "Env var HASURA_GRAPHQL_DATABASE_URL is not set"
exit 1
fi

if ! stack --allow-different-user exec -- which graphql-engine > /dev/null && [ -z "${GRAPHQL_ENGINE:-}" ] ; then
echo "Do 'stack build' before tests, or export the location of executable in the GRAPHQL_ENGINE envirnoment variable"
exit 1
fi

GRAPHQL_ENGINE=${GRAPHQL_ENGINE:-"$(stack --allow-different-user exec -- which graphql-engine)"}
if ! [ -x "$GRAPHQL_ENGINE" ] ; then
echo "$GRAPHQL_ENGINE is not present or is not an executable"
exit 1
fi

HGE_PID=""

run_hge_with_flags() {
fail_if_port_busy 8080
set -x
stdbuf -o0 "$GRAPHQL_ENGINE" serve $* > "$OUTPUT_FOLDER/graphql-engine.log" & HGE_PID=$!
set +x
wait_for_port 8080
}

kill_hge() {
kill $HGE_PID || true
wait $HGE_PID || true
}

trap kill_hge ERR
trap kill_hge INT

OUTPUT_FOLDER=${OUTPUT_FOLDER:-"$CIRCLECI_FOLDER/test-server-flags-output"}
mkdir -p "$OUTPUT_FOLDER"

################### Test deprecated flag --access-key

key="HGE$RANDOM$RANDOM"

run_hge_with_flags --access-key="$key"

echoInfo "Test deprecated flag --access-key=XXXX"
grep -F '"admin_secret_set":true' "$OUTPUT_FOLDER/graphql-engine.log" >/dev/null
test_export_metadata_with_access_key "$key"

kill_hge

################## Test deprecated EnvVar HASURA_GRAPHQL_ACCESS_KEY=XXXX

key="HGE$RANDOM$RANDOM"

export HASURA_GRAPHQL_ACCESS_KEY="$key"

run_hge_with_flags

echoInfo "Test deprecated EnvVar HASURA_GRAPHQL_ACCESS_KEY=XXXX"
grep -F '"admin_secret_set":true' "$OUTPUT_FOLDER/graphql-engine.log" >/dev/null || (cat "$OUTPUT_FOLDER/graphql-engine.log" && false)
test_export_metadata_with_access_key "$key"

kill_hge

unset $HASURA_GRAPHQL_ACCESS_KEY
Loading