| 1 |
**Do you want to contribute to LemonLdap::NG project ?** |
| 2 |
|
| 3 |
Contribute to Project |
| 4 |
===================== |
| 5 |
|
| 6 |
LemonLDAP::NG is mostly written in Perl and Javascript. Community |
| 7 |
applies the following rules: |
| 8 |
|
| 9 |
- Perl: |
| 10 |
|
| 11 |
- code must be written in modern object-oriented code (using |
| 12 |
`Mouse <https://metacpan.org/pod/Mouse>`__) *(except handler and |
| 13 |
Apache::Session inheritance)* |
| 14 |
- code must be formatted using the `make tidy` command |
| 15 |
|
| 16 |
- Javascript: |
| 17 |
|
| 18 |
- Javascript code is written in ``<component>/site/js-src`` and |
| 19 |
bundled using `rollupjs <https://rollupjs.org/>`_: ``make minify`` will |
| 20 |
generate JS files |
| 21 |
|
| 22 |
Get code |
| 23 |
-------- |
| 24 |
|
| 25 |
Configure SSH |
| 26 |
^^^^^^^^^^^^^ |
| 27 |
|
| 28 |
*On Debian developper station :* |
| 29 |
|
| 30 |
:: |
| 31 |
|
| 32 |
ssh-keygen -o -t rsa -b 4096 -C "your@email" |
| 33 |
|
| 34 |
Go to your gitlab account : https://gitlab.ow2.org/profile/keys |
| 35 |
|
| 36 |
:: |
| 37 |
|
| 38 |
cat ~/.ssh/id_rsa.pub |
| 39 |
|
| 40 |
Copy id_rsa.pub content to key section and enter a name into "Title" and click "Add key" button. |
| 41 |
Test ssh connexion : |
| 42 |
|
| 43 |
:: |
| 44 |
|
| 45 |
ssh -T [email protected] |
| 46 |
|
| 47 |
Accept messages |
| 48 |
|
| 49 |
Configure Git |
| 50 |
^^^^^^^^^^^^^ |
| 51 |
|
| 52 |
As *user:* |
| 53 |
|
| 54 |
:: |
| 55 |
|
| 56 |
git config --global user.name "Name Surname" |
| 57 |
git config --global user.email "your@mail" |
| 58 |
git config --global color.ui true |
| 59 |
git config --list |
| 60 |
|
| 61 |
Clone repository |
| 62 |
^^^^^^^^^^^^^^^^ |
| 63 |
|
| 64 |
As *user*, create directory in directory: |
| 65 |
|
| 66 |
:: |
| 67 |
|
| 68 |
git clone [email protected]:lemonldap-ng/lemonldap-ng.git |
| 69 |
cd lemonldap-ng/ |
| 70 |
|
| 71 |
# Use your own clone for pushes |
| 72 |
git remote set-url --push origin [email protected]:user/lemonldap-ng.git |
| 73 |
|
| 74 |
|
| 75 |
Run LemonLDAP::NG |
| 76 |
------------------- |
| 77 |
|
| 78 |
Container-based setup |
| 79 |
^^^^^^^^^^^^^^^^^^^^^ |
| 80 |
|
| 81 |
The following commands are based on `Podman <https://podman.io/>`. To get them working in a |
| 82 |
Docker environment, just replace ``podman`` with ``docker``. |
| 83 |
|
| 84 |
Build image: |
| 85 |
|
| 86 |
:: |
| 87 |
|
| 88 |
podman build . -t llng-local-dev |
| 89 |
|
| 90 |
Start container: |
| 91 |
|
| 92 |
:: |
| 93 |
|
| 94 |
podman run -it -v ./:/app -p 8080:8080 -p 3000:3000 llng-local-dev |
| 95 |
|
| 96 |
Open http://auth.llng.localhost:8080/ in your browser. |
| 97 |
|
| 98 |
Run tests: |
| 99 |
|
| 100 |
:: |
| 101 |
|
| 102 |
podman run -it -v ./:/app llng-local-dev make test |
| 103 |
|
| 104 |
.. note:: |
| 105 |
|
| 106 |
this will not be efficient if you want to run tests multiple times (eg while developing) as the patch and build steps will be run each |
| 107 |
time. You can speed-up this by starting the dev. server container, then running your tests inside the running container with the following |
| 108 |
command. |
| 109 |
|
| 110 |
:: |
| 111 |
|
| 112 |
podman exec -it <container-id> make test |
| 113 |
|
| 114 |
|
| 115 |
Manual setup |
| 116 |
^^^^^^^^^^^^ |
| 117 |
|
| 118 |
Install basic tools |
| 119 |
~~~~~~~~~~~~~~~~~~~ |
| 120 |
|
| 121 |
As *root:* |
| 122 |
|
| 123 |
:: |
| 124 |
|
| 125 |
apt install make devscripts equivs yui-compressor git terser rollup node-rollup-plugin-babel autopkgtest cpanminus |
| 126 |
|
| 127 |
|
| 128 |
Install dependencies |
| 129 |
~~~~~~~~~~~~~~~~~~~~ |
| 130 |
|
| 131 |
:: |
| 132 |
|
| 133 |
# Install build dependancies |
| 134 |
mk-build-deps debian/control |
| 135 |
sudo apt install ./lemonldap-ng-build-deps*deb |
| 136 |
apt install apache2 libapache2-mod-fcgid libapache2-mod-perl2 # install Apache |
| 137 |
cpanm Perl::Tidy@$(make tidyversion) |
| 138 |
|
| 139 |
For SAML: |
| 140 |
|
| 141 |
:: |
| 142 |
|
| 143 |
apt install liblasso-perl libglib-perl |
| 144 |
|
| 145 |
Configure hosts file |
| 146 |
~~~~~~~~~~~~~~~~~~~~ |
| 147 |
|
| 148 |
:: |
| 149 |
|
| 150 |
echo '127.0.0.1 auth.example.com manager.example.com test1.example.com test2.example.com' >> /etc/hosts |
| 151 |
|
| 152 |
Unit tests |
| 153 |
~~~~~~~~~~ |
| 154 |
|
| 155 |
Launch unit tests: |
| 156 |
|
| 157 |
:: |
| 158 |
|
| 159 |
make test # or manager_test, portal_test, ... to launch unit tests |
| 160 |
|
| 161 |
Same tests launched on a simulated install |
| 162 |
|
| 163 |
:: |
| 164 |
|
| 165 |
make autopkgtest # or autopkg_portal, autopkg_manager, ... to launch unit tests |
| 166 |
|
| 167 |
Execute an unit test : |
| 168 |
|
| 169 |
:: |
| 170 |
|
| 171 |
# Building project |
| 172 |
cd ~/lemonldap-ng/; make |
| 173 |
# Go to parent test directory |
| 174 |
cd ~/lemonldap-ng/lemonldap-ng-portal |
| 175 |
# and execute the unit test: |
| 176 |
prove -v t/67-CheckUser.t |
| 177 |
|
| 178 |
# Run unit test at debug log level |
| 179 |
DEBUG=1 prove -v t/67-CheckUser.t |
| 180 |
|
| 181 |
Launch tests with LDAP backend |
| 182 |
|
| 183 |
:: |
| 184 |
|
| 185 |
apt install slapd |
| 186 |
make LLNGTESTLDAP=1 test |
| 187 |
|
| 188 |
.. note:: |
| 189 |
|
| 190 |
slapd might fail to start if you use Apparmor or SELinux, check your system logs if that happens |
| 191 |
|
| 192 |
Other commands |
| 193 |
~~~~~~~~~~~~~~ |
| 194 |
|
| 195 |
* Start a test web server on port 19876:: |
| 196 |
|
| 197 |
make start_web_server # TESTUSESSL=1 to enable SSL engine (only available for Apache) |
| 198 |
make start_web_server TESTWEBSERVER=nginx # to use Nginx web server |
| 199 |
make stop_web_server |
| 200 |
make reload_web_server # to reload LL:NG conf |
| 201 |
|
| 202 |
* Clean test files :: |
| 203 |
|
| 204 |
make clean |
| 205 |
|
| 206 |
* Compile Javascript and minify :: |
| 207 |
|
| 208 |
make minify |
| 209 |
|
| 210 |
* Rebuild manager tree, this is needed everytime you add a new option :: |
| 211 |
|
| 212 |
make json |
| 213 |
|
| 214 |
* Update Perl manifest :: |
| 215 |
|
| 216 |
make manifest |
| 217 |
|
| 218 |
* Reformat Perl files :: |
| 219 |
|
| 220 |
make tidy |
| 221 |
|
| 222 |
Add a translation key |
| 223 |
~~~~~~~~~~~~~~~~~~~~~ |
| 224 |
|
| 225 |
If you need to create a new parameter in Manager or add a new message in Portal, you must add a key in JSON languages files. |
| 226 |
|
| 227 |
To ease this process, use the script ``scripts/addTrEntry`` provided in the sources: |
| 228 |
|
| 229 |
:: |
| 230 |
|
| 231 |
$ scripts/addTrEntry |
| 232 |
Usage: |
| 233 |
scripts/addTrEntry <option> key enText <frText> |
| 234 |
scripts/addTrEntry <option> key '$otherkey' |
| 235 |
|
| 236 |
Options: |
| 237 |
--portal -p: add entry in portal translation instead of manager |
| 238 |
--modify -m: modify an existing entry |
| 239 |
--delete -d: delete an existing key |
| 240 |
--reorder -r: reorder files |
| 241 |
--help -h: display this |
| 242 |
|
| 243 |
|
| 244 |
For example: |
| 245 |
|
| 246 |
:: |
| 247 |
|
| 248 |
$ scripts/addTrEntry MyNewParameter 'A new parameter' 'Un nouveau paramètre' |
| 249 |
|
| 250 |
|
| 251 |
Documentation |
| 252 |
~~~~~~~~~~~~~ |
| 253 |
|
| 254 |
Install dependencies: |
| 255 |
|
| 256 |
:: |
| 257 |
|
| 258 |
apt install python3-sphinx python3-sphinx-bootstrap-theme |
| 259 |
|
| 260 |
Then edit sources in doc/sources/admin. |
| 261 |
|
| 262 |
You can check the result with: |
| 263 |
|
| 264 |
:: |
| 265 |
|
| 266 |
make documentation |
| 267 |
firefox doc/pages/documentation/current/start.html |
| 268 |
|
| 269 |
Javascript |
| 270 |
~~~~~~~~~~ |
| 271 |
|
| 272 |
Javascript code is produced by `rollupjs <https://rollupjs.org/>`_. |
| 273 |
|
| 274 |
Source script must be created in ``lemonldap-ng-portal/site/js-src``, then run this command: |
| 275 |
|
| 276 |
:: |
| 277 |
|
| 278 |
make minify |
| 279 |
|
| 280 |
On Debian, you can install rollupjs and the needed dependencies with: |
| 281 |
|
| 282 |
:: |
| 283 |
|
| 284 |
apt install rollup node-rollup-plugin-babel |
| 285 |
|
| 286 |
|
| 287 |
Debugging |
| 288 |
~~~~~~~~~ |
| 289 |
|
| 290 |
$req and req->{env} variables can be dumped by using logParams = 1 in `lemonldap-ng.ini` file. |
| 291 |
High debug level can be enabled in `Manager/Conf/Parser.pm` with `HIGHDEBUG => 1` |