Skip to content
A py-fortress sample project demos RBAC0 in Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
sample
.gitignore
LICENSE
README.md

README.md

py-fortress-sample README

This installs py-fortress and runs a simple test program of how the RBAC API works._


Prerequisites

Minimum hardware requirements:

  • 1 Core
  • 1 GB RAM

Minimum software requirements:


Clone py-fortress-sample, prepare for usage

  1. Clone py-fortress-sample

    git clone https://github.com/shawnmckinney/py-fortress-sample.git
    
  2. Change folder into the project:

    cd py-fortress-sample
    

    you should now be here: py-fortress-sample

  3. Now edit the config file:

    vi sample/ldap/py-fortress-cfg.json
    

    cfg file is here: py-fortress-sample/sample/ldap/py-fortress-cfg.json

  4. Set the LDAP Port

    ...
    "ldap": {
      ...
      "port": 32768,
    ...
    

    use value obtained earler

  5. Update the connection parameters (pick one):

    a. apacheds:

    "dn": "uid=admin,ou=system",
    

    b. openldap:

    "dn": "cn=Manager,dc=example,dc=com",
    

    per your earlier choice of docker image


Setup Python Runtime and Install py-fortress

  1. Prepare your terminal for execution of python3. From the main dir of the git repo:

    pyvenv env
    . env/bin/activate
    

    from the py-fortress-sample folder

  2. Install py-fortress:

    pip3 install py-fortress
    
  3. Change folder to where the sample program is:

    cd sample/ldap
    

    you're now here: py-fortress-sample/sample/ldap

  4. Prepare the Directory Information Tree:

    You can think of this command as creating tables in a new database instance.

    initldap
    

    initldap is a python script, created during install of py-fortress package, that maps here: pyfortress.test.test_dit_dao

  5. Examine the output, should finish almost instaneously (< 1 sec).

    initldap
    2018-04-06 06:02:45,895 INFO Initialize py-fortress ldap...
    2018-04-06 06:02:45,896 INFO ldap host: localhost, port:32768
    test_bootstrap
    test_bootstrap success
    .
    ----------------------------------------------------------------------
    Ran 1 test in 0.365s
    

    If it hangs more than a second or two, ctrl-c to kill it. A bug in the ldap pool causes a hang, but it indicates something went wrong with your ldap server setup and/or ldap port wrong...

  6. Run the test program:

    python3 test_samples.py 
    
  7. View the output:

    ----------------------------------------------------------------------
    Ran 18 tests in 2.388s
    OK
    
  8. Study the APIs in test_samples.py module.

You can’t perform that action at this time.