mirror of https://gitee.com/bigwinds/arangodb
added authentication tests, fixed authentication
This commit is contained in:
parent
fa227a8063
commit
7cc7f2d28e
|
|
@ -38,7 +38,8 @@ unittests-brief: \
|
|||
unittests-arangob \
|
||||
unittests-import \
|
||||
unittests-upgrade \
|
||||
unittests-dfdb
|
||||
unittests-dfdb \
|
||||
unittests-authentication
|
||||
|
||||
unittests-verbose:
|
||||
@echo "################################################################################"
|
||||
|
|
@ -128,6 +129,15 @@ start-server:
|
|||
@if [ "$(VALGRIND)" != "" ]; then echo "adding valgrind memorial time..."; sleep 75; else sleep 2; fi
|
||||
@echo
|
||||
|
||||
################################################################################
|
||||
### @brief issue a curl request and return the status
|
||||
################################################################################
|
||||
|
||||
.PHONY: curl-request-get
|
||||
|
||||
curl-request-get:
|
||||
@declare -x ACTUAL=$$(curl --dump - -X GET "$(CURL_PROTO)://$(CURL_HOST):$(CURL_PORT)$(CURL_URL)" 2> /dev/null | head -n 1 | sed -e 's/^HTTP\/1\.1 \([0-9]\+\).*/\1/g'); if [ "x$$ACTUAL" != "x$(EXPECTED)" ]; then echo "request to $(CURL_PROTO)://$(CURL_HOST):$(CURL_PORT)$(CURL_URL) returned $$ACTUAL, expected: $(EXPECTED)"; false; else true; fi
|
||||
|
||||
################################################################################
|
||||
### @brief COMMON MAKE-RELATED TESTS
|
||||
################################################################################
|
||||
|
|
@ -468,7 +478,7 @@ unittests-import:
|
|||
|
||||
@echo
|
||||
@echo "================================================================================"
|
||||
@echo "<< IMPORT TESTS >>"
|
||||
@echo "<< IMPORT TESTS >>"
|
||||
@echo "================================================================================"
|
||||
@echo
|
||||
|
||||
|
|
@ -592,6 +602,74 @@ unittests-arangob:
|
|||
@rm -rf "$(VOCDIR)"
|
||||
@echo
|
||||
|
||||
################################################################################
|
||||
### @brief AUTHENTICATION
|
||||
################################################################################
|
||||
|
||||
.PHONY: unittests-authentication
|
||||
|
||||
unittests-authentication:
|
||||
|
||||
@echo
|
||||
@echo "================================================================================"
|
||||
@echo "<< AUTHENTICATION TESTS >>"
|
||||
@echo "================================================================================"
|
||||
@echo
|
||||
|
||||
################################################################################
|
||||
### @brief FULL AUTHENTICATION
|
||||
################################################################################
|
||||
|
||||
$(MAKE) start-server PID=$(PID) SERVER_START="--server.endpoint tcp://$(VOCHOST):$(VOCPORT) --server.disable-auth false --server.authenticate-system-only false" PROTO=http
|
||||
$(MAKE) curl-request-get CURL_PROTO="http" CURL_HOST="$(VOCHOST)" CURL_PORT="$(VOCPORT)" CURL_URL="/_api/" EXPECTED="401" || test "x$(FORCE)" == "x1"
|
||||
$(MAKE) curl-request-get CURL_PROTO="http" CURL_HOST="$(VOCHOST)" CURL_PORT="$(VOCPORT)" CURL_URL="/_api" EXPECTED="401" || test "x$(FORCE)" == "x1"
|
||||
$(MAKE) curl-request-get CURL_PROTO="http" CURL_HOST="$(VOCHOST)" CURL_PORT="$(VOCPORT)" CURL_URL="/_api/version" EXPECTED="401" || test "x$(FORCE)" == "x1"
|
||||
$(MAKE) curl-request-get CURL_PROTO="http" CURL_HOST="$(VOCHOST)" CURL_PORT="$(VOCPORT)" CURL_URL="/_admin/html" EXPECTED="401" || test "x$(FORCE)" == "x1"
|
||||
$(MAKE) curl-request-get CURL_PROTO="http" CURL_HOST="$(VOCHOST)" CURL_PORT="$(VOCPORT)" CURL_URL="/_admin/html/" EXPECTED="401" || test "x$(FORCE)" == "x1"
|
||||
$(MAKE) curl-request-get CURL_PROTO="http" CURL_HOST="$(VOCHOST)" CURL_PORT="$(VOCPORT)" CURL_URL="/test" EXPECTED="401" || test "x$(FORCE)" == "x1"
|
||||
$(MAKE) curl-request-get CURL_PROTO="http" CURL_HOST="$(VOCHOST)" CURL_PORT="$(VOCPORT)" CURL_URL="/the-big-fat-fox" EXPECTED="401" || test "x$(FORCE)" == "x1"
|
||||
|
||||
kill `cat $(PIDFILE)`
|
||||
while test -f $(PIDFILE); do sleep 1; done
|
||||
@if [ "$(VALGRIND)" != "" ]; then sleep 60; fi
|
||||
@rm -rf "$(VOCDIR)"
|
||||
|
||||
################################################################################
|
||||
### @brief AUTHENTICATION FOR /_ ONLY
|
||||
################################################################################
|
||||
|
||||
$(MAKE) start-server PID=$(PID) SERVER_START="--server.endpoint tcp://$(VOCHOST):$(VOCPORT) --server.disable-auth false --server.authenticate-system-only true" PROTO=http
|
||||
$(MAKE) curl-request-get CURL_PROTO="http" CURL_HOST="$(VOCHOST)" CURL_PORT="$(VOCPORT)" CURL_URL="/_api/" EXPECTED="401" || test "x$(FORCE)" == "x1"
|
||||
$(MAKE) curl-request-get CURL_PROTO="http" CURL_HOST="$(VOCHOST)" CURL_PORT="$(VOCPORT)" CURL_URL="/_api" EXPECTED="401" || test "x$(FORCE)" == "x1"
|
||||
$(MAKE) curl-request-get CURL_PROTO="http" CURL_HOST="$(VOCHOST)" CURL_PORT="$(VOCPORT)" CURL_URL="/_api/version" EXPECTED="401" || test "x$(FORCE)" == "x1"
|
||||
$(MAKE) curl-request-get CURL_PROTO="http" CURL_HOST="$(VOCHOST)" CURL_PORT="$(VOCPORT)" CURL_URL="/_admin/html" EXPECTED="401" || test "x$(FORCE)" == "x1"
|
||||
$(MAKE) curl-request-get CURL_PROTO="http" CURL_HOST="$(VOCHOST)" CURL_PORT="$(VOCPORT)" CURL_URL="/_admin/html/" EXPECTED="401" || test "x$(FORCE)" == "x1"
|
||||
$(MAKE) curl-request-get CURL_PROTO="http" CURL_HOST="$(VOCHOST)" CURL_PORT="$(VOCPORT)" CURL_URL="/test" EXPECTED="404" || test "x$(FORCE)" == "x1"
|
||||
$(MAKE) curl-request-get CURL_PROTO="http" CURL_HOST="$(VOCHOST)" CURL_PORT="$(VOCPORT)" CURL_URL="/the-big-fat-fox" EXPECTED="404" || test "x$(FORCE)" == "x1"
|
||||
|
||||
kill `cat $(PIDFILE)`
|
||||
while test -f $(PIDFILE); do sleep 1; done
|
||||
@if [ "$(VALGRIND)" != "" ]; then sleep 60; fi
|
||||
@rm -rf "$(VOCDIR)"
|
||||
|
||||
################################################################################
|
||||
### @brief NO AUTHENTICATION
|
||||
################################################################################
|
||||
|
||||
$(MAKE) start-server PID=$(PID) SERVER_START="--server.endpoint tcp://$(VOCHOST):$(VOCPORT) --server.disable-auth true --server.authenticate-system-only true" PROTO=http
|
||||
$(MAKE) curl-request-get CURL_PROTO="http" CURL_HOST="$(VOCHOST)" CURL_PORT="$(VOCPORT)" CURL_URL="/_api/" EXPECTED="404" || test "x$(FORCE)" == "x1"
|
||||
$(MAKE) curl-request-get CURL_PROTO="http" CURL_HOST="$(VOCHOST)" CURL_PORT="$(VOCPORT)" CURL_URL="/_api" EXPECTED="404" || test "x$(FORCE)" == "x1"
|
||||
$(MAKE) curl-request-get CURL_PROTO="http" CURL_HOST="$(VOCHOST)" CURL_PORT="$(VOCPORT)" CURL_URL="/_api/version" EXPECTED="200" || test "x$(FORCE)" == "x1"
|
||||
$(MAKE) curl-request-get CURL_PROTO="http" CURL_HOST="$(VOCHOST)" CURL_PORT="$(VOCPORT)" CURL_URL="/_admin/html" EXPECTED="301" || test "x$(FORCE)" == "x1"
|
||||
$(MAKE) curl-request-get CURL_PROTO="http" CURL_HOST="$(VOCHOST)" CURL_PORT="$(VOCPORT)" CURL_URL="/_admin/html/" EXPECTED="301" || test "x$(FORCE)" == "x1"
|
||||
$(MAKE) curl-request-get CURL_PROTO="http" CURL_HOST="$(VOCHOST)" CURL_PORT="$(VOCPORT)" CURL_URL="/test" EXPECTED="404" || test "x$(FORCE)" == "x1"
|
||||
$(MAKE) curl-request-get CURL_PROTO="http" CURL_HOST="$(VOCHOST)" CURL_PORT="$(VOCPORT)" CURL_URL="/the-big-fat-fox" EXPECTED="404" || test "x$(FORCE)" == "x1"
|
||||
|
||||
kill `cat $(PIDFILE)`
|
||||
while test -f $(PIDFILE); do sleep 1; done
|
||||
@if [ "$(VALGRIND)" != "" ]; then sleep 60; fi
|
||||
@rm -rf "$(VOCDIR)"
|
||||
|
||||
################################################################################
|
||||
### @brief CPPCHECK
|
||||
################################################################################
|
||||
|
|
|
|||
|
|
@ -113,7 +113,10 @@ bool VocbaseContext::authenticate () {
|
|||
|
||||
if (path != 0) {
|
||||
// check if path starts with /_
|
||||
if (*path == '/' && *(path + 1) == '_') {
|
||||
if (*path != '/') {
|
||||
return true;
|
||||
}
|
||||
if (*path != '\0' && *(path + 1) != '_') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue