Skip to content

Test Frontend

L. Le Meur edited this page Nov 10, 2022 · 1 revision

A Test Frontend server is provided as a specific package in the codebase, which mimics a content management system. It provides a web user interface for managing publications, users and licenses. It also provides a REST API which mimics the way you will connect your distribution platform to the license server.

Its sole goal is to help you testing the License and License Status servers. It should never be used in production.

Its public functionalities are:

  • Fetch a license by id
  • Fetch a licensed publication by license id

Install the Test Frontend Server

To install properly the Test Frontend Server, you must compile this go package and install several npm packages.

Note: You will have to use an old version of npm, e.g. npm 6.12.0.

In the following example, we'll use GOPATH (not a specific project directory). To install and test the npm packages, type:

cd $GOPATH
# clone the project
git clone https://github.com/readium/readium-lcp-server.git src/github.com/readium/readium-lcp-server
cd src/github.com/readium/readium-lcp-server/frontend/manage
# override the use of the deprecated git protocol (if needed)
git config --global url."https://github".insteadOf git://github
# the following command takes a while; don't mind warnings
npm install

Environment variable

Like the License Server and Status Server, the Test Frontend Server will search its configuration file in the go bin directory by default; but the path to the file should be changed using an environment variable:

  • READIUM_FRONTEND_CONFIG for the Frontend test server

Configuration of the Test Frontend Server

frontend section

frontend: parameters associated with the Test Frontend Server.

  • host: the public server hostname, hostname by default
  • port: the listening port, 8991 by default
  • public_base_url: the URL used by the Frontend node.js software to communicate with this Frontend Test Server; combination of the host and port values on http by default.
  • database: the URI formatted connection string to the database, sqlite3://file:frontend.sqlite?cache=shared&mode=rwc by default. mysql://login:password@/dbname?parseTime=true if your using MySQL.
  • master_repository: repository where the uploaded EPUB files are stored before encryption.
  • encrypted_repository: repository where the encrypted EPUB files are stored after upload. The LCP server must have access to the path declared here, as it will move each encrypted file to its final storage folder on notification of encryption from the Frontend Server.
  • directory: the directory containing the client web app; by default $GOPATH/src/github.com/readium/readium-lcp-server/frontend/manage.
  • provider_uri: provider uri, which will be inserted in all licenses produced via this test frontend.
  • right_print: allowed number of printed pages, which will be inserted in all licenses produced via this test frontend.
  • right_copy: allowed number of copied characters, which will be inserted in all licenses produced via this test frontend.

other required sections

The Test Frontend Server must communicate with the License Server and the License Status Server. This is why it must contain the following sections, with the values defined above.

lcp

  • public_base_url

lsd

  • public_base_url

lcp_update_auth

  • username
  • password

lsd_notify_auth

  • username
  • password

Sample config

Here is a Test Frontend Server sample config:

frontend:
    host: "192.168.0.1"
    port: 8991
    database: "sqlite3://file:/usr/local/var/lcp/db/frontend.sqlite?cache=shared&mode=rwc"
    master_repository: "/usr/local/var/lcp/files/master"
    encrypted_repository: "/usr/local/var/lcp/files/encrypted"
    provider_uri: "https://www.example.net"
    right_print: 10
    right_copy: 2000

lcp:
  public_base_url:  "http://192.168.0.1:8989"
lsd:
  public_base_url:  "http://192.168.0.1:8990"
lcp_update_auth: 
    username: "adm_username"
    password: "adm_password"
lsd_notify_auth: 
    username: "adm_username"
    password: "adm_password"

Initialization

Starting the frontend UI requires an initial configuration, as it must read the dynamically created "config.js" file:

#start the frontend server, this creates config.js
frontend
# stop
<ctrl-C>
# compile the typescript files, check that the frontend UI is launched
npm start
# when the frontend UI has appeared, stop
<ctrl-C>

After the frontend server has been launched, you can access the server GUI via its base url, as configured in the License Server config file.