Tuesday, February 21, 2006

JMeter Birthday Boundary Testing - Solution

One of the applications I was testing today required a boundary test for people aged 65 years old. To do this, I set up two variables, one with a generated date exactly 65 years ago, and the other being 65 years old plus one day, thus giving an age of 64.



age64:

${__javaScript(with(new Date()) X = String(getMonth() + 101).substr(1) + "/" + String(getDate() + 101).substr(1) + "/" + String(getFullYear() - 65), dateString)}


age65:

${__javaScript(with(new Date()) X = String(getMonth() + 101).substr(1) + "/" + String(getDate() + 100).substr(1) + "/" + String(getFullYear() - 65), dateString)}



Note that this will fail on the last day of the month and the day before a leap day. But hey, you have been working hard all month ... take a day or two off! ;-)

Wednesday, February 15, 2006

Formatted Date in JMeter / JavaScript - Solution 2

In another JMeter testing scenario, I wanted to set a user defined variable to a date string with the format "yyyymmddhhmmss". The solution below solved the problem of left-padding with zeros and getting all the formatting done in a single line.


${__javaScript(with(new Date()) X = getFullYear() + String(getMonth() + 101).substr(1) + String(getDate() + 100).substr(1) + String(getHours() + 100).substr(1) + String(getMinutes() + 100).substr(1) + String(getSeconds() + 100).substr(1), dateString)}

The uses of this kind of user variable include:



  1. Knowing exactly when a test was run for auditing

  2. Guaranteeing a unique string for things like new test usernames [note that I am writing regression tests which only run once. If you are running load tests, you will want to add String(getMilliseconds() + 1000).substr(1) to get unique string each pass]

  3. Having a string you can key off of, for example to clean up database entries you have made

Sunday, February 05, 2006

Boxes With Rounded Corners in CSS - Solution

Image


CSS Code



.textBox {
    background:#9cf url(/images/question-box.gif) left top no-repeat;
    /* Width attribute needed to fix behavior in Internet Explorer */
    /* width:100%; */
}
.textBox .right {
    background:url(/images/question-box-right.gif) right top no-repeat;
}
.textBox .bottom {
    background:url(/images/question-box-bottom.gif) left bottom no-repeat;
}
.textBox .corner {
    background:url(/images/question-box-corner.gif) right bottom no-repeat;
    padding:1em;
}

HTML Code



<div class="textBox"><div class="right"><div class="bottom"><div class="corner">
    <p>It is easy to create a resizable box with rounded corners using Cascading Style Sheets (CSS). Four nested &lt;div&gt; elements are required, each having a background image respectively set to the left-top corner (including the body), right edge, bottom edge, and right-bottom corner.</p>
</div></div></div></div>

See screenshots at http://www.threeleaf.com/freelance-work/demos/round-corners/ , along with some examples of why the workaround is necessary in Internet Exploer 6 and 7. My question: Why don't they fix that? If less funded browser companies like Firefox and Opera have come up with solutions, why can't Microsoft?

Formatted Date in JMeter / JavaScript - Solution

I am using JMeter for regression testing, and needed a way to use the current date in mm/dd/yyyy format in a form post. Here is the solution I came up with using the JavaScript function:


${__javaScript(d = new Date; prefix=d.getMonth()<9?'0':'';X = prefix + String(d.getMonth()+1) + '/' + d.getDate() + '/' + d.getFullYear(), Dummy)}

Looks like date formatting in JavaScript is a perpetual problem, so I hope this is helpful.

Microsoft Word Clears the Clipboard - Solution

I had been using Microsoft Word for years, when suddenly I had a strange problem where if I copied text to the clipboard, then opened Word, and then attempted to paste that nothing would happen OMG!. I have searched on the Web serveral times, but have not found a solution until now. Turns out I needed to disable a COM addin.


Thanks to Dopyiii (http://howtotroubleshoot.blogspot.com/#113035503245630446) for getting me on the right track.


His instructions for viewing COM addins:



  1. Open Word and go to Tools > Customize > Commands tab
  2. In the Categories section on the left, choose Tools
  3. In the Commands column on the right, you'll see "COM Addins"
  4. Grab this COM Addins button and drag it up and drop it off on your toolbar somewhere.

    • It doesn't matter where - you'll delete it in a minute anyway.

    • The quick way to delete this button (or to customize the toolbar) is to hold down Alt and click and drag the button into the document. When you let go, it'll disappear!


  5. Close the Customize dialog
  6. Now, click the new COM Addins button on your toolbar.

    • Like the Templates and Addins dialog, you can enable or disable whatever you see here

    • Remove the button if you like, or keep it there for nostalgic purposes.



I found that when I disabled Natural Voice Reader, I was able to paste after opening. Most people won't have NVR installed, of course, but this might also get you on the right track if it is a COM addin that is causing the problem. Let me know if this helps you!

Spammers can exploit unvalidated PHP forms

This is a message I sent to the AOL postmaster on September 19, 2005:


I have recently figured out that an AOL member known as "homerragtime" has developed a method to exploit unvalidated form posts to send SPAM e-mail. For several months homerragtime was successful sending e-mail through my unvalidated forms, and I was perplexed at receiving so many rejected spams that appeared to have come from my own site.


About two months ago I finally began validating my forms, and began to find form postings like the following being captured by my validation process:


pictureID aorg@johnmarshphotography.com
comments aorg@johnmarshphotography.com
send aorg@johnmarshphotography.com Content-Type: multipart/mixed; boundary=\"===============1010877498==\" MIME-Version: 1.0 Subject: 90c4558b To: aorg@johnmarshphotography.com bcc: homerragtime@aol.com From: aorg@johnmarshphotography.com This is a multi-part message in MIME format. --===============1010877498== Content-Type: text/plain; charset=\"us-ascii\" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit wygqm --===============1010877498==--

The tip-off for me was seeing the BCC field. It appears homerragtime has a robot that crawls the web and posts these kinds of messages. If he gets one of the messages that he is BCCed on, he matches that with the number in his subject line, and then knows that the form can be exploited. I did a search for homerragtime, and see this same signature in many places.


Please research this further. I believe homerragtime is violating your company policy not to send spam, even though technically, he is sending the spam through other people's web sites.


A few more notes:



  • I have found this problem has occurred on all three of the web sites I maintain. They are all fixed now.
  • My sites are all in PHP, but it is quite possible that this exploit could be used in other languages.
  • Bottom line: validate your forms. This person was very aggressive at sending out spam through my sites, judging by the large number of rejected e-mails I was getting returned to me.

IE Toolbar Names Get Mixed Up

I enjoy adding toolbars to Internet Explorer (currently have nine). I do not keep them all active all the time, of course. I only keep the Google toolbar open all the time and open others as needed. However, I have noticed a problem where when I right click on the toolbar area to open or close a toolbar, the names do not always correspond to the correct toolbar. For example, clicking on Yahoo! may open or close Google. Sometimes this can get very confusing when, say, four toolbars have switched names .


Anyone else seen this? I have not seen it documented on the Web, and I have not figured out a solution yet.

Wednesday, February 01, 2006

Formatted Date in JMeter / JavaScript - Solution

I am using JMeter for regression testing, and needed a way to use the current date in mm/dd/yyyy format in a form post. Here is the solution I came up with using the JavaScript function:


${__javaScript(d = new Date; prefix=d.getMonth()<9?'0':'';X = prefix + String(d.getMonth()+1) + '/' + d.getDate() + '/' + d.getFullYear(), Dummy)}

Looks like date formatting in JavaScript is a perpetual problem, so I hope this is helpful.