Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP-tests fixes #285

Merged
merged 37 commits into from
Jan 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
bb43348
php tests with composer setup
mozhmike Jan 18, 2018
b7700dc
php tests fix
mozhmike Jan 18, 2018
2b9cf5b
Merge branch 'master' of https://github.com/cossacklabs/themis into p…
mozhmike Jan 18, 2018
cb9c8ce
fix tests
Lagovas Jan 18, 2018
9d00125
Force env init before tests
mozhmike Jan 19, 2018
51afdd0
Merge branch 'php-tests' of https://github.com/cossacklabs/themis int…
mozhmike Jan 19, 2018
7cf5e2e
fix session in extension
Lagovas Jan 19, 2018
0ba9d86
Merge remote-tracking branch 'origin/php-tests' into php-tests
Lagovas Jan 19, 2018
42dd7cb
Merge remote-tracking branch 'origin/master' into php-tests
Lagovas Jan 19, 2018
7207acd
Merge remote-tracking branch 'origin' into php-tests
Jan 19, 2018
6ed02f5
Makefiles for php-tests
mozhmike Jan 19, 2018
e9f9176
Merge branch 'php-tests' of https://github.com/cossacklabs/themis int…
Jan 19, 2018
9b14dab
Merge branch 'master' into php-tests
mozhmike Jan 22, 2018
e282d00
Merge remote-tracking branch 'origin/master' into php-tests
Lagovas Jan 22, 2018
7ec9f07
small readme fix
vixentael Jan 22, 2018
45cd178
Makefiles for php-tests
mozhmike Jan 23, 2018
076aef3
Merge branch 'php-tests' of https://github.com/cossacklabs/themis int…
mozhmike Jan 23, 2018
1c4b1cf
apt-get php5-dev
mozhmike Jan 23, 2018
bbec1ef
Circle-ci php env
mozhmike Jan 23, 2018
537c97d
Circle-ci php env
mozhmike Jan 23, 2018
f2a2324
merge
mozhmike Jan 23, 2018
40a4826
Make for php-tests
mozhmike Jan 23, 2018
2d3d76d
Make for php-tests
mozhmike Jan 23, 2018
7f9c5f6
Circle-ci config for phpize link
mozhmike Jan 23, 2018
1c10c0a
Circle-ci config for php-config link
mozhmike Jan 23, 2018
bb3e144
fix for php test
mozhmike Jan 23, 2018
d1c6e25
Circle build setting push
mozhmike Jan 23, 2018
0b10bf6
Isolate python test
mozhmike Jan 23, 2018
cb6b509
Revert python test isolation
mozhmike Jan 24, 2018
f496659
explicitly use python2
Lagovas Jan 24, 2018
fa3d5d6
force rebuild
Lagovas Jan 24, 2018
1a09908
fix setuptools error
Lagovas Jan 25, 2018
ca80c66
fix editor newline
Lagovas Jan 25, 2018
e4c43a1
fix gcov usage
Lagovas Jan 25, 2018
26edb33
setup python3 version
Lagovas Jan 25, 2018
ff6ef8c
force rebuild
Lagovas Jan 25, 2018
5627816
fix installing python
Lagovas Jan 25, 2018
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ __pycache__/
tests/phpthemis/vendor
tests/phpthemis/composer.json
tests/phpthemis/composer.phar
tests/phpthemis/composer.lock
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ else
VERSION = $(shell date -I | sed s/-/_/g)
endif

PHP_VERSION := $(shell php --version 2>/dev/null)
PHP_VERSION := $(shell php -r "echo PHP_MAJOR_VERSION;" 2>/dev/null)
RUBY_GEM_VERSION := $(shell gem --version 2>/dev/null)
GO_VERSION := $(shell go version 2>&1)
NPM_VERSION := $(shell npm --version 2>/dev/null)
Expand Down Expand Up @@ -405,7 +405,13 @@ uninstall: phpthemis_uninstall rubythemis_uninstall themispp_uninstall
@echo -n "themis uninstall "
@$(BUILD_CMD_)

phpthemis_install: CMD = cd src/wrappers/themis/php && phpize && ./configure && make install
ifeq ($(PHP_VERSION),5)
PHP_FOLDER = php
else
PHP_FOLDER = php7
endif

phpthemis_install: CMD = cd src/wrappers/themis/$(PHP_FOLDER) && phpize && ./configure && make install

phpthemis_install: install
ifdef PHP_VERSION
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ It is checked to compile on the latest stable versions of:

* Debian 7.8+, CentOS 7, Ubuntu 14, Arch Linux 2014+
* Windows XP+
* OSX 10.9+
* macOS 10.9+
* Android 4-8+ / CyanogenMod 11+
* iOS8—iOS11+, x32/x64

Expand Down
12 changes: 10 additions & 2 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ machine:
# add define that turn off one nist test (tests/soter/soter_rand_test.c:190) that always fail on ci machine but ok on real machine
CFLAGS: "-DCIRICLE_TEST"
BORINGSSL_PATH: "$HOME/boringssl"
php:
5.6.17

## Customize dependencies
dependencies:
Expand All @@ -22,8 +24,10 @@ dependencies:
- "~/boringssl"

pre:
- sudo apt-get update && sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php5 cmake libssl-dev python3 python3-setuptools ruby ninja-build lcov build-essential libc6-dbg
- sudo ln -sf /usr/bin/gcov-4.9 /usr/bin/gcov
- sudo apt-get update && sudo DEBIAN_FRONTEND=noninteractive apt-get -y install cmake libssl-dev python python-setuptools python3-setuptools ruby ninja-build lcov build-essential libc6-dbg
- sudo ln -sf /usr/bin/gcov-4.8 /usr/bin/gcov
- sudo ln -sf /opt/circleci/.phpenv/shims/phpize /usr/bin/phpize
- sudo ln -sf /opt/circleci/.phpenv/shims/php-config /usr/bin/php-config
- if [ ! -d $GOROOT ]; then cd $HOME && wget https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz && tar xf go1.6.2.linux-amd64.tar.gz; fi
- gem install coveralls-lcov
- go get github.com/mattn/goveralls
Expand All @@ -38,10 +42,14 @@ dependencies:

override:
- git submodule update --init
# setup explicitly versions of python to correctly run scripts with python3 name
- make
- make JAVA_HOME=/usr/lib/jvm/default-java themis_jni
- sudo make install
- sudo make themispp_install
- pyenv global 2.7.12 3.4.4
# set python from pyenv global accessible because we install with sudo
- sudo rm /usr/bin/python2 /usr/bin/python3 && sudo ln -s `which python2` /usr/bin/python2 && sudo ln -s `which python3` /usr/bin/python3
- sudo make pythemis_install
- sudo make rubythemis_install
- sudo make phpthemis_install
Expand Down
30 changes: 16 additions & 14 deletions src/wrappers/themis/php7/php_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ ssize_t receive_callback(uint8_t *data, size_t data_length, void *user_data){
return -1;
}

typedef struct themis_secure_session_object_t {
secure_session_t *session;
zend_object std;
} themis_secure_session_object;

static inline themis_secure_session_object * get_session_object(zend_object *obj) {
return (themis_secure_session_object*)((char *)obj - XtOffsetOf(themis_secure_session_object, std));
}

#define Z_SESSION_P(zv) get_session_object(Z_OBJ_P(zv));


int get_public_key_by_id_callback(const void *id, size_t id_length, void *key_buffer, size_t key_buffer_length, void *user_data){
// unused
(void)(user_data);
Expand All @@ -38,19 +50,15 @@ int get_public_key_by_id_callback(const void *id, size_t id_length, void *key_bu
return THEMIS_SUCCESS;
}

typedef struct themis_secure_session_object_t {
secure_session_t *session;
zend_object std;
} themis_secure_session_object;

void themis_secure_session_free_storage(void *object TSRMLS_DC)
{
themis_secure_session_object *obj = (themis_secure_session_object *)object;
secure_session_destroy(obj->session);
themis_secure_session_object *obj = get_session_object(object);
secure_session_t* session = obj->session;
secure_session_destroy(session);

zend_hash_destroy(obj->std.properties);
FREE_HASHTABLE(obj->std.properties);
efree(obj);
efree(object);
}

zend_object_handlers themis_secure_session_object_handlers;
Expand All @@ -71,12 +79,6 @@ zend_object* themis_secure_session_create_handler(zend_class_entry *type TSRMLS_
return &obj->std;
}

static inline themis_secure_session_object * get_session_object(zend_object *obj) {
return (themis_secure_session_object*)((char *)obj - XtOffsetOf(themis_secure_session_object, std));
}

#define Z_SESSION_P(zv) get_session_object(Z_OBJ_P(zv));

PHP_METHOD(themis_secure_session, __construct){
secure_session_t *session = NULL;
char* id;
Expand Down
5 changes: 0 additions & 5 deletions tests/phpthemis/composer-php5.6.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
{
"name": "tests/phpthemis/php-5.6",
"description": "Some stuff for tests",
"autoload": {
"classmap": [
"src/"
]
},
"require": {
"php": "^5.6",
"phpunit/phpunit": "^5"
Expand Down
5 changes: 0 additions & 5 deletions tests/phpthemis/composer-php7.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
{
"name": "tests/phpthemis/php-7",
"description": "Some stuff for tests",
"autoload": {
"classmap": [
"src/"
]
},
"require": {
"php": "^7",
"phpunit/phpunit": "^6"
Expand Down
Empty file modified tests/phpthemis/composer-setup.sh
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion tests/phpthemis/init_env-php5.6.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash -e

rm composer.json
rm -f composer.json
ln -s composer-php5.6.json composer.json
php composer.phar update
2 changes: 1 addition & 1 deletion tests/phpthemis/init_env-php7.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash -e

rm composer.json
rm -f composer.json
ln -s composer-php7.json composer.json
php composer.phar update
2 changes: 1 addition & 1 deletion tests/phpthemis/php.ini
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ default_socket_timeout = 60
;
; ... or under UNIX:
;
extension=phpthemis.so
extension=./phpthemis.so
;
; ... or with a path:
;
Expand Down
22 changes: 18 additions & 4 deletions tests/phpthemis/run_tests.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
#!/bin/bash -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we return back using "cd -"?

cd $DIR
PHPVERSION=`php -r "echo PHP_MAJOR_VERSION;"`


if [ ! -f ./composer.phar ]; then
bash ./composer-setup.sh
fi

if [ $PHPVERSION = 7 ]; then
bash ./init_env-php7.sh
else
bash ./init_env-php5.6.sh
fi

echo -e "\n >>>> secure cell tests <<<<\\n"
./vendor/phpunit/phpunit/phpunit scell_test.php
php -c php.ini ./vendor/phpunit/phpunit/phpunit scell_test.php
echo -e "\n >>>> secure message tests <<<<\n"
./vendor/phpunit/phpunit/phpunit smessage_test.php
php -c php.ini ./vendor/phpunit/phpunit/phpunit smessage_test.php
echo -e "\n >>>> secure token tests <<<<\n"
# todo:
./vendor/phpunit/phpunit/phpunit ssession_test.php
php -c php.ini ./vendor/phpunit/phpunit/phpunit ssession_test.php
Loading