From 0866784ce8e8b00777470b3ddb2acb79c8bd2632 Mon Sep 17 00:00:00 2001 From: Marek Ruszczak Date: Fri, 18 Nov 2011 13:13:56 +0200 Subject: [PATCH] Changes: Adds test: when running application is updated with new security token this token shouldn't be gained by this application until it is rerun (test of child processes of applauncherd). --- debian/changelog | 6 ++ debian/rules | 2 +- tests/harmattan/red-tests/tests.xml | 8 ++ .../applauncherd-token-test.conf | 9 ++ .../applauncherd-token-test.pro | 63 +++++++++++++ .../applauncherd-token-test-1.1/debian/README | 6 ++ .../debian/applauncherd-token-test.aegis | 21 +++++ .../debian/applauncherd-token-test.postinst | 3 + .../debian/changelog | 11 +++ .../applauncherd-token-test-1.1/debian/compat | 1 + .../debian/control | 22 +++++ .../debian/copyright | 16 ++++ .../applauncherd-token-test-1.1/debian/rules | 74 ++++++++++++++++ .../applauncherd-token-test-1.1/main.cpp | 9 ++ .../applauncherd-token-test_1.1_armel.deb | Bin 0 -> 4674 bytes tests/harmattan/testscripts/test-security.py | 83 ++++++++++++++++-- 16 files changed, 326 insertions(+), 8 deletions(-) create mode 100644 tests/harmattan/testapps/applauncherd-token-test-1.1/applauncherd-token-test.conf create mode 100644 tests/harmattan/testapps/applauncherd-token-test-1.1/applauncherd-token-test.pro create mode 100644 tests/harmattan/testapps/applauncherd-token-test-1.1/debian/README create mode 100644 tests/harmattan/testapps/applauncherd-token-test-1.1/debian/applauncherd-token-test.aegis create mode 100644 tests/harmattan/testapps/applauncherd-token-test-1.1/debian/applauncherd-token-test.postinst create mode 100644 tests/harmattan/testapps/applauncherd-token-test-1.1/debian/changelog create mode 100644 tests/harmattan/testapps/applauncherd-token-test-1.1/debian/compat create mode 100644 tests/harmattan/testapps/applauncherd-token-test-1.1/debian/control create mode 100644 tests/harmattan/testapps/applauncherd-token-test-1.1/debian/copyright create mode 100755 tests/harmattan/testapps/applauncherd-token-test-1.1/debian/rules create mode 100644 tests/harmattan/testapps/applauncherd-token-test-1.1/main.cpp create mode 100644 tests/harmattan/testapps/applauncherd-token-test_1.1_armel.deb diff --git a/debian/changelog b/debian/changelog index 2854d44..0781bf7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +applauncherd (3.0.1) unstable; urgency=low + + * Changes: Adds new test for applauncherd re-exec. Checking state of running application when it is updated. + + -- Alexey Shilov Mon, 14 Nov 2011 13:39:38 +0200 + applauncherd (2.0.16) stable; urgency=low * Fixes: NB#296154 - proprietary headers in applauncherd replaced to LGPL diff --git a/debian/rules b/debian/rules index 39ca8e4..a91f243 100755 --- a/debian/rules +++ b/debian/rules @@ -49,7 +49,7 @@ install: build dh_installdirs DESTDIR=debian/tmp make install - cp tests/harmattan/testapps/applauncherd-token-test_1.0_armel.deb debian/tmp/usr/share/fala_images + cp tests/harmattan/testapps/applauncherd-token-test_1.?_armel.deb debian/tmp/usr/share/fala_images cp tests/harmattan/testapps/applauncherd-usrlib-test_1.?_armel.deb debian/tmp/usr/share/fala_images #tests/harmattan/testapps/applauncherd-token-test_1.0_armel.deb: diff --git a/tests/harmattan/red-tests/tests.xml b/tests/harmattan/red-tests/tests.xml index 55e71df..ef85705 100644 --- a/tests/harmattan/red-tests/tests.xml +++ b/tests/harmattan/red-tests/tests.xml @@ -100,6 +100,14 @@ insignificant="true"> source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_reexec_when_file_in_usrlib_modified + + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-security.py test_that_other_apps_dont_gain_new_token + initctl start xsession/pkgm-timed-checks diff --git a/tests/harmattan/testapps/applauncherd-token-test-1.1/applauncherd-token-test.conf b/tests/harmattan/testapps/applauncherd-token-test-1.1/applauncherd-token-test.conf new file mode 100644 index 0000000..a08ba63 --- /dev/null +++ b/tests/harmattan/testapps/applauncherd-token-test-1.1/applauncherd-token-test.conf @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/harmattan/testapps/applauncherd-token-test-1.1/applauncherd-token-test.pro b/tests/harmattan/testapps/applauncherd-token-test-1.1/applauncherd-token-test.pro new file mode 100644 index 0000000..b2d6229 --- /dev/null +++ b/tests/harmattan/testapps/applauncherd-token-test-1.1/applauncherd-token-test.pro @@ -0,0 +1,63 @@ +## This file is part of test package applauncherd-token-test +# +# Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# +# Contact: Marek Ruszczak +# +# This software, including documentation, is protected by copyright +# controlled by Nokia Corporation. All rights are reserved. Copying, +# including reproducing, storing, adapting or translating, any or all +# of this material requires the prior written consent of Nokia +# Corporation. This material also contains confidential information +# which may not be disclosed to others without the prior written +# consent of Nokia. +## + +QMAKEVERSION = $$[QMAKE_VERSION] +ISQT4 = $$find(QMAKEVERSION, ^[2-9]) +isEmpty( ISQT4 ) { + error("Use the qmake include with Qt4.4 or greater, on Debian that is qmake-qt4"); +} + +QT += core +QT -= gui + +TARGET = fala-token-test-app +TEMPLATE = app +CONFIG += warn_on link_pkgconfig +CONFIG += console +CONFIG -= app_bundle + +DESTDIR = bin +OBJECTS_DIR = obj +MOC_DIR = obj + +SOURCES += main.cpp + +# Flags to reduce binary size where possible +QMAKE_CXXFLAGS += -fdata-sections -ffunction-sections +QMAKE_LFLAGS += --discard-local --discard-all -Wl --gc-sections +QMAKE_CXXFLAGS -= -O2 +QMAKE_CXXFLAGS += -Os + +unix { + #VARIABLES + isEmpty(PREFIX) { + PREFIX = /usr + } + BINDIR = $$PREFIX/bin + DATADIR =$$PREFIX/share + + DEFINES += DATADIR=\\\"$$DATADIR\\\" PKGDATADIR=\\\"$$PKGDATADIR\\\" + + #MAKE INSTALL + + INSTALLS += target aegisfs_config + + target.path =$$BINDIR + + aegisfs_config.files = applauncherd-token-test.conf + aegisfs_config.path = /etc/aegisfs.d +} + diff --git a/tests/harmattan/testapps/applauncherd-token-test-1.1/debian/README b/tests/harmattan/testapps/applauncherd-token-test-1.1/debian/README new file mode 100644 index 0000000..561a6b1 --- /dev/null +++ b/tests/harmattan/testapps/applauncherd-token-test-1.1/debian/README @@ -0,0 +1,6 @@ +The Debian Package applauncherd-token-test +---------------------------- + +This packeged is used to test that applauncherd is gaining custom tokens when installed appliaction is using a booster. + + -- Marek Ruszczak Fri, 04 Nov 2011 16:05:43 +0200 diff --git a/tests/harmattan/testapps/applauncherd-token-test-1.1/debian/applauncherd-token-test.aegis b/tests/harmattan/testapps/applauncherd-token-test-1.1/debian/applauncherd-token-test.aegis new file mode 100644 index 0000000..fa0b74e --- /dev/null +++ b/tests/harmattan/testapps/applauncherd-token-test-1.1/debian/applauncherd-token-test.aegis @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/harmattan/testapps/applauncherd-token-test-1.1/debian/applauncherd-token-test.postinst b/tests/harmattan/testapps/applauncherd-token-test-1.1/debian/applauncherd-token-test.postinst new file mode 100644 index 0000000..4d46836 --- /dev/null +++ b/tests/harmattan/testapps/applauncherd-token-test-1.1/debian/applauncherd-token-test.postinst @@ -0,0 +1,3 @@ +#!/bin/sh + +aegisfs --install /etc/aegisfs.d/applauncherd-token-test.conf diff --git a/tests/harmattan/testapps/applauncherd-token-test-1.1/debian/changelog b/tests/harmattan/testapps/applauncherd-token-test-1.1/debian/changelog new file mode 100644 index 0000000..c96bf91 --- /dev/null +++ b/tests/harmattan/testapps/applauncherd-token-test-1.1/debian/changelog @@ -0,0 +1,11 @@ +applauncherd-token-test (1.1) unstable; urgency=low + + * adding additional custom credential token. + + -- Marek Ruszczak Tue, 15 Nov 2011 15:33:16 +0200 + +applauncherd-token-test (1.0) stable; urgency=low + + * Initial Release. + + -- Marek Ruszczak Fri, 04 Nov 2011 16:05:43 +0200 diff --git a/tests/harmattan/testapps/applauncherd-token-test-1.1/debian/compat b/tests/harmattan/testapps/applauncherd-token-test-1.1/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/tests/harmattan/testapps/applauncherd-token-test-1.1/debian/compat @@ -0,0 +1 @@ +7 diff --git a/tests/harmattan/testapps/applauncherd-token-test-1.1/debian/control b/tests/harmattan/testapps/applauncherd-token-test-1.1/debian/control new file mode 100644 index 0000000..a8c2a82 --- /dev/null +++ b/tests/harmattan/testapps/applauncherd-token-test-1.1/debian/control @@ -0,0 +1,22 @@ +Source: applauncherd-token-test +Section: unknown +Priority: extra +Maintainer: Marek Ruszczak +Build-Depends: pkg-config, debhelper (>= 7.0.50~), libqt4-dev, applauncherd-dev, applauncherd, aegis-builder (>= 1.4), libmeegotouch-dev +Standards-Version: 3.9.1 + +Package: applauncherd-token-test +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, libqt4-core, libqtgui4, applauncherd, libmeegotouchcore0 +Description: Application used to test applauncherd reexec + This application is used to test that installation of new security tokens + is properly handled by applauncherd deamon. + +Package: applauncherd-token-test-dbg +Architecture: devel +Depends: ${shlibs:Depends}, ${misc:Depends}, libqt4-core, libqtgui4, applauncherd, libmeegotouchcore0, applauncherd-token-test (= ${binary:Version}) +Description: Application used to test applauncherd reexec + This application with debug symbols is used to test that + installation of new security tokens is properly handled + by applauncherd deamon. + diff --git a/tests/harmattan/testapps/applauncherd-token-test-1.1/debian/copyright b/tests/harmattan/testapps/applauncherd-token-test-1.1/debian/copyright new file mode 100644 index 0000000..5aad6fe --- /dev/null +++ b/tests/harmattan/testapps/applauncherd-token-test-1.1/debian/copyright @@ -0,0 +1,16 @@ +This work was packaged for Debian by: + + Marek Ruszczak Fri, 04 Nov 2011 16:05:43 +0200 + +Copyright: + + Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + All rights reserved. + +This software, including documentation, is protected by copyright +controlled by Nokia Corporation. All rights are reserved. Copying, +including reproducing, storing, adapting or translating, any or all +of this material requires the prior written consent of Nokia +Corporation. This material also contains confidential information +which may not be disclosed to others without the prior written +consent of Nokia. diff --git a/tests/harmattan/testapps/applauncherd-token-test-1.1/debian/rules b/tests/harmattan/testapps/applauncherd-token-test-1.1/debian/rules new file mode 100755 index 0000000..b1260e0 --- /dev/null +++ b/tests/harmattan/testapps/applauncherd-token-test-1.1/debian/rules @@ -0,0 +1,74 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +CFLAGS = -Wall -g + +APPNAME := applauncherd-token-test + +Makefile: + qmake-qt4 + +build: build-stamp + +build-stamp: Makefile + dh_testdir + + # Add here commands to compile the package. + $(MAKE) + + touch $@ + +clean: Makefile + dh_testdir + dh_testroot + rm -f build-stamp + $(MAKE) clean + dh_clean + +install: + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/your_appname + $(MAKE) INSTALL_ROOT=$(CURDIR)/debian/$(APPNAME) install + +aegis: + # setting up aegis credentials + aegis-deb-add -control debian/applauncherd-token-test/DEBIAN/control .. debian/applauncherd-token-test.aegis=_aegis + # aegis-deb-add -control debian/applauncherd-token-test-dbg/DEBIAN/control .. debian/applauncherd-token-test-dbg.aegis=_aegis + +# Build architecture-independent files here. +binary-indep: +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: install + dh_testdir + dh_testroot + dh_installdocs + dh_installexamples + dh_installman + dh_link + dh_strip --dbg-package=$(APPNAME)-dbg + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch aegis +.PHONY: build clean binary-indep binary-arch binary install configure + diff --git a/tests/harmattan/testapps/applauncherd-token-test-1.1/main.cpp b/tests/harmattan/testapps/applauncherd-token-test-1.1/main.cpp new file mode 100644 index 0000000..fcfeb77 --- /dev/null +++ b/tests/harmattan/testapps/applauncherd-token-test-1.1/main.cpp @@ -0,0 +1,9 @@ +#include + +int main(int argc, char *argv[]) +{ + QCoreApplication a(argc, argv); + + return a.exec(); +} + diff --git a/tests/harmattan/testapps/applauncherd-token-test_1.1_armel.deb b/tests/harmattan/testapps/applauncherd-token-test_1.1_armel.deb new file mode 100644 index 0000000000000000000000000000000000000000..b3376ac4c51ac58e5e98e126b0af9daa70ad3088 GIT binary patch literal 4674 zcmcgwXH-+$wgv$a5ESXs5eSMjDWPMi!cm%lf|LXj0uovh2%!a}_l}5k1f&-QR8%^M z6sdwpFVaK^B@_vHc#iiB-@E7BbAP=x_E>wZJ?6LO`o2Bq7;7$mWeC#FL6sH?vvq{H zh}k;2K#*8IK0YbwYf`dO3JS6^e0-88^MCbHl9F;VC*Mw&e4@)sqGTjK^ zm5X$?Y?{ne*m=gL#NjAy>}ilRaR1mmE<_ss>~ghFniK%vAU6vVe5sR{ z*0G}nV=kN{Ywh!VQoJ%~*~jF%Vf&{HU`Se_bx;0klk8`3oTLlIe!QsCDk5oLZeFdz z+N};}Ppo8bU?ox7c@~p`lYu!z6eC#~mi64=xS;KhSZYmV;v0_=X>yaa$+@}H z%g-<^(ft0+-2FA#}@bc zy?+=@M+dK=>ywgx16O}78Ms=b_4{&TXl*=2_xxl=8Hp0cT~+&F(WCF!=~hm6mb#>h zEI!w$(%N)M7#7Q`^2rmg!Z!Y?YLsoL%IqvzIlZUZcQK122=F zJr0-~Qe@<97KIny&abal%5O8i{w(Y?RaC0u8+K}i0E3)sJ9pqm7Te1gqS&l+naDFo z4u)Iq%e3e$fO@-c<#;Um)_Ljo>CYVc3`bN)Jd0i+E>_WpH^*WVzin8M!a~1eHzkTl zX~st;q|4=r$I}lo`P9!?rudA1bub-8>p0}ERIvKwoHb5p(2i7=wrdyZ-#ipo$bUn@f1XG z^oovoWF%7_whPJ?WVci4rlp*~(u+pWN#FM|t>7UI-AqimA$TD|Qy}4w7hdfg;Cu*~ z2pJhI6oQ8QnM5ZU@=tkqOficYB<~7t zkkypY<|0dNq=@l4NSUx=!`IKB#w+(pJSJ z1`HM_iw0gScpTfQq&SC%UK!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vnGku$?j>5a&xf?!HadzyP#;I6pj5Z61 z_6|u@Vo%(TF=jPp+bnr9hQap&H!Vr48v9D2kFXvOUJNV0Q1jV%c|GowORus#-DB&{vZ0QT@^DEkM(?nO5XD=IBrsWQD6w7--?RW^S|Uu^49nNP20`@~cTPh2nhB`I?lknOwG z_1|^ramVz`D7tvMExvNf1bsqfl`tRe^V0!W#oPugK3q2$Ewou@hQ6@ zT|FJ4upi@-nH>@ag}I;|AqYMfh%-z@0OIC`fOxprIlz!mF*FQ?7DKx_!CVCRB>sB@ z3U*R|pP+vMDogz0R~ZR&_c&Slj}`xN8#=~@ii#d?sFMO7{ipB0v@}6N?3`doV;BSq zva^GsQ2*KdpZNWykADaK1;rEOiJ>&uq zA1eK!^og6Fn^%_jMWX*L*Zc%}4gdfE literal 0 HcmV?d00001 diff --git a/tests/harmattan/testscripts/test-security.py b/tests/harmattan/testscripts/test-security.py index c643194..73601c2 100644 --- a/tests/harmattan/testscripts/test-security.py +++ b/tests/harmattan/testscripts/test-security.py @@ -16,6 +16,7 @@ # of this file. import unittest +import re from utils import * class SecurityTests(unittest.TestCase): @@ -398,15 +399,14 @@ class SecurityTests(unittest.TestCase): packageFileName = '/usr/share/fala_images/applauncherd-token-test_1.0_armel.deb' packageName = 'applauncherd-token-test' token = 'applauncherd-token-test::applauncherd-test-token' - - #check that facebook is NOT installed - notInstaled, op = commands.getstatusoutput('dpkg -l %s' %(packageName)) - if (notInstaled==0) : + + #check that test package is NOT installed + if (isPackageInstalled(packageName)) : debug('Tested package "%s" is isntalled, removing it.' %(packageName)) self.__test_reexec_remove_test_package(packageName) initialBoosters = get_booster_pid() - + def waitFoNewBoosters(oldBoosters) : oldBoosters = set(oldBoosters) for i in range(3) : @@ -415,7 +415,7 @@ class SecurityTests(unittest.TestCase): return newBoosters time.sleep(1) return None - + #send sighup just in case to clear capabilites of applaucherd (prevent problems from other bugy installations) commands.getstatusoutput('kill -hup `pgrep applauncherd`') @@ -433,7 +433,7 @@ class SecurityTests(unittest.TestCase): debug('Installing test packege "%s"...' %(packageName)) st, op = commands.getstatusoutput('dpkg -i %s' %(packageFileName)) - self.assertEqual(st, 0, 'Installation of "%s" failed see:\n%s' %(packageName, op)) + self.assertEqual(st, 0, 'Installation of "%s" failed (error code: %s) see:\n%s' %(packageName, st, op)) debug('...Instalation was successful.') newBoostersPids = waitFoNewBoosters(oldBoostersPids) @@ -459,6 +459,75 @@ class SecurityTests(unittest.TestCase): debug('Restoring system to initial state: removing test package after test was complleted.') self.__test_reexec_remove_test_package(packageName) + def test_that_other_apps_dont_gain_new_token(self) : + """ + Checks that when running application is upgraded and upgrade contains new token, then + this runing application doesn't gain new token until it is restarted (re-exec of + applauncherd don't have impact on child processes). + It is assumed that application is boosted (run by invoker). + """ + + package1FileName = '/usr/share/fala_images/applauncherd-token-test_1.0_armel.deb' + package2FileName = '/usr/share/fala_images/applauncherd-token-test_1.1_armel.deb' + packageName = 'applauncherd-token-test' + firstToken = 'applauncherd-token-test::applauncherd-test-token' + secondToken = 'applauncherd-token-test::applauncherd-test-second-token' + appName = "fala-token-test-app" + + #check that test package is NOT installed + if (isPackageInstalled(packageName)) : + debug('Tested package "%s" is isntalled, removing it.' %(packageName)) + self.__test_reexec_remove_test_package(packageName) + + versionSearch = re.compile(r"_(\d+(\.\d+)+)_\w+\.deb") + debug("Installing '%s' in version: %s" %(packageName, versionSearch.search(package1FileName).group(1))) + st, op = commands.getstatusoutput('dpkg -i %s' %(package1FileName)) + self.assertEqual(st, 0, 'Installation of "%s" failed (error code: %s) see:\n%s' %(packageName, st, op)) + debug('...Instalation was successful.') + + try : + p = run_app_as_user_with_invoker(appName, 'e') + appPid = wait_for_app(appName) + self.assert_(appPid, "Application '%s' was not launched successfuly" %(appName)) + + oldCredentials = get_creds(pid = appPid) + self.assert_(oldCredentials, "Failed to fetch credentials for application '%s' with pid: %s." %(appName, appPid)) + self.assert_(firstToken in oldCredentials, "Expected credential '%s' not found for '%s' application." + %(firstToken, appName)) + self.assert_((packageName+"::"+packageName) in oldCredentials, "Default package credential '%s' not found for '%s' application." + %(packageName+"::"+packageName, appName)) + self.assert_(not (secondToken in oldCredentials), "Old version of %s shouldn't have '%s' token" + %(appName, secondToken)) + + debug("Instaling upgrade of package '%s' with version %s" %(packageName, versionSearch.search(package2FileName).group(1))) + st, op = commands.getstatusoutput('dpkg -i %s' %(package2FileName)) + self.assertEqual(st, 0, 'Upgrade of package "%s" failed (error code: %s) see:\n%s' %(packageName, st, op)) + debug('...Instalation was successful.') + + newCredentials = get_creds(pid = appPid) + self.assert_(newCredentials, "Failed to fetch credentials for application '%s' with pid: %s. Application might have crush." %(appName, appPid)) + + credDiff = set(oldCredentials).symmetric_difference(set(newCredentials)) + self.assertEqual(len(credDiff), 0, "Application '%s' has a diffrance in tokens: %s, after installing update (application was not restarted)." + %(appName, credDiff)) + + kill_process(appName) + time.sleep(2) + + p = run_app_as_user_with_invoker(appName, 'e') + appPid = wait_for_app(appName) + newCredentials = get_creds(pid = appPid) + credDiff = set(oldCredentials).symmetric_difference(set(newCredentials)) + self.assertEqual(credDiff, set([secondToken]), "After rerun of '%s' it should gain only '%s' token, not: %s" + %(appName, secondToken, credDiff)) + + finally: + debug('Restoring system to initial state: removing test package after test was complleted.') + kill_process(appName) + self.__test_reexec_remove_test_package(packageName) + + + # main if __name__ == '__main__': # When run with testrunner, for some reason the PATH doesn't include