Consortia cases covered with Karate tests

Consortia cases covered with Karate tests

Setup tenants

We define two tenants called 'centralTenant' and 'universityTenant' with 'consortiaAdmin' and 'universityUser1' users respectively. Then set up each tenant in 6 steps:

  1. POST required tenant to okapi

  2. Enable ['mod-login', 'mod-permissions', 'mod-configuration'] modules to be able to set up admin users. Notice that ['mod-users'] will also be enabled automatically.

  3. Create necessary user with credentials, and then add existing permissions of enabled modules to the user.

  4. Enable ['folio_users'] - when posting non-central tenants (isCentral = false) to consortium shadow admin user (of 'centralAdmin') will be created automatically with permissions ['ui-users.editperms'] so we need this module enabled before posting non-central tenant. Note that ['mod-password-validator', 'mod-authtoken', 'mod-users-bl', 'mod-pubsub', 'mod-notes', 'mod-inventory-storage', 'mod-circulation-storage', 'mod-event-config', 'mod-template-engine', 'mod-calendar', 'mod-patron-blocks', 'mod-email', 'mod-sender', 'mod-notify', 'mod-feesfines', 'mod-circulation', 'mod-tags'] will also be enabled automatically.

  5. Enable ['mod-consortia'].

  6. Add ['consortia.all'] permission to both created users. 

Note. Predefined users has fields [id, username, password, tenant] so whenever we do login these fields will be populated automatically along with [okapitoken] (if login was successful) so if we do not want to switch between tenants explicitly we just need to pick right user to do required request and leave headers as follows:

Consortium API tests

Scenario

sub-scenario(s)

status code

Scenario

sub-scenario(s)

status code

1

 

Create, Read, Update a consortium for positive cases

Create a consortium

201

2

Get consortiums

200

3

Get consortium

200

4

Update consortium

200

5

2

 

Create, Read, Update a consortium for negative cases

Attempt to get non-existing consortium

404

6

Attempt to update consortium with non-equal id in payload

400

7

Attempt to update non-existing consortium

404

8

Attempt to create second consortium

409

 

Tenant API tests

Big picture

Scenarios in 'tenant.feature' file we cover GET, POST, and PUT operations with all possible status codes except 401, and 403, and DELETE for only 404. And after each successful POST operation we also verify that:

  • For both type ('isCentral' = true and 'isCentral' = false) of tenants: 'consortia_configuration' table in '<tenant>_mod_consortia' has record for 'central' ('isCentral' = true) tenant;

  • For tenants 'isCentral' = false: 'user_tenant' table in '<tenant>_mod_users' has record for 'dummy_user'.

Scenario

sub-scenarios

status code

Scenario

sub-scenarios

status code

1

 

 

 

 

 

@Negative

Attempt to POST a tenant to the consortium






Attempt to create a tenant for consortia without 'adminUserId' query param ('isCentral' = false)

400

2

Attempt to create a tenant for consortia before 'central' tenant has been created

404

3

Attempt to create a tenant for non-existing consortium

404

4

Attempt to create a tenant without an 'id'

422

5

Attempt to create a tenant without a 'code'

422

6

Attempt to create a tenant without a 'name'

422

7

Attempt to create a tenant without 'isCentral'

422

8

Attempt to create a tenant with a

'name' that has length more than 150 characters and a 'code' with more than 3 characters

---

9

2

 

 

@Positive

Do POST a tenant, GET list of tenant(s) ('isCentral' = true)




Get tenants of the consortium (before posting any tenant)

200

10

Post a tenant with 'isCentral' = true ('centralTenant')

201

11

Get tenants of the consortium (after posting 'centralTenant')

200

12

Verify that 'consortia_configuration' in 'centralTenant' has record for 'central'('isCentral' = true) tenant

200

13

 

 

@Negative

Attempt to POST a second tenant with existing 'isCentral' = true, 'id', 'name', 'code'




