diff options
author | Marcin Siodelski <marcin@isc.org> | 2016-08-18 10:30:45 +0200 |
---|---|---|
committer | Marcin Siodelski <marcin@isc.org> | 2016-08-18 10:30:45 +0200 |
commit | 750fa1da22069a1899e8b3263600a7ab3314e071 (patch) | |
tree | d4f2a16b296e2b14c65dfbfaee64c490d7500734 /src/lib/dhcpsrv/database_backends.dox | |
parent | [4489] Using keatest_readonly db user for read only mode tests. (diff) | |
download | kea-750fa1da22069a1899e8b3263600a7ab3314e071.tar.xz kea-750fa1da22069a1899e8b3263600a7ab3314e071.zip |
[4489] Updated dev-guide with database prerequisites for unit tests.
Diffstat (limited to 'src/lib/dhcpsrv/database_backends.dox')
-rw-r--r-- | src/lib/dhcpsrv/database_backends.dox | 132 |
1 files changed, 0 insertions, 132 deletions
diff --git a/src/lib/dhcpsrv/database_backends.dox b/src/lib/dhcpsrv/database_backends.dox index 104318ece2..682bc5dea0 100644 --- a/src/lib/dhcpsrv/database_backends.dox +++ b/src/lib/dhcpsrv/database_backends.dox @@ -83,137 +83,5 @@ - <b>user</b> - database user ID under which the database is accessed. If not specified, no user ID is used - the database is assumed to be open. - @section dhcp-backend-unittest Running Unit Tests - - With the use of databases requiring separate authorisation, there are - certain database-specific pre-requisites for successfully running the unit - tests. These are listed in the following sections. - - @subsection dhcp-mysql-unittest MySQL Unit Tests - - A database called <i>keatest</i> must be created. A database user, also called - <i>keatest</i> (and with a password <i>keatest</i>) must also be created and - be given full privileges in that database. The unit tests create the schema - in the database before each test and delete it afterwards. - - In detail, the steps to create the database and user are: - - -# Log into MySQL as root: - @verbatim - % mysql -u root -p - Enter password: - : - mysql>@endverbatim\n - -# Create the test database. This must be called "keatest": - @verbatim - mysql> CREATE DATABASE keatest; - mysql>@endverbatim\n - -# Create the user under which the test client will connect to the database - (the apostrophes around the words <i>keatest</i> and <i>localhost</i> are - required): - @verbatim - mysql> CREATE USER 'keatest'@'localhost' IDENTIFIED BY 'keatest'; - mysql>@endverbatim\n - -# Grant the created user permissions to access the <i>keatest</i> database - (again, the apostrophes around the words <i>keatest</i> and <i>localhost</i> - are required): - @verbatim - mysql> GRANT ALL ON keatest.* TO 'keatest'@'localhost'; - mysql>@endverbatim\n - -# Exit MySQL: - @verbatim - mysql> quit - Bye - %@endverbatim - - The unit tests are run automatically when "make check" is executed (providing - that Kea has been build with the \--with-dhcp-mysql switch (see the installation - section in the <a href="http://kea.isc.org/docs/kea-guide.html">Kea Administrator - Reference Manual</a>). - - @subsection dhcp-pgsql-unittest PostgreSQL Unit Tests - - Conceptually, the steps required to run PostgreSQL unit-tests are the same as - in MySQL. First, a database called <i>keatest</i> must be created. A database - user, also called <i>keatest</i> (that will be allowed to log in using password - <i>keatest</i>) must be created and given full privileges in that database. The - unit tests create the schema in the database before each test and delete it - afterwards. - - PostgreSQL set up differs from system to system. Please consult your OS-specific - PostgreSQL documentation. The remainder of that section uses Ubuntu 13.10 x64 as - example. On Ubuntu, after installing PostgreSQL (with <tt>sudo apt-get install - postgresql</tt>), it is installed as user <i>postgres</i>. To create new databases - or add new users, initial commands must be issued as user postgres: - -@verbatim -$ sudo -u postgres psql postgres -[sudo] password for thomson: -psql (9.1.12) -Type "help" for help. -postgres=# CREATE USER keatest WITH PASSWORD 'keatest'; -CREATE ROLE -postgres=# CREATE DATABASE keatest; -CREATE DATABASE -postgres=# GRANT ALL PRIVILEGES ON DATABASE keatest TO keatest; -GRANT -postgres=# \q -@endverbatim - - Now we are back to our regular, unprivileged user. Try to log into the newly - created database using keatest credentials: -@verbatim -$ psql -d keatest -U keatest -Password for user keatest: -psql (9.1.12) -Type "help" for help. - -keatest=> -@endverbatim - - If instead of seeing keatest=> prompt, your login will be refused with error - code about failed peer or indent authentication, it means that PostgreSQL is - configured to check unix username and reject login attepts if PostgreSQL names - are different. To alter that, PostgreSQL configuration must be changed. - Alternatively, you may set up your environment, so the tests would be run from - unix account keatest. <tt>/etc/postgresql/9.1/main/pg_hba.conf</tt> config file - had to betweaked. It may be in a different location in your system. The following - lines: - -@verbatim -local all all peer -host all all 127.0.0.1/32 md5 -host all all ::1/128 md5 -@endverbatim - - were replaced with: - -@verbatim -local all all password -host all all 127.0.0.1/32 password -host all all ::1/128 password -@endverbatim - - Another possible problem is to get no password prompt, in general because - you have no <tt>pg_hba.conf</tt> config file and everybody is by default - trusted. As it has a very bad effect on the security you should have - been warned it is a highly unsafe config. The solution is the same, - i.e., require password or md5 authentication method. If you lose - the postgres user access you can add first: -@verbatim -local all postgres trust -@endverbatim - to trust only the local postgres user. Note the postgres user can - be pgsql on some systems. - - Please consult your PostgreSQL user manual before applying those changes as - those changes may expose your other databases that you run on the same system. - In general case, it is a poor idea to run anything of value on a system - that runs tests. Use caution! - - The unit tests are run automatically when "make check" is executed (providing - that Kea has been build with the \--with-dhcp-pgsql switch (see the installation - section in the <a href="http://kea.isc.org/docs/kea-guide.html">Kea Administrator - Reference Manual</a>). */ |