Permalink
Browse files

Add unit tests for user switching.

  • Loading branch information...
1 parent d98ac2c commit c072d96ee56e534eee4ed769f467b1e7ee582586 @FooBarWidget FooBarWidget committed Apr 17, 2012
View
@@ -43,6 +43,7 @@ doc/*.html
test/test.log
test/apache2.log
test/config.yml
+test/config.json
test/coverage
test/cxx/CxxTestMain
test/oxt/oxt_test_main
@@ -419,6 +419,13 @@ def aggregate_sources?
Utils/fib.h
Utils/fibpriv.h
)
+ define_component 'Utils/jsoncpp.o',
+ :source => 'Utils/jsoncpp.cpp',
+ :category => :other,
+ :deps => %w(
+ Utils/json.h
+ Utils/json-forwards.h
+ )
#'BCrypt.o' => %w(
# BCrypt.cpp
View
@@ -0,0 +1,42 @@
+{
+ //// This file contains system-specific configuration options that the test suite needs.
+ //// Please customize it for your system.
+
+ // These are the usernames and group names of normal, non-administrator
+ // users and groups. Preferably, these are user and group accounts that
+ // are normally not used.
+ //
+ // These users and groups MUST be able to access this 'test' directory,
+ // otherwise the tests will fail.
+
+ //// Good values for OS X:
+ "normal_user_1": "_www",
+ "normal_user_2": "daemon",
+ // Must not be "nobody".
+ "default_user": "_sandbox",
+ // Must not be normal_user_1's primary group.
+ "normal_group_1": "daemon",
+ // Must not be normal_user_2's primary group.
+ "normal_group_2": "_sandbox",
+ // Must not be default_user's primary group. Must not be "nobody".
+ "default_group": "_www",
+
+ ///// Good values for Linux and FreeBSD. Same restrictions apply.
+ //"normal_user_1": "games",
+ //"normal_user_2": "daemon",
+ //"default_user": "man",
+ //"normal_group_1": "daemon",
+ //"normal_group_2": "man",
+ //"default_group": "games",
+
+ // A nonexistant username, group name, user ID and group ID.
+ "nonexistant_user": "xxxxxxxxxxxxxxxxxxx",
+ "nonexistant_group": "xxxxxxxxxxxxxxxxxxx",
+ "nonexistant_uid": 9999,
+ "nonexistant_gid": 9999,
+
+ // If you want to run the Nginx integration tests, then set the following
+ // config option to the full path of the Nginx binary. This Nginx binary *must*
+ // be compiled with Phusion Passenger support!
+ // nginx: /usr/local/sbin/nginx
+}
@@ -1,5 +1,6 @@
#include <TestSupport.h>
#include <ApplicationPool2/Spawner.h>
+#include <Utils/json.h>
using namespace Passenger;
using namespace Passenger::ApplicationPool2;
@@ -28,17 +29,17 @@ namespace tut {
}
};
- DEFINE_TEST_GROUP(ApplicationPool2_DirectSpawnerTest);
+ DEFINE_TEST_GROUP_WITH_LIMIT(ApplicationPool2_DirectSpawnerTest, 80);
#include "SpawnerTestCases.cpp"
- TEST_METHOD(30) {
+ TEST_METHOD(70) {
// If the application didn't start within the timeout
// then whatever was written to stderr is used as the
// SpawnException error page.
Options options = createOptions();
options.appRoot = "stub";
- options.startCommand = "bash\1" "-c\1" "echo hello world >&2; sleep 60";
+ options.startCommand = "perl\1" "-e\1" "print STDERR \"hello world\\n\"; sleep(60)";
options.startupFile = ".";
options.startTimeout = 300;
@@ -56,13 +57,13 @@ namespace tut {
}
}
- TEST_METHOD(31) {
+ TEST_METHOD(71) {
// If the application crashed during startup without returning
// a proper error response, then its stderr output is used
// as error response instead.
Options options = createOptions();
options.appRoot = "stub";
- options.startCommand = "bash\1" "-c\1" "echo hello world >&2";
+ options.startCommand = "perl\1" "-e\1" "print STDERR \"hello world\\n\"";
options.startupFile = ".";
DirectSpawner spawner(bg.safe, *resourceLocator, generation);
@@ -1,6 +1,7 @@
#include <TestSupport.h>
#include <ApplicationPool2/Spawner.h>
#include <Logging.h>
+#include <Utils/json.h>
#include <unistd.h>
#include <climits>
#include <signal.h>
@@ -50,11 +51,11 @@ namespace tut {
}
};
- DEFINE_TEST_GROUP(ApplicationPool2_SmartSpawnerTest);
+ DEFINE_TEST_GROUP_WITH_LIMIT(ApplicationPool2_SmartSpawnerTest, 80);
#include "SpawnerTestCases.cpp"
- TEST_METHOD(30) {
+ TEST_METHOD(70) {
// If the preloader has crashed then SmartSpawner will
// restart it and try again.
Options options = createOptions();
@@ -73,7 +74,7 @@ namespace tut {
spawner->spawn(options);
}
- TEST_METHOD(31) {
+ TEST_METHOD(71) {
// If the preloader still crashes after the restart then
// SmartSpawner will throw an exception.
Options options = createOptions();
@@ -90,7 +91,7 @@ namespace tut {
}
}
- TEST_METHOD(32) {
+ TEST_METHOD(72) {
// If the preloader didn't start within the timeout
// then it's killed and an exception is thrown, with
// whatever stderr output as error page.
@@ -123,7 +124,7 @@ namespace tut {
}
}
- TEST_METHOD(33) {
+ TEST_METHOD(73) {
// If the preloader crashed during startup without returning
// a proper error response, then its stderr output is used
// as error response instead.
@@ -155,7 +156,7 @@ namespace tut {
}
}
- TEST_METHOD(34) {
+ TEST_METHOD(74) {
// If the preloader encountered an error, then the resulting SpawnException
// takes note of the process's environment variables.
Options options = createOptions();
Oops, something went wrong.

0 comments on commit c072d96

Please sign in to comment.