mod-lists: Refactoring guide
Overview
This module includes additional critical updates for Eureka compatibility. Key differences focus on:
Second Test User instead of testAdmin
Dynamic User ID Management & validations adjustment
Second Test User instead of testAdmin
The access-control.feature has logic to check whether other users have access to private lists, and version.feature checks who has updated the list. Since it crucial to have two different users, and setup-users.feature creates only one user(testUser), there was implemented logic to create testUser2.
Since setup-users.feature works only with testUser variable, the additional scenario was added in lists-junit.feature for testUser2 creation. We overriding the existing testUser with testUser2 values, calling setup-users.feature scenarios, and assigning testUser values back.
Scenario: create second user for testing
* def testUserName = testUser.name
* def testUser = {tenant: "#(testTenant)", name: '#(testUser2.name)', password: 'test'}
Given call read('classpath:common/eureka/setup-users.feature@getAuthorizationToken')
Given call read('classpath:common/eureka/setup-users.feature@createTestUser')
Given call read('classpath:common/eureka/setup-users.feature@specifyUserCredentials')
Given call read('classpath:common/eureka/setup-users.feature@addUserCapabilities')
* def testUser = {tenant: "#(testTenant)", name: '#(testUserName)', password: 'test'} testUser2 was added as variable in karate-config.js
Dynamic User ID Management & validations adjustment
Common functionality doesn’t create test users with static id anymore. So further validations in the code cannot be made with static ids and must be saved as variables.
//testUser1
Scenario: create tenant and users for testing
Given call read('classpath:common/eureka/setup-users.feature')
* eval java.lang.System.setProperty('testUser1Id', karate.get('userId'))
//testUser2
Scenario: create second user for testing
* def testUserName = testUser.name
* def testUser = {tenant: "#(testTenant)", name: '#(testUser2.name)', password: 'test'}
Given call read('classpath:common/eureka/setup-users.feature@getAuthorizationToken')
Given call read('classpath:common/eureka/setup-users.feature@createTestUser')
* eval java.lang.System.setProperty('testUser2Id', karate.get('userId'))
Given call read('classpath:common/eureka/setup-users.feature@specifyUserCredentials')
Given call read('classpath:common/eureka/setup-users.feature@addUserCapabilities')
* def testUser = {tenant: "#(testTenant)", name: '#(testUserName)', password: 'test'}Therefore, in versions.feature validations has changed from:
To:
Also, since we now have only two test users, whose usernames are similar(testUser has ‘test-user’, and testUser2 has ‘test-user-2’) there was some adjustments in username validation. In karate keyword ‘contains’ with variables works only as full match of variables. Therefore was decided to user ‘karate.toString()’
P.S. Since testAdmin was replaced with testUser2, naming of headers variables was changed also(from 'testAdminHeaders' , to 'testUser2Headers')