Welcome to Sign in | Join | Help

Browse by Archive:




Do Not Disturb!
 

Like many people, I have VOIP at home - my current provider is Vonage.  One of the features of Vonage is an international virtual number.  This gives me a local number in the UK that my family can dial, which automatically redirects to my home number here in the US.  It's relatively cheap ($4.99 per month) and makes it really easy for friends and family to get in contact.

One of the disadvantages of having an international virtual number however is that people can accidentally dial the number - and when they do, because of the time difference (8 hours between PST and GMT) it can be a somewhat inconvenient.  Let's just say that we've had about 3 or 4 wrong numbers this week, all of which have been about 2am in the morning.  Not so good if you like sleep. 

Vonage has a feature called "Do Not Disturb", which redirects all calls to voicemail - and which can be activated via their web page.  As simple as this sounds, I can be forgetful at times, so enabling this before going to bed (and disabling when I get up) can be an issue.  To overcome this I decided to put on my "web application test" hat and see if I could use Visual Studio 2008 to write an automated web test that logs into the Vonage site, and activates / deactivates this feature for me.  First, I created a new test project in VS2008, added a new test project and a new web test (from the test menu).  I recorded the action to enable the do not disturb feature:

image

I was able to strip down the required pages to just three requests (one to login, one to query for the phone number, and one to set the feature) and made sure that it worked within the IDE.  I then duplicated this test to create a second that re-enabled the feature.  (I'm sure there is a nice way of passing parameters to webtests, but just haven't worked it out yet).  The test works as follows:

The first request is a HTTP POST that submits my Vonage username and password to the site.

<Request Method="POST" Version="1.1" Url="https://secure.vonage.com/vonage-web/public/login.htm" ThinkTime="6" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="Windows-1252" ExpectedHttpStatusCode="0" ExpectedResponseUrl="https://secure.vonage.com/vonage-web/dashboard/index.htm">
  <FormPostHttpBody>
    <FormPostParameter Name="countryURLs" Value="http://www.vonage.com" RecordedValue="http://www.vonage.com" CorrelationBinding="" UrlEncode="True" />
    <FormPostParameter Name="username" Value="USERNAME" RecordedValue="USERNAME" CorrelationBinding="" UrlEncode="True" />
    <FormPostParameter Name="password" Value="PASSWORD" RecordedValue="PASSWORD" CorrelationBinding="" UrlEncode="True" />
    <FormPostParameter Name="submit.x" Value="30" RecordedValue="30" CorrelationBinding="" UrlEncode="True" />
    <FormPostParameter Name="submit.y" Value="13" RecordedValue="13" CorrelationBinding="" UrlEncode="True" />
  </FormPostHttpBody>
</Request>

The second request (this time a HTTP GET) brings up the do not disturb features page.  This is required to obtain the phone number as a FORM parameter that we use in the next request:

<Request Method="GET" Version="1.1" Url="https://secure.vonage.com/vonage-web/features/DoNotDisturb/edit.htm" ThinkTime="4" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="iso-8859-1" ExpectedHttpStatusCode="0" ExpectedResponseUrl="">
  <ExtractionRules>
    <ExtractionRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ExtractHiddenFields, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" VariableName="1" DisplayName="Extract Hidden Fields" Description="Extract all hidden fields from the response and place them into the test context.">
      <RuleParameters>
        <RuleParameter Name="Required" Value="True" />
        <RuleParameter Name="HtmlDecode" Value="True" />
      </RuleParameters>
    </ExtractionRule>
  </ExtractionRules>
  <CorrelationExtractionRules>
    <ExtractionRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ExtractFormField, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" VariableName="FormPostParam1.on" DisplayName="" Description="">
      <RuleParameters>
        <RuleParameter Name="Name" Value="on" />
        <RuleParameter Name="HtmlDecode" Value="True" />
        <RuleParameter Name="Required" Value="False" />
      </RuleParameters>
    </ExtractionRule>
  </CorrelationExtractionRules>
  <QueryStringParameters>
    <QueryStringParameter Name="did" Value="PHONENUM" RecordedValue="PHONENUM" CorrelationBinding="" UrlEncode="False" UseToGroupResults="False" />
    <QueryStringParameter Name="dndButton" Value="Configure" RecordedValue="Configure" CorrelationBinding="" UrlEncode="False" UseToGroupResults="False" />
  </QueryStringParameters>
</Request>

The third request is a HTTP POST that sets the Do Not Disturb feature on or off depending on the value of the "on" parameter:

<Request Method="POST" Version="1.1" Url="https://secure.vonage.com/vonage-web/features/DoNotDisturb/edit.htm" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="iso-8859-1" ExpectedHttpStatusCode="0" ExpectedResponseUrl=https://secure.vonage.com/vonage-web/features/DoNotDisturb/edit.htm?did=PHONENUM&amp;success=true&amp;settings=com.vonage.service.feature.DndSettingsDTO+%7BphoneNumber%3DPHONENUM%2C+isOn%3Dtrue%7D>
  <FormPostHttpBody>
    <FormPostParameter Name="on" Value="True" RecordedValue="true" CorrelationBinding="{{FormPostParam1.on}}" UrlEncode="True" />
    <FormPostParameter Name="phoneNumber" Value="{{$HIDDEN1.phoneNumber}}" RecordedValue="PHONENUM" CorrelationBinding="" UrlEncode="True" />
  </FormPostHttpBody>
</Request>

After the tests were complete, I put together two batch files (DNDOn.bat and DNDOff.bat) that call the webtests from the command line.  Using MSTest.exe, it's possible to run webtests from outside the IDE:

set VSINSTALLDIR=C:\Program Files\Microsoft Visual Studio 9.0
"%VSINSTALLDIR%\Common7\IDE\MSTest.exe" /noresults /testcontainer:bin\debug\DNDOn.webtest

Once the batch files were working, I simply added a new scheduled tasks (in Vista, type "Task Scheduler" from the start menu to reach this) to run the DNDOn.bat file at 10pm at night, and DNDOff.bat at 7am in the morning. 

image 

(btw, this is the first time I've really used the new task scheduler in Vista.  Two things surprised me:  1.  How easy it was to create a new task that ran the first time (I have too many nightmares creating Backup batch files on NT4!).   2.  How many tasks there are enabled in Vista - I need to spend some time figuring out what these do!)

...and that was it!  A quick solution that I can deploy to my new home server that will avoid more unwanted wrong number phone calls in the middle of the night.

If you want to check it out, you can find my test file here.  You'll of course need to replace USERNAME, PASSWORD, and PHONENUM (10 digits, remember to include the 1) with your specific values for your account. 

Comments

Software Architecture » Blog Archive » Do Not Disturb!

PingBack from http://architecture.wpbloghost.net/2007/12/05/do-not-disturb/
# December 17, 2007 2:57 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS