Background to be executed only once in cucumber - cucumber-jvm

I have the cucumber feature as below. I would like the background to be executed only once not for each line in the examples. How do i do that.
Feature: Bulk import of portfolios through the UI
Background: Bulk import of portfolios and treaties
Given the user logs into “dev” environment as “User ” with password "Password1"
And the user Chooses to import a portfolio providing SQLServer as "10.10.10.10”
And the user chooses uploaded Anytime
And the user enters the filter criteria for “Client_EDM”
And the user expands the Edm
And the user expands the portfolios dropdown
And the user chooses the Name as "UK COM for v0.7"
And the user chooses the contract as ""
Scenario Outline: Import of portfolio
Given the user clicks on Import button
And the user specifies the ImportJobName as "<ImportName>"
And the user specifies the project "<EDM>"
And the user specifies the structure "<StructureName>"
And the user submits a portfolio for Import
Examples:
| EDM | ImportName | StructureName|
|Client1_EDM|EUFL_UK_Com_Import100|EUFLCom_Import101|
|Client2_EDM|EUFL_UK_Com_Import101|EUFLCom_Import101|
Tagging the Scenario Outline as #attribute or adding #before for each of the background step will not solve my problem.. Any suggestions on how to go about doing it.?

Scenario: Bulk import of portfolios and treaties
Given the user logs into “dev” environment as “User ” with password "Password1"
And the user Chooses to import a portfolio providing SQLServer as "10.10.10.10”
And the user chooses uploaded Anytime
And the user enters the filter criteria for “Client_EDM”
And the user expands the Edm
And the user expands the portfolios dropdown
And the user chooses the Name as "UK COM for v0.7"
And the user chooses the contract as ""
Scenario Outline: Import of portfolio
Given the user clicks on Import button
And the user specifies the ImportJobName as "<ImportName>"
And the user specifies the project "<EDM>"
And the user specifies the structure "<StructureName>"
And the user submits a portfolio for Import
Examples:
| EDM | ImportName | StructureName|
|Client1_EDM|EUFL_UK_Com_Import100|EUFLCom_Import101|
|Client2_EDM|EUFL_UK_Com_Import101|EUFLCom_Import101|

Related

How to modify laravel 5.6 login behaviour? How to add more fields for logging along with email and password?

Laravel has 2 fields in its auth to help user login i.e email and password. I have added another field(hidden field) in the login blade to pass a random number along with a password and email.
In my eloquentuserprovider.php i am grabbing $credentials[‘password’] and $credentials[‘email’] like this but when I write $credentials[‘hidden’] I get an error saying ‘undefined index hidden’.
So my question is how should I add other fields along with email and password to validate the user
I am writing all my validation logic in eloquentuserprovider.php

Craft 3 -get user id and username

I'm using craft 3 Pro to make a website where users have a private area.
Users register and when login happens they are redirected to a page in the private area with respective info about that user.
When i use {% requireLogin %} with {{ currentUser.id }} craft 3 outputs the ID of the user that has active login in the CP (control panel).
But what i need is the ID of the user that made login in the frontend to access private area and not user ID that is logged in CP.
I'm reading craft 3 docs but didn't find the answer i'm looking for.
Any suggestions?
Craft does not make difference between CP and SITE users. There are only permissions to allow for a user to access the Control Panel.
However you can acces the basic user object with
craft.app.user That means the logged in user id is craft.app.user.id
If you want to access the User element to get the values of the custom fields you assigned to the users then
craft.app.user.identity and craft.app.user.identity.yourCustomField
What you need is to differentiate Admins from Regular users:
{% set userGroups = craft.app.user.identity.getGroups() %}
If userGroups contains the Admin user group, your user...is an admin clearly
Also there is a bunch of methods and properties for the identity object here:
https://docs.craftcms.com/api/v3/craft-elements-user.html#public-properties
Dig in!

Testing in Laravel 5.5

I want to test the user login without using dusk.
My problem is that I want to test the html form with the email and password fields, then complete those fields and if the login was correct, show the home route for example.
In previous versions we made this:
$this->type('email', 'example#gmail.com);
$this->type('password', '123456');
Now, I dont know how to do it.
$this->actingAs($user); //USUARIO CREADO ANTERIORMENTE
$response = $this->get(route('home'));
$response->assertStatus(200)
$response->assertViewIs('home');
The check I can do is that a logged-in user can go to the home path, but not when filling in the forms fields.

#auth.requires_permission not working ver 2

Good day to all web2py experts!
I can't find a way on how to use the web2py Decorators
#auth.requires_permission('read','person')
def f(): ....
in the pdf manual it says that:
prevents visitors from accessing the function f unless the visitor is a member
of a group whose members have permissions to "read" records of table
"person". If the visitor is not logged in, the visitor gets directed to a login
page (provided by default by web2py). web2py also supports components,
i.e. actions which can be loaded in a view and interact with the visitor via
Ajax without re-loading the entire page. This is done via a LOAD helper which
allows very modular design of applications; it is discussed in chapter 3 in the
context of the wiki and, in some detail, in the last chapter of this book.
This 5th edition of the book describes web2py 2.4.1 and later versions
In my case:
I have list of groups: Admin_Tier_1, Admin_Tier_2, Admin_Tier_3
Admin_Tier_1 - has the highest authority to access all features like adding a school year, set a school year etc.
Admin_Tier_2 - has the authority to add students etc
Admin_Tier_3 - its the lowest level of authority that can only add fines to the students (Organization Officers)
now I use the Decorator code like this:
#auth.requires_permission('Admin_Tier_1','student_list')
def add(): ....
now I login the account of the Chairman which registered in the auth_membership as Admin_Tier_1. Then I click the link "List of Students" which redirect to add(): function but the system returned a message:
Not Authorized
Insufficient privileges
The auth.requires() method can take a callable rather than a boolean value as the condition, and this is preferable when it is expensive to generate the boolean value (otherwise, the boolean value is generated whenever the controller is accessed, even if the particular decorated function is not the one being called). So, to avoid calling auth.has_membership unnecessarily, you can do:
#auth.requires(lambda: auth.has_membership('Admin_Tier_1') or
auth.has_membership('Admin_Tier_2'))
Now the two auth.has_membership calls will only be made when the actual function being decorated is called.
Also, if you need to check a larger number of roles, you can do something like:
#auth.requires(lambda: any([auth.has_membership(r) for r in ['list', 'of', 'roles']))
Problem solved:
#auth.requires(auth.has_membership('Admin_Tier_1') or auth.has_membership('Admin_Tier_2'))
source here.
Whenever I access the page if the user belong to the group of Admin_Tier_3 the system block the acess and redirect it to "/default/user/not_authorized" page :)

How does Password Managers (in browsers) detect user & password fields, and how to force this detection?

I'm trying to understand how does password managers to detect user & password field in forms.
I guess that the password field is detected by looking for a input[type="password"], and the user field is the direct previous input (hidden, text, email, etc...)
/***** EDITED ****/
Confirmed, for example:
I have two forms
F1= name,email,pass
F2= email,name,pass
So, I save my password in the first form, the PM saves "email" and "pass".
Then, the second form is filled with the value of email in the field name.
/***** END EDITED ****/
But this produces too many bugs, and these are very commons, even in some famous sites and frameworks.
There are some way to explicitly specific which fields should be saved?
I didnt find any info in internet.
I only find this propose: http://www.mypico.org/documents/2014-StajanoETAL-api.pdf but is not implemented yet (and maybe never)