How to user rails performance tests with real data [duplicate] - ruby-on-rails

show grants for charm#'localhost';
---------------------+
| Grants for charm#localhost |
+-----------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'charm'#'localhost' IDENTIFIED BY PASSWORD '*EDD1CD76B1331E363B2BAED3F0B7EAF28559FBEWD' |
| GRANT ALL PRIVILEGES ON `charmstyle_com`.`charmstyle_com` TO 'charm'#'localhost'
i used
grant all on charmstyle_com to charm#'localhost' IDENTIFIED BY 't1q4gytrur';
flush privileges;
then i import the database,it shows an error:
ERROR 1142 (42000) at line 29: CREATE command denied to user 'charm'#'localhost' for table 'adminnotification_inbox'

You granted the user permissions only to the 'charmstyle_com' table inside the 'charmstyle_com' database. What you probably want is to grant permissions to all the tables in 'charmstyle_com' (or at least the 'adminnotification_inbox' table)
GRANT ALL PRIVILEGES ON `charmstyle_com`.* TO 'charm'#'localhost'
alternatively
GRANT ALL PRIVILEGES ON `charmstyle_com`.`adminnotification_inbox`
TO 'charm'#'localhost'

Related

Block access for all the users in Apache Ranger

I think Apache Ranger does not support blocking all the users in a Policy using '*' simply.
Does Apache Ranger API provide any way to do this?
I can think of a way to first get all users using
curl -u <Username>:<Password> -X GET /service/xusers/users | jq '.vXUsers[].name'
And then put them in the below API to block all users
POST /service/public/v2/api/policy
Is there any way we can just use '*' on UI under Select User tab?
I think Apache Ranger does not support blocking all the users in a Policy using '*' simply.
You do not need to block the users all together, just create a policy and do not specify any access permissions for any users. Unless you specify the permissions explicitly, by default, all the users will be denied.
For example, if a policy has no allow conditions as below;
Then, you will get denied for all actions;
0: jdbc:hive2://node5.cluster.com:10000/> create table t (id int);
Error: Error while compiling statement: FAILED: HiveAccessControlException Permission denied: user [mapr] does not have [CREATE] privilege on [default/t] (state=42000,code=40000)
0: jdbc:hive2://node5.cluster.com:10000/>
When I specify an allow condition for a user to create a table as below;
Then, I can create a table;
0: jdbc:hive2://node5.cluster.com:10000/> create table t (id int);
INFO : OK
INFO : Concurrency mode is disabled, not creating a lock manager
No rows affected (0.687 seconds)
0: jdbc:hive2://node5.cluster.com:10000/>

Is there a way to let Ranger policy execute SHOW database?

Apache Ranger : 1.2
Hive : 2.3.3
Ranger policy-A : AD Group-1 has access to both DB-1 & DB-2
Ranger policy-B : AD Group-2 has access to only DB-2
When a user1 belong to Group-1 executes "SHOW DATABASES;
he could see list of databases.
But, when a user2 belong to Group-2 does the same gets below error,
HiveAccessControlException Permission denied: user [user2] does not have [USE] privilage on [*]
Is this expected behavior?
Was expecting user2 should be able to see only databases he has access to when he executes "SHOW DATABASES"

Mosquitto >1.5 User Access Level Wildcard

