WANEM

2009 December 17

I usually find it very difficult to simulate a real world scenarios whenever I want to develop or test applications that are targeted for mobile devices. I usually find it difficult to access the experience that my apps would bring to table for an end user. It was just few months back when I was introduced to WANEM by one of my colleagues.

WANem is a Wide Area Network Emulator, meant to provide a real experience of a Wide Area Network/Internet, during application development / testing over a LAN environment. Typically we application developers develop applications on a LAN while the intended purpose for the same could be, clients accessing the same over the WAN or even the Internet. WANem allows the application development team to setup a gateway which can be used to simulate WAN characteristics like Network delay, Packet loss, Packet corruption, Disconnections, etc and trust me there are a whole lot of network parameters that we can fiddle around with. But what is really cool about WANem is that it takes hardly 5 minutes to set it up and have is running.

Another gem of a (Open Source) tool.

You can get more information about WANem at http://wanem.sourceforge.net/

The problem with iPhone killers

2009 October 28
by sudharshan

A very nice read on the why and how iPhone seems not just to survive but also thrives whenever the community brands a phone as an “iPhone Killer”

http://www.techcrunch.com/2009/10/26/the-problem-with-iphone-killers/

Source: TechCrunch

Python – Terminating Threads

2009 October 23

According to me Thread management in any language is a messy affair and probably there are a lot of examples that I have come across that illustrates how to terminate threads. Here is a very good and clean example of how to terminate threads from the main (Parent)

import threading
import time

class ThreadExit(threading.Thread):
    def __init__(self):
        self._stopevent = threading.Event()
        self._sleepperiod = 1.0
        threading.Thread.__init__(self, name="ThreadExit")

    def run(self):
        print "%s starts" % (self.getName(),)
        count = 0
        while not self._stopevent.isSet():
            count += 1
            print "loop %d" % (count,)
            self._stopevent.wait(self._sleepperiod)
        print "%s ends" % (self.getName(),)

    def join(self,timeout=None):
        self._stopevent.set()
        threading.Thread.join(self, timeout)

if __name__ == "__main__":
    threadExit = ThreadExit()
    threadExit.start()
    time.sleep(10.0)
    threadExit.join()

The program also illustrates a very nice approach of overriding the join method to facilitate the termination

IIS – Digest Authentication

2009 October 23

Here is the third one from my closet.

The following steps would help you configure Digest Authentication on IIS

  • Launch IIS Management Console.
  • Right click on the website for which Digest authentication should be enabled and select the properties.
  • Click on the Directory Security Tab and Edit the Authentication and Access control
  • In the Authentication Methods, Disable Anonymous access and select Integrated Windows authentication and Digest authentication for Windows Domian servers.
  • Pass the alert and apply the settings.
  • Restart IIS

Digest Authentication is now setup on IIS.

Just remember one thing that in order to configure Digest authentication in IIS, the server that hosts IIS should be in a Domain that provides the user access for that machine

Apache – Digest Authentication

2009 October 22

Here is the second one. In order to configure Digest authentication in Apache, the server that hosts Apache should be in a Domain that provides the user access for that machine. Here again there are two steps,

  1. Create a password file
  2. Configure the server

Create the password file:

To create the password file we would be using the htdigest executable instead of htpasswd

htdigest.exe -c <path to file> domain username

Example:

htdigest.exe -c .digest MyCompany sampleUser

Here again -c flag is used to create a password file.

Configure the Server

  1. Open the httpd.conf file found in the conf folder of Apache
  2. Uncomment the line LoadModule auth_digest_modules modules/mod_auth_digest.so
  3. Add the following code in the conf file
    <Directory "path to webroot for configuration">
    AuthType? Digest
    AuthName? "Domain Name"
    AuthDigestFile? "Path to the password file"
    Require vaild-user
    <Directory>
  4. Save the conf file
  5. Restart Apache
  6. Digest Authentication is now set up on apache

Apache – Basic Authentication

2009 October 22

When I was searching my internal wiki I stumbled upon some useful pages that I had written. Here is the first among many that I wrote.

