Login using MFA using JMeter - blazemeter

So i am trying to login to my application through Jmeter , it requires MFA , and so it returns the token in a variable in the response header "
i used blazemeter to record the login procedures it got , then i added a listener , reg expression and a JSR Post processor
I am giving the the thread only 1 user , however i am getting a lot of trials in the summary tree log , also its not getting the token and logging in , any help please ? , i attached my jmeter shots
I want to en-pose the login and the token to successfully login to the applicationenter image description here
1 error
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.compile(GroovyScriptEngineImpl.java:187) ~[groovy-all-2.4.16.jar:2.4.16]
at org.apache.jmeter.util.JSR223TestElement.processFileOrScript(JSR223TestElement.java:217) ~[ApacheJMeter_core.jar:5.1.1 r1855137]
at org.apache.jmeter.extractor.JSR223PostProcessor.process(JSR223PostProcessor.java:44) [ApacheJMeter_components.jar:5.1.1 r1855137]
at org.apache.jmeter.threads.JMeterThread.runPostProcessors(JMeterThread.java:925) [ApacheJMeter_core.jar:5.1.1 r1855137]
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:564) [ApacheJMeter_core.jar:5.1.1 r1855137]
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486) [ApacheJMeter_core.jar:5.1.1 r1855137]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253) [ApacheJMeter_core.jar:5.1.1 r1855137]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_121]
Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script9.groovy: 1: unexpected token: # line 1, column 63.
*****"+vars.get(" AUTH-TOKEN")

Related

Snowflake custom OAuth client fails with invalid_client error?

I have created a custom OAuth client for the snowflake account by referring documentation here, https://docs.snowflake.com/en/user-guide/oauth-custom.html
I created an OAuth custom instance for my local using the following query:
create security integration My_Snowflake_Connector
type = oauth
enabled = true
oauth_client = custom
oauth_client_type = 'CONFIDENTIAL'
oauth_redirect_uri = 'http://localhost:4200/api/auth/callback/snowflake'
oauth_issue_refresh_tokens = true
oauth_refresh_token_validity = 86400
blocked_roles_list = ()
pre_authorized_roles_list = ('SYSADMIN', 'ACCOUNTADMIN', 'SECURITYADMIN')
oauth_allow_non_tls_redirect_uri = true
I have obtained authorization & token URLs using the following query:
DESCRIBE security integration My_Snowflake_Connector
I also obtained secrets using the following query:
SELECT SYSTEM$SHOW_OAUTH_CLIENT_SECRETS( 'MY_SNOWFLAKE_CONNEECTOR' )
I have used passport-oauth2 plugin & OAuth2Strategy
On initiating OAuth flow I am rightly taken to the snowflake account I log in it shows the OAuth consent screen but upon redirection, I get an error invalid_client.
I am getting the following error JSON blob:
{\n "data" : null,\n "error" : "invalid_client",\n "code" : null,\n "message" : "This is an invalid client.",\n "success" : false,\n "headers" : null\n}
I have verified the callback URL, client id & secret none seems to be wrong.
What may be wrong with my configuration?
Update
We could not figure out the reason behind the OAuth error, Finally, we ended up using the Node js client from snowflake. For more info: https://docs.snowflake.com/en/user-guide/nodejs-driver.html
I could see a similar error when testing OAuth2 from Postman when Client Authentication is set to "Send Client Credentials in body".
On changing this to "Send as Basic Auth Header",token generation works fine and proceeds successfully.
I guess this change should resolve the issue in your case as well. One of the reference that I checked is here : https://github.com/ciaranj/node-oauth/pull/316

Conenct Talend with Snowflake cloud

I am new using Talend and Snowflake cloud.
I am trying to conet Talend using the component "Snowflake Connection", and complete with this settings:
user:XXX
password: YYY
Schema: TPCH_SF1
Database: SNOWFLAKE_SAMPLE_DATA
and give me this error: .net.snowflake.client.jdbc.SnowflakeSQLException: Incorrect username or password was specified.
But this user I can enter in Snowflake.
Can anyone help me please.
I tried reproducing it. Just to clarify different component what error comes through i have written down all different error come when which component throws error.
If snowflake account is wrong
java.lang.RuntimeException: JDBC driver encountered communication error. Message: HTTP status=403.Incorrect Snowflake Account was specified
For this error we need to change the account name
Snowflake Region is wrong for valid snowflake account. 403 error is thrown
something like below.
"ERROR [main, net.snowflake.client.jdbc.SnowflakeUtil:logResponseDetails:449] -- Response content: 403 ERROR "
you can define region name in Advance setting by checking in use Custom Snowflake Region for connection.
Snowflake username or password is incorrect for the account.
JDBC driver not able to connect to Snowflake. Error code: 390100, Message: Incorrect username or password was specified..
Hope this helps.

spring cloud contract: user registration test

I'm struggling with BCryptPasswordEncoder and groovy contract
I have a producer and a consumer service, the producer sends a message with user registration information (ie. user and password (encoded using BCryptPasswordEncoder(12)). The test is creating the message with the password encrypted, this is ok, but my questions are:
1. is it possible to encrypt the password in the contract?
2. how?
3. if possible how can I set BCryptPasswordEncoder(12)?
at the moment when running the test (mvn clean install) from the producer, the verification is failing since the encrypted password <> plain password defined in contract
Thanks!
UPDATE
I have uploaded a sample to github https://github.com/dssantana/user-registration
If you run mvn clean install, you will find that at a certain point one of the tests fail with an error similar to:
2017-12-18 11:55:36.056 INFO [user-client,,,] 5236 --- [ main] .e.u.c.UserAccountRegistrationController : UserAccountRegistrationController - UserAccountRegister:
AccountRegistration(firstName=Diego, lastName=Santana, email=dssantana#gmail.com, mobileNumber=0452621048, ipAddress=127.0.0.1, birthday=1979-10-16,
password=$2a$12$jm3YACnf72P3wKCmPLRXwufeXJx5lzibwLz3DzhCXft.XKW2bK1RC)
[ERROR] Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 6.935 s <<< FAILURE! - in au.net.example.userclient.ContractVerifierTest
[ERROR] validate_shouldSendAnAccountRegistrationMessageWithSpecialCharactersUsername(au.net.example.userclient.ContractVerifierTest) Time elapsed: 0.426 s <<< ERROR!
java.lang.IllegalStateException: Parsed JSON
[{"firstName":"Joe","lastName":"Doe","email":"joe.doe+test#gmail.com","mobileNumber":"0452621048","ipAddress":"127.0.0.1",
"birthday":"1979-10-16","password":"$2a$12$fZcEe6fUzmjHmItvsJ8MCOCOR.mnc2nbDqh/Ce1aYzUBRq5L8ywRm"}]
doesn't match the JSON path [$[?(#.['password'] == 'Test01')]]
at au.net.example.userclient.ContractVerifierTest.validate_shouldSendAnAccountRegistrationMessageWithSpecialCharactersUsername(ContractVerifierTest.java:49)
[ERROR] validate_shouldSendAnAccountRegistrationMessage(au.net.example.userclient.ContractVerifierTest) Time elapsed: 0.323 s <<< ERROR!
java.lang.IllegalStateException: Parsed JSON
[{"firstName":"Diego","lastName":"Santana","email":"dssantana#gmail.com","mobileNumber":"0452621048","ipAddress":"127.0.0.1",
"birthday":"1979-10-16","password":"$2a$12$jm3YACnf72P3wKCmPLRXwufeXJx5lzibwLz3DzhCXft.XKW2bK1RC"}] doesn't match the JSON path [$[?(#.['password'] == 'Test01')]]
at au.net.example.userclient.ContractVerifierTest.validate_shouldSendAnAccountRegistrationMessage(ContractVerifierTest.java:33)
The encrypted password is Test01 and should match with the plain password in the contract test, however I'm not sure how to verify this, it's one way encryption and the way to verify is to encrypt and match the contract data with the test data.
As presented in this link https://github.com/dssantana/user-registration/pull/1/files what was added to the initial test setup is the $( consumer("fixed value"), producer(regex(nonBlank()))) line to ensure that on the producer side, in the generated test we have some value of password

LDAP-Error in Identity Server 4.6 when using user registration with "Ask password from user"

I wanted to try the password-notification feature of the IS 4.6 but it throwing an exception.
I followed those links:
https://docs.wso2.org/display/IS460/Recover+with+Notification
http://cgchamath.blogspot.mx/2013/12/wso2-identity-server-user-creation-with.html
This is the error I am getting
Here is the Stacktrace
Caused by: org.wso2.carbon.identity.base.IdentityException: Error
while persisting identity user data in to user store at
org.wso2.carbon.identity.mgt.store.UserStoreBasedIdentityDataStore.store(UserStoreBasedIdentityDataStore.java:81)
at
org.wso2.carbon.identity.mgt.IdentityMgtEventListener.doPostAddUser(IdentityMgtEventListener.java:420)
... 124 more Caused by: org.wso2.carbon.user.core.UserStoreException:
One or more attributes you are trying to add/update are not supported
by underlying LDAP. at
org.wso2.carbon.user.core.ldap.ReadWriteLDAPUserStoreManager.doSetUserClaimValues(ReadWriteLDAPUserStoreManager.java:874)
at
org.wso2.carbon.identity.mgt.store.UserStoreBasedIdentityDataStore.store(UserStoreBasedIdentityDataStore.java:73)
... 125 more Caused by:
javax.naming.directory.NoSuchAttributeException: [LDAP: error code 16
- NO_SUCH_ATTRIBUTE: failed for Modify Request
Object : 'uid=testUser,ou=Users,dc=wso2,dc=org'
Modification[0]
Operation : replace
Modification
http://wso2.org/claims/identity/passwordTimestamp: 1398394865706
Modification1
Operation : replace
Modification
initials: false : ERR_04269 ATTRIBUTE_TYPE for OID http://wso2.org/claims/identity/passwordtimestamp does not exist!];
remaining name 'uid=testUser' at
com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3108) at
com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:3033) at
com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2840) at
com.sun.jndi.ldap.LdapCtx.c_modifyAttributes(LdapCtx.java:1411) at
com.sun.jndi.toolkit.ctx.ComponentDirContext.p_modifyAttributes(ComponentDirContext.java:253)
at
com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.modifyAttributes(PartialCompositeDirContext.java:165)
at
com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.modifyAttributes(PartialCompositeDirContext.java:154)
at
org.wso2.carbon.user.core.ldap.ReadWriteLDAPUserStoreManager.doSetUserClaimValues(ReadWriteLDAPUserStoreManager.java:859)
... 126 more
I can imagine that the application is generating a timestamp for the expiration of the password and tries to save in a field in the LDAP which is mapped by the combination:
http://wso2.org/claims/identity/passwordtimestamp -> nickName
This mapping is wrong obviously.
How can I force an adequate mapping so the process is saving the user in the right way (and hopefully sending the email after that ...)?
Thanks in advance.
First problem on this way solved:
I had to re-add the claim of the password time stamp, but with the correct uri:
http://wso2.org/claims/identity/passwordTimestamp
Also helpful was:
https://wso2.org/jira/browse/IDENTITY-1200
The LDAP-error is fixed, but still it is not sending the email. But that is another issue

