Functional test with services API layer and CRM - testing

Here is my project architecture components:
Front-end (Drupal crm)
Symfony 2 services (API layer)
CRM (external service to store users)
I would like to setup functional testing with codeception to test subscription part of my application.
Now, here is the process for subscription:
1/ Display form in front-end
2/ When form is submitted data is post to Services
3/ Services establish a connexion with the CRM and return a Json response to front-end.
4/ Front-end redirect and display a success message (or errors).
I need to clean up my data before run my test (test is get on /subscription, fill form, submit and test response). In fact, if a user exist in CRM, I need to delete it if I want test a success case.
In my case, I don't have a way to delete a specific user before running my test (no route in API to delete a user).
How can I achieve this? I'm not supposed to have a detached database to test this case.

You need to write background in feature file to delete data for each scenario. I quickly visited codeception and it is BDD testing framework.
Feature: Test Subscription
As a system admin
I want to test subscription system of "APPLICATION NAME"
Background:
Given delete all test data from system
And test data is delete successfully
Scenario: Create User in CRM
Given I am logged in as system admin
When I try to click to new customer
And Enter ...
And Enter......
When I click on customer list
Then I should see created customer in list
Background will run after each scenario and do job for you.

Related

Jmeter: scenario: I have to run 10 Concurrency users for login with one single login data

I created concurrency Thread Group with 10 Users in 1 Min, but when i run it ,i am getting 409 conflict in Login Authorization request.
is it possible to run 10 Concurrent Users with single login details?
enter image description here
It depends on how the system under test is configured, in your case it seems to be impossible
In general you need to configure JMeter to behave exactly like a real browser, to wit each JMeter's thread (virtual user) must represent a real user using a real browser and a real user:
has its own credentials
cache
cookies
think time
business actions
so ideally you need to create as many "login details" as virtual users you need to simulate

Set Password email by application

I have 2 applications on the same Tenant.
I can configure an email template for the "Set Password" workflow on:
an Application Level
the Tenant level
When I register a new user using the UI, as far as I understood it will only be able to send the email configured on the tenant level since it won't know anything about which application the user can see until the next step when I add the registrations.
If I create a user and add registration to it right away (on the same step) then this takes the Template configured on the application level.
My questions are:
Can we do something like this through the UI interface too? My applications have a different user base (some have accounts on both) and it would be nice to be able to send them one email or the other.
Or is this only possible through the API?
If I register a user with both applications (through the API) which email do they get?
Thanks for the help!
Can we do something like this through the UI interface too?
This is not currently possible. Creating the User, and creating a User Registration are two separate steps. As you correctly stated, when creating the user in the UI, there is no context yet for an application. For this reason, the user will receive the template configured at the tenant level.
Or is this only possible through the API?
Correct. You must use the Create "User + Registration" API to do this in one step to use the application template for setup password.
If I register a user with both applications (through the API) which email do they get?
When using the API to Create "User + Registration" you can only register for one application at a time. The email is only sent during the User Create step, so if you register for a second application, the user will already exist and thus will not receive a second email.

Should integration test bypass login natural processes in order don't retest same login functionality for many times

Let's say I'm testing a web service and I have a couple of scenarios requires user to be authenticated:
Scenario #1: Customer sign-up
Scenario #2: Customer sign-in
Scenario #3: Customer change name
Scenario #4: Customer update image
Should all the tests go through all login steps like:
1) Go to register page
2) Enter new user information
3) Activate account
4) Go to login page
5) Enter login and password
6) Press the Login button
7) Check if I authenticated as a customer
Or I can just test it once and implement endpoint which quickly creates a user and log it in.
So if I have that kind of endpoint that means I can skip retesting the same things all the time and just have short scenarios #3 and #4 implementation. But in this case, I have a less natural environment.
Please tell me about the best practices that you use in real projects.
Few best practices:
use the testing pyramid integration > ui (tests are much slower on UI, automate in the UI only the necessary things to have main flows covered)
for the UI use fast methods for the setup (so yes, web services, test login only once)
if possible keep some test data trough the builds (for example to make sure a new build that might change data structure does not affect basic functionality, e.g. login)
tests should be atomic (not depend on each other)
do some cleanup from time to time to remove duplicate test code and to improve the framework(speed, stability)
You shouldn't copy and paste the "log in" scenario to all of the other scenarios, but having an account and being logged in are prerequisites for the other use cases. From a behavior driven development perspective this will translate to one or more Given steps that simulate or actually perform those steps:
Scenario: Customer change name
# Calls web service or database to create new user
Given "Bob" is a registered user
# Calls web service or database to make account active
And "Bob" has an active account
# Opens browser, navigates to login page, fills out login form and submits it
And the user is logged in as "Bob"
# Steps specific to changing name and asserting it has changed
When the user changes their name to "Samuel"
Then the user's name is "Samuel"

Multi-user login through JMeter

I need some clarification in the testing process, specifically when multiple users (100 Users) login to a web application through JMeter.
I can log in with a single valid user but if there are 100 users and 1 is a valid user and 99 are invalid users, the 99 users cannot log in.
The problem is creating 100 is a difficult process.
Now, is testing login as mentioned above the same as testing with 100 valid users?
If not, is there any better process to test login with multi-users?
There is only one obvious requirement: each JMeter thread (virtual user) should use different credentials, in other words JMeter user must represent real user using real browser as close as possible, otherwise your load testing will not make sense.
So ideally you should have 100 different credentials so each virtual user could use its own username/password combination and have its own session. It particularly matters when your test scenario assumes some business processes, i.e. one user starts workflow, another one approves, third one finishes, etc.
If each load test iteration assumes "clean" system you could consider automating user creation process via setUp Thread Group where you can create the prerequisites (users, content, whatever). Ask around, it might be the case you can create the user using a single REST API or Database call, or it could be possible to import users from LDAP or using a shell command
As a last resort you can use single credentials with multiple JMeter virtual users, however in this case you may run into issues with your application so try avoiding CRUD operations so your test would represent just browsing.

SAP Hana integration with Business One user Accounts Login

I have a basic problem with SAP Hana and Integration of it with B1.
I have developed a project for loading data from B1 using calculation and attribute views accessed by xsodata services, and also Insert and Update using xsjs services. Now I want to add login to it, I mean login for b1 users entering their credentials and then be redirected to e.g. their list of activities.
I have configured approperiate service for calling B1 Service Layer "Login" method and it works just fine (it gives back sessionId and other infos). But the problem I have is how to use it in entire project. I mean for example when the user calls a xsodata service detect if his/her session has expired before loading data from service and decide to return data or redirect him/her to login page.
And for the sake of security, I want these session checks be done server side, not in the controllers.
It would be pleased if you gave me some samples or just ideas to what to do.