I am trying to use Mosquitto MQTT Broker v1.5.8.
I am using mosquitto_auth_plugin for User Authentication. (https://github.com/jpmens/mosquitto-auth-plug)
I created a mysql server with users and acls tables.
I want to setup a user that can subscribe to topic test/#.
So I setup the rw = 5 in the acls table for that user
However the user is not able to subscribe to any test/# but can subscribe to test/123
I looked at one of the issue posted https://github.com/jpmens/mosquitto-auth-plug/issues/356
but since the Repo is archived, I cant ask questions there.
mysql> select * from acls;
+----+--------------+--------------------+----+
| id | username | topic | rw |
+----+--------------+--------------------+----+
| 1 | test | test/# | 5 |
+----+--------------+--------------------+----+

I want to write script for login functionality. There are 5 types of user for that I have written following feature file

Query: I want to login with different user for that I am parametrizing the Usertype and will verify the respective element w.r.t there access.
Now In Step file suppose eg: I have written
#Then ("^User logged in with \"([^\"]*)\"$)
Public void User_logged_in_with_Usertype() {
If (Usertype= Admin){
...
So in above code in how I will get value of admin or any other user(Can we get same value from feature file or I need to write a code separately for each user)
Feature: As a user I would like to login in FMJ-Redesign application with different users
Story : User is logging in FMJ application
Scenario Outline: User is logged in with Admin user credentials
Given Navigating BU to "<Browser>"
When User clicks on Location
And ForevermarkJewellerWebsite element should be present on login page
Then User logged in with "<Usertype>"
And User will check visibility of "<Element>"
Then User Logout Successfully
Examples:
|Browser | UserType | Element |
|Chrome | Admin | |
|Chrome | Market | |
|Chrome | Jeweller | |
|Chrome | Store | |
The way to get the value for Usertype is to have it as a parameter in the method.
Your code looks like this:
#Then ("^User logged in with \"([^\"]*)\"$)
Public void User_logged_in_with_Usertype() {
If (Usertype= Admin){
...
I rewrote your Scenario outline a bit and ended up with this version
Scenario Outline: User is logged in with Admin user credentials
Given Navigating BU to <Browser>
When User clicks on Location
And ForevermarkJewellerWebsite element should be present on login page
Then User logged in with <UserType>
And User will check visibility of <Element>
Then User Logout Successfully
Examples:
| Browser | UserType | Element |
| Chrome | Admin | |
| Chrome | Market | |
| Chrome | Jeweller | |
| Chrome | Store | |
This allowed me to write the step like this:
#Then("^User logged in with (.*)$")
public void user_logged_in_with(String userType) throws Throwable {
if (userType.equals("Admin")) {
// implement our behaviour here
}
}
There are a few differences to notice here:
I removed the quotes around the parameters in the example
I added the value of UsertType as a parameter to the method user_logged_in_with
These changes simplified the regular expression needed and allows you to implement different behaviour for different UserTypes.
I would probably implement four different steps for the user types you have. This would give me simpler steps, I could avoid the condition. The price would be four methods.
If I did that, the resulting implementation would look like this instead:
#Then("^User logged in with Admin$")
public void user_logged_in_with_Admin() throws Throwable {
// implement our behaviour here
}
This simplified the regular expression even more and removed the need for a capture group.

How to write a test in cucumber?

This is my first test case with cucumber and I am having tough time to figure out one thing. So I already have a test which check user creation. I want to add more steps like on user create create account and create product and set some attributes to these objects.
Here is the user create feature file
#no-database-cleaner
Feature: Creating an user account
In order to use Recdns portal
I need to create an user account
Scenario: Successful user account creation
Given the database contains no test data
And I am on the homepage
When I attempt to create the following user account:
| email address | password | confirm password |
| abc#company1.com | password | password |
# User is automatically logged in
Then I should see "Welcome!" message on page
And an ar_id is set for the user
And
When I click "Sign Out"
Then I should see "Signed out"
When I attempt to sign in with following user account:
| email address | password |
| abc#company1.com | password |
Then I should see "Welcome!" message on page
Scenario Outline: Verify error message when user failed to sign in
Given there is a user
And I am on the homepage
And I try to login with email "<email address>", password "<password>"
Then I should see "<error message>" message on page
Examples:
| email address | password | error message |
| testuser#company1.com | abc1234 | Invalid email or password |
| testuserdoesnotexist#company1.com | password | Invalid email or password |
Scenario Outline: Verify error message when user failed to sign up
Given I am on the homepage
And I click "Sign Up"
And I try to create user with email "<email address>", password "<password>", confirm password "<confirm password>"
Then I should see "<error message>" message on page
Examples:
| email address | password | confirm password | error message |
| abc#company1.com | abc123 | abc123 | Email has already been taken |
| xyz#test | abc123 | abc123 | Email is invalid |
| | abc123 | abc123 | Email can't be blank |
| abc#company1.com | | abc123 | Password can't be blank |
| abc#company1.com | abc123 | | Password doesn't match confirmation |
| abc#company1.com | abc1 | abc1 | Password is too short |
So where exactly I can add steps saying create account table and product table. Thanks
Is your 'create user account' method something that you need for each test to run? If so, I'd just create a helper that you can call before your scenario. ..something like #needs_new_account. One of the best parts about cucumber is the ability to reuse environments. You probably shouldn't create a new account for each scenario. Instead, have cucumber remember that it needs to keep that new account (ie., dont delete it) and reuse for the rest of your scenarios, if possible. Let me know if this helps. ..not quite sure I'm understanding your question completely.
Also, you don't need your extra "and" between "and" and "when"...Gherkin syntax treats And/When/Then the same.

Resources