Attempt to create a second central tenant ('isCentral' = true

409

14

Attempt to create a tenant with an existing 'id'

409

15

Attempt to create a tenant with an existing 'code'

409

16

Attempt to create a tenant with an existing 'name'

409

17

4

 

 

 

 

@Negative

Attempt to PUT existing tenant with invalid payload



Attempt to update a tenant with a different 'id'

400

18

Attempt to update the tenant for non-existing consortium

404

19

Attempt to update non-existing tenant

404

20

Attempt to update the tenant without an 'id'

422

21

Attempt to update the tenant without a 'code'

422

22

Attempt to update the tenant without a 'name'

422

23

Attempt to update the tenant without 'isCentral'

422

24

Attempt to update the tenant with a 'name' that has length more than 150 characters and a 'code' with more than 3 characters

---

25

@Positive

Do PUT the tenant

Update the tenants' 'code'

200

26

Update the tenants' 'name'

200

27

6

@Negative

Attempt to DELETE non-existing tenant, with non-existing consortiumId

Attempt to delete non-existing tenant in the consortium

404

28

Attempt to delete tenant by non-existing consortiumId

404

29

 

@Positive

Do POST a non-central tenant, GET list of tenant(s) ('isCentral' = false)

Create 'university' tenant

201

30

Get tenants by consortiumId - should get two tenants

200

31

Verify that 'consortia_configuration' in 'universityTenant' has record for 'central' tenant

200

32

Verify 'dummy_user' has been saved in 'user_tenant' table in 'university_mod_users'

200

 

User-Tenant-Associations

Big picture

Before posting tenants to the consortium tenants had following users:

  • 'consortiaAdmin' in 'centralTenant';

  • 'consortia-system-user' in 'centralTenant' (automatically created when 'mod-consortia' was enabled);

  • 'pubsub-user' in 'centralTenant' (we will not check this users' associations);

  • 'universityUser1' in 'universityTenant';

  • 'consortia-system-user' in 'universityTenant' (automatically created when 'mod-consortia' was enabled);

  • 'pubsub-user' in 'universityTenant' (we will not check this users' associations).

And mostly we need to investigate records in the following tables:

  • 'users' table in 'central_mod_users' - real users in all tenants should be saved here;

  • 'user_tenant' in 'central_mod_consortia' - primary and non-primary associations should be saved here;

  • 'user_tenant' in 'central_mod_users' - real users in all tenants should be saved here with 'tenant' information;

  • 'users' table in 'university_mod_users' - real users of 'universityTenant' and users who have non-primary association in 'universityTenant'  should be saved here.

test-id

Scenario

sub-scenarios (action and verification)

test-id

Scenario

sub-scenarios (action and verification)

1

 

 


con-1

 

 


Verify there are following records for  'consortiaAdmin':

1. 'consortiaAdmin' has been saved in 'users' table in 'central_mod_users'

2

2. 'consortiaAdmin' has been saved in 'user_tenant' table in 'central_mod_users'

3

3. primary affiliation for 'consortiaAdmin' has been created in 'user_tenant' table in 'central_mod_consortia'

4

4. shadow 'consortiaAdmin' has been saved in 'users' table in 'university_mod_users'

5

5. non-primary affiliation for shadow 'consortiaAdmin' has been created in 'user_tenant' table in 'central_mod_consortia'

6

6. verify shadow 'consortiaAdmin' has required permissions (in 'universityTenant')

7

2

 


con-2

 


Verify there are following records for 'consortia-system-user' of 'centralTenant':

1. 'consortia-system-user' has been saved in 'users' table in 'central_mod_users'

8

2. 'consortia-system-user' has been saved in 'user_tenant' table in 'central_mod_users'

9

3. primary affiliation for 'consortia-system-user' has been created in 'user_tenant' table in 'central_mod_consortia'

10

4. 'consortia-system-user' has required permissions

11

 

 


con-3

 

 


Verify there are following records for 'universityUser1':

1. 'universityUser1' has been saved in 'users' table in 'university_mod_users'

12

2. 'universityUser1' has been saved in 'user_tenant' table in 'central_mod_users'

13

3. primary affiliation for 'universityUser1' has been created in 'user_tenant' table in 'central_mod_consortia'

14

4. shadow 'universityUser1' has been saved in 'users' table in 'central_mod_users'

15

5. non-primary affiliation for shadow 'universityUser1' has been created in 'user_tenant' table in 'central_mod_consortia'

16

6. shadow 'universityUser1' has empty permissions (in 'centralTenant')

17

4

 

 


con-4

 

 

Verify there are following records for 'consortia-system-user' of 'universityTenant':

1. 'consortia-system-user' has been saved in 'users' table in 'university_mod_users'

18

2. 'consortia-system-user' has been saved in 'user_tenant' table in 'central_mod_users'

19

3. primary affiliation for 'consortia-system-user' has been created in 'user_tenant' table in 'central_mod_consortia'

20

4. 'consortia-system-user' has required permissions

21

5. shadow 'consortia-system-user' has been saved in 'users' table in 'central_mod_users'

22

6. non-primary affiliation for shadow 'consortia-system-user' has been created in 'user_tenant' table in 'central_mod_consortia'

23

7. shadow 'consortia-system-user' of 'universityTenant' has empty permissions (in 'centralTenant')

24

 


con-5

 

Add permissions of 'consortiaAdmin' to shadow 'consortiaAdmin'

#Note. There will be only one admin user, so need to add permissions of 'consortiaAdmin' to shadow 'consortiaAdmin'

 

25

6

 

con-6

 

Create a user called 'centralUser1' in 'centralTenant' and verify there are following records:

create user called 'centralUser1' in 'centralTenant'

26

1. 'centralUser1' has been saved in 'users' table in 'central_mod_users'

27

2. 'centralUser1' has been saved in 'user_tenant' table in 'central_mod_users'

28

3. primary affiliation for 'centralUser1' has been created in 'user_tenant' table in 'central_mod_consortia'

29

 

 


con-7

 

 


POST, DELETE, re-POST non-primary affiliation for 'centralUser1' verify there are following records:

#Note. We have 'centralUser1' in 'centralTenant' (circ-6)

POST non-primary affiliation for 'centralUser1' (for 'universityTenant')

30

1. shadow 'centralUser1' has been saved in 'users' table in 'university_mod_users'

31

2. shadow 'centralUser1' has empty permissions (in 'universityTenant')

32

DELETE non-primary affiliation for 'centralUser1' (for 'universityTenant')

33

3. shadow 'centralUser1' has been deactivated (in 'users' table in 'university_mod_users')

34

re-POST non-primary affiliation for 'centralUser1' (for 'universityTenant')

35

4. shadow 'centralUser1' has been reactivated (in 'users' table in 'university_mod_users')