Using Karate, I have need to use basic authentication (to pass common authentication dialog window with username and password), and I have tried this: https://github.com/intuit/karate#http-basic-authentication-example).
I have created the file basic-auth.js
function fn(creds) {
var temp = creds.username + ':' + creds.password;
var Base64 = Java.type('java.util.Base64');
var encoded = Base64.getEncoder().encodeToString(temp.bytes);
return 'Basic ' + encoded;
}
I have added the call to the test feature file I run (added to Scenario section):
header Authorization = call read('basic-auth.js') { username: 'realusernamestring', password: 'realpasswordstring' }
Then I have placed the url I want to access right after:
driver urlUnderPassword
But it did not work, I still cannot access the page. I think there is something missing, something what needs to be done. Could you help me what the problem might be?
Thank you.
What you are referring to is for API tests not UI tests.
If you need the browser / driver to do basic auth it should be easy, just put it in the URL: https://intellipaat.com/community/10343/http-basic-authentication-url-with-in-password
So I am guessing something like this will work:
* driver 'http://' + username + ':' + password + '#' + urlUnderPassword
Related
So I'm not using the generic Accounts-ui package and am configuring a password recovery system. So far, so good...until the error below showed up:
I know it's an error with my smtp setup in /sever/smtp.js, which reads like this:
Meteor.startup(function () {
smtp = {
username: 'myEmail%40gmail.com',
password: 'password',
server: 'smtp.gmail.com',
port: 25
}
process.env.MAIL_URL = 'smtp://myEmail%40gmail.com:' + encodeURIComponent('password') + "#smtp.gmail.com:25";
});
I guess you can completely ignore the smtp object above, since I had to manually change the process.env.MAIL_URL variable because I had another error before this. This entire process is set up on my local computer/localhost.
I had port 465 before this and there was an error where the username and password were not found. I changed to port 25 and the process worked until I got this error saying that the greeting was never received.
Any help with this is much appreciated.
Edit: I would also like to add that adding the email package and changing up the ports messes up the Accounts.createUser function, where Meteor is unable to create a user unless I remove the smtp setup from the server.
I am noob in Meteor, but the below did work for me .
Meteor.startup(function () {
smtp = {
username: 'myEmail', // eg: myEmail#gmail.com
password: 'password, // eg: password for your email
server: 'smtp.gmail.com', // gmail smtp
port: 25
}
process.env.MAIL_URL = 'smtp://' + encodeURIComponent(smtp.username) + ':' + encodeURIComponent(smtp.password) + '#' + encodeURIComponent(smtp.server) + ':' + smtp.port;
});
Let me know if this worked
I'm not sure if this helps but:
You can use # instead of %40
This is work with me in localhost and Digital Ocean
/*Send Email Through Gmail SMTP*/
process.env.MAIL_URL="smtp://gmailUsername:gmailPassword#smtp.gmail.com:587";
Let me know if you still have greeting problem
Anyway, you don't need Meteor.startup. You only need to place it somewhere on your server folder. For example: server/email.js
I want to change the reset-password email template url
I want to change
localhost:3000/reset-password/dP8cuMPE220mEPA7l0uSRIq4
to
app.mysite.com/reset-password/dP8cuMPE220mEPA7l0uSRIq4
I've done this
Accounts.emailTemplates.resetPassword.text = function(user, url) {
url = url.replace('#/', '');
url = url.replace('localhost:3000', 'app.mysite.com');
return "Click this link to reset your password: " + url;
};
This works on my localenvironment but when in production it doesn't have localhost:3000
so the url will not change
I want to change the host, how to do this?
You need to set the ROOT_URL environment parameter. Meteor will use it to generate this link. So if you set ROOT_URL="http://app.myside.com/, then the generated url will be http://app.mysite.com/reset-password/blahBLAH.
I'm trying to send email from an ASP.NET using my SendGrid account. It works on my dev machine, but not in production, even though the credentials are the same. Likewise, in production I can connect to the SMTP server via telnet (using base64 encoded credentials), but the ASP site can't connect--I get error "Unauthenticated senders not allowed."
I've tried a mix of port numbers (25, 587, 465 -- my site is SSL). Using port 465 times out. 25 and 587 return respond immediately--but with the login error. This is really baffling because, like I say, it's the same credentials on dev machine and production.
I looked very briefly at Microsoft Network Monitor 3.4, but could not make heads or tails of it. I was hoping it would tell me the blow-by-blow commands being sent since I suspect the web site is doing something a little different from how telnet connects, but I don't know what.
Note I also asked my web host if outgoing traffic on these ports were blocked on production firewall, but they aren't.
Here's the actual code--like I say works fine on localhost, but SMTP connection fails in production
[AllowAnonymous]
[HttpPost]
public ActionResult ResetPasswordSend(string email)
{
List<string> userList = new List<string>();
try
{
string[] invalidChars = new string[] { ";", "," };
foreach (var invalidChar in invalidChars) if (email.Contains(invalidChar)) throw new Exception("Email contains invalid character.");
int count = 0;
// since emails are not unique, I must launch resets for all of them
var users = _db.HsProfile.Query("[Email]=#0", SqlDb.Params(email));
foreach (var profile in users)
{
count++;
userList.Add(profile.UserName);
var token = WebSecurity.GeneratePasswordResetToken(profile.UserName, 15);
WebMail.Send(profile.Email, "HumaneSolution.com Password Reset for user " + profile.UserName,
"You received this email because you or someone with your email address requested a password reset on HumaneSolution.com. " +
"If you didn't do this, then you don't need to take any action, and nothing will happen.\n\n" +
"To proceed with the password reset, click the link below within 15 minutes:\n\n" +
Url.BaseUrl("Account/EnterNewPassword/" + token) + "\n\n" +
"Sent to: " + email + " at " + DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() + "\n" +
"User name: " + profile.UserName);
}
if (count == 0) throw new Exception("Email " + email + " is not registered at HumaneSolution.com.");
}
catch (Exception exc)
{
ViewBag.Error = exc.Message;
}
return View(userList);
}
Based on suggestion from SendGrid, I re-wrote the email code so it does not use WebMail.Send but rather the SmtpClient and MailMessage objects explicitly. SendGrid says there might be some kind of timing problem in how ASP.NET loads credentials from the config file automatically. Here's exactly what they said:
Are you by chance storing your SendGrid credentials in a configuration file, separate from the code that connects to our SMTP server? The reason I ask is because I have seen rails and C# configurations like this receive the unauthenticated error due to the credentials not being passed at the correct time. Usually this is solved by moving the credentials directly in with the code instead of a separate configuration file. Give that a try and see if you notice a difference.<<
I didn't follow their advice completely -- i.e. I'm still using config file, but I'm loading the config values in subclasses of SmtpClient and MailMessage so I avoid hardcoding creds in my app. Anyway, it worked, all is well again.
I implemented login functionality using Meteor. I want to send a verification email whenever a new user is created. According to the documentation, I should use:
Accounts.sendVerificationEmail(userId, [email])
on the server folder.
However, I feel that it is lacking in implementation details. What file should I create to use this method? Does it have to be in a specific folder?
I made file in ../server/config.coffee:
Accounts.config
sendVerificationEmail: true
forbidClientAccountCreation: false
Accounts.emailTemplates.siteName = "blabla.com"
Accounts.emailTemplates.from = "blabla.com site Admin <admin#blabla.com>"
Accounts.emailTemplates.verifyEmail.subject = (user) ->
"Confirm registration on " + Accounts.emailTemplates.siteName;
Accounts.emailTemplates.verifyEmail.text = (user, url) ->
"To confirm your registration, please, click this link " + url
Of course, you have to setup process.env.MAIL_URL too.
I'm presented with an url with an "#" sign in it:
curl http://subdomain:token#localhost:9292/aaa/bbb
works perfectly
But I can't get it to work with node.js http.request, probably because I don't understand what the "#" is doing (and somehow can't find a clear answer on google).
Anyone care to explain?
Here's my current node.js code
var http_options = {
method : "GET"
, url : subdomain + ":" + token + "#" + Config.API.url
, path : "/aaa/bbb"
};
var req = http.request(http_options, function (response) {
// ...
});
req.on('error', function (error) {
console.log('error: ' + error);
});
which produces:
error: ECONNREFUSED
The # is dividing the user / password part from the location part.
the curl line you wrote send a HTTP Authenticate (BASIC authentication) with the request.
curl http://subdomain:token#localhost:9292/aaa/bbb
means: Get localhost:9292/aaa/bbb and do it as user: subdomain password token
I have no idea how to do that in node.js, but you'll figure it out, now that you know what it does.