I'm getting troubles while uploading to Youtube with google java client: "Invalid value for: listed is not a valid value"

I'm trying to upload videos using https://code.google.com/p/youtube-api-samples/source/browse/samples/java/youtube-cmdline-uploadvideo-sample/src/main/java/com/google/api/services/samples/youtube/cmdline/youtube_cmdline_uploadvideo_sample/UploadVideo.java example
I've successfully registered on the youtube console and have obtained the client_secrets.json at https://code.google.com/apis/console/?api=youtube#project:340964720118:access
I have installed the secrets so my app can access them; everything is compiled well, but when the program is executed, I'me getting that strange errors:
GoogleJsonResponseException code: 400 : Invalid value for: listed is not a valid value
com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Invalid value for: listed is not a valid value",
"reason" : "invalid"
} ],
"message" : "Invalid value for: listed is not a valid value"
}
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:145)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:423)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
I can't find out what is wrong; since the request itself is deeply encapsulated, I can't understand what is wrong with the request...
UPD.
Thanks to
System.out.println(videoInsert.getHttpContent().toString());
call inserted before the
Video returnedVideo = videoInsert.execute();
in the sample code, I got that the JSOn formed and sent to the google is
{snippet={description=Video uploaded via YouTube Data API V3 using the Java library on Sun Sep 29 20:29:30 MSK 2013, tags=[test], title=Test Upload via Java on Sun Sep 29 20:29:30 MSK 2013}, status={privacyStatus=listed}}
But actually there is still a question what is wong with this json and why it causes the error on the the server side.
UPD 2:
And no I no longer get the message above, but the upload is still impossible. I'm getting 401 Error while trying to upload the file in that lines of the example above:
System.out.println(videoInsert.getJsonContent().toString());
System.out.println(videoInsert.getHttpContent().getType());
Video returnedVideo = videoInsert.execute();
System.out.println(returnedVideo.getId());
I supposed that I haven't authorized the request to my personal data, but I actually DID it (the request was loaded to the default browser where I have accepted it and specified the account I would like to work with). However, there is no way to check that authoriation; my google account data holds only Apps and Activity log for the google+ apps; I haven't fount my app in the list. So where I can check where I'm not logged in?
IOException: 401 Unauthorized
com.google.api.client.googleapis.json.GoogleJsonResponseException: 401 Unauthorized
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:145)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:423)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
at ScreenRecordingExample.UploadToYoutube(ScreenRecordingExample.java:356)
Ok, I have found out that the problem appeared due to the incorrect privacyStatus value:
I had
status.setPrivacyStatus("listed");
in my code, while it seems that only public, unlisted and private are possible values
And the UPD-2 problem was resolved unfortunately in the way i don't know exactly how:
i have noticed, that in my code example there was a line
return new AuthorizationCodeInstalledApp(flow, localReceiver).authorize("user");
I have replaced 'user' with my google user name (but actually I'm not sure that it was a thing that was really needed). After that replacement the authorization attempt started again (default browser loaded the accept/decline page and there I should select one of two accounts). Since I have two accounts, the original youtube one and the common google one, and during the last attempt I have selected the google's one and got 401 error, I have selected the youtube's one this time.
so, after that the problem was resolved. I still don't know do it due to the correct username instead of 'user' or due to the correct account selection. If someoune kows the truth, please comment!

Resources