There are two configuration steps which you must complete in order to protect a resource using basic authentication. Or three, depending on what you are trying to do.

  1. Create a password file
  2. Configure the Server to use the password file for processing authentication requests

Create a password file

htpasswd -c <location to password file>  <username>

For example:

htpasswd -c /etc/apache2/.passwords sampleUser

htpasswd will prompt you to enter a password, and then ask you confirm it. Note the use of the -c flag in the command shown above. This flag tells htpasswd to create the file /etc/apache/.passwords. This is only required when you need to create a new password file. Subsequent users can be added to this password file without the use of the -c flag. Note that using the -c flag with htpasswd on an existing file will clear the file’s contents completely and create a new one. So be careful while using this flag.

Please note that the command is htpasswd2 in Suse Linux

Configure the Server

Once you have created the password file, you need to inform Apache about it, and also configure it to this file in order to process user credentials for admission. This configuration is done with the following directives:

AuthType:
Authentication type being used. In this case, it will be set to Basic

AuthName:
The authentication realm or name

AuthUserFile:
The location of the password file

AuthGroupFile:
The location of the group file, if any

Require:
The requirement(s) which must be satisfied in order to grant admission

eg: Add these lines in your httpd.cong file using Directory tag withe full path you want to secure

<Directory>
AuthUserFile /etc/apache2/.passwords
AuthName "This is a protected area"
AuthGroupFile /dev/null
AuthType Basic
Require valid-user
</Directory>

Once the configuration is complete, restart Apache.

Python – Redirect Stdout

2009 October 21
by sudharshan

There are two ways to redirect the Stdout to a file.

The first technique is based on redirecting sys.sysout by assigning a writable object (such as a file object) to it. The print statements that follow will write to that object, instead of the default standard output. The drawback is that you should remember to reset sys.sysout to sys.__stdout__ if you want your default standard output back.

import sys
fileHandle = open('c:/out.log', 'w')
sys.stdout = fileHandle
print 'This message will be logged instead of displayed'
sys.stdout = sys.__stdout__
fileHandle.close()

The second technique came to my attention when I reread python. It involves redirecting the print statement directly as follows:

print >>output, "hello world"

Both these techniques have proved to be very handy while logging.

STAF

2009 October 12
by sudharshan

One of my favorite Test Automation frameworks which I have used in many of my projects is STAF.

Software Testing Automation Framework (STAF) is an open source, multi-platform, multi-language framework designed around the idea of reusable components, called services (such as process invocation, resource management, logging, and monitoring).

The main advantage of STAF is that one can code the automation script in either JAVA, Python, Perl et al and can run the same script on a plethora of platforms, which makes the job of an automation engineer very simple.  STAF shines when you need to run tests on a distributed platform and on a variety of platforms at the same time and aggregate the test results in a single repository.

STAF is also very well documented and also has provides online tutorials.

Photoshop.com Mobile App for IPhone

2009 October 10

First it was the big announcement of publishing Flash Application to Native IPhone application and now yet another big announcement, Photoshop mobile for IPhone. It seems that finally Adobe has found a way to keep their customers happy.

Using the Photoshop.com mobile application, one can,

  • Transform your photos with essential edits like crop, rotate and flip.
  • Correct and play with color by adjusting the saturation and tint, enhancing the exposure and vibrancy, and also convert images to b/w
  • Apply dramatic changes with effects such as Warm Vintage, Vignette and Pop. Edits or changes can be undone or redone so you can experiment without the worry of losing your original photo.
  • Upload photos to Photoshop.com.

The application can be downloaded via the Apple App Store and here is the link. For more information on the, visit the product website.  And above all this, the application is free.

Python – Find and Replace

2009 October 7
by sudharshan

Here is a simple python script that would help in finding and replacing text in a file using python

import os
import sys

nargs = len(sys.argv)

if nargs < 5:
    print "usage %s Search_text Replace_text infile outfile"% os.path.basename(sys.argv[0])
else:
    stext = sys.argv[1]
    rtext = sys.argv[2]
    input_file = open(sys.argv[3])
    output_file = open(sys.argv[4],"w")
    for s in input_file:
        output_file.write(s.replace(stext,rtext))
    output_file.close();
    input_file.close();