Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
3.0 KiB

  1. <job id="myTest">
  2. <reference object="AzRoles.AzAuthorizationStore"/>
  3. <script language="JScript">
  4. var TestSucceeded = true;
  5. if ( WScript.Arguments.length == 0)
  6. {
  7. WScript.Echo("you must provide store URL");
  8. WScript.Quit();
  9. }
  10. if ( WScript.Arguments(0) == "?" || WScript.Arguments(0) == "/?")
  11. {
  12. WScript.Echo("ACTestJ.wsf Usage:");
  13. WScript.Echo("ACTestJ.wsf <StoreUrl>");
  14. WScript.Quit();
  15. }
  16. var AzStore = new ActiveXObject("AzRoles.AzAuthorizationStore");
  17. if (AzStore == null)
  18. {
  19. WScript.Echo("Creating AzRoles.AzAuthorizationStore failed...");
  20. WScript.Echo("Most likely AzRoles is not properly registered...");
  21. WScript.Echo("------No test is conducted------");
  22. WScript.Quit();
  23. }
  24. WScript.Echo("Testing AccessCheck using store: " + WScript.Arguments(0));
  25. try
  26. {
  27. WScript.Echo("AzStore created.");
  28. AzStore.Initialize(0, WScript.Arguments(0));
  29. WScript.Echo("Open application for client context ...");
  30. var app = AzStore.OpenApplication("WebSites");
  31. if (app == null)
  32. {
  33. WScript.Echo("OpenApplication failed. Throwing exception...");
  34. TestSucceeded = false;
  35. throw "Can't open WebSites application";
  36. }
  37. WScript.Echo("Initializinng client context ...");
  38. var CC = app.InitializeClientContextFromToken(0);
  39. if (CC == null)
  40. {
  41. WScript.Echo("InitializeClientContextFromToken failed. Throwing exception...");
  42. TestSucceeded = false;
  43. throw "Can't initialize client context.";
  44. }
  45. var scopes = new Array("Create");
  46. var ops = new Array(1);
  47. ops[0] = 20;
  48. var paramNames = new Array("Amount", "Name");
  49. var paramValues = new Array(499, "Everyone");
  50. WScript.Echo("Testing Amount 499, we should succeed if not Everyone");
  51. var result = CC.AccessCheck("WebSites", null, ops, paramNames, paramValues);
  52. // will check each result
  53. var i;
  54. var varResultArray = new VBArray(result);
  55. var b = varResultArray.toArray();
  56. WScript.Echo("Printing result..." + b.length);
  57. for (i= 0; i < b.length; i++)
  58. {
  59. if (b[i] != 0)
  60. WScript.Echo("Operation " + ops[i] + " is denied." + " Result = " + b[i]);
  61. else
  62. WScript.Echo("Operation " + ops[i] + " is granted." + " Result = " + b[i]);
  63. }
  64. paramValues[0] = 5010;
  65. paramValues[1] = "Shawn";
  66. WScript.Echo("Testing Amount 5010. We should fail for developers using more 2000 except Shawn");
  67. result = CC.AccessCheck("WebSites", scopes, ops, paramNames, paramValues);
  68. var varResultA = new VBArray(result);
  69. var c = varResultA.toArray();
  70. WScript.Echo("Printing result..." + c.length);
  71. for (i= 0; i < c.length; i++)
  72. {
  73. if (c[i] != 0)
  74. WScript.Echo("Operation " + ops[i] + " is denied." + " Result = " + c[i]);
  75. else
  76. WScript.Echo("Operation " + ops[i] + " is granted." + " Result = " + c[i]);
  77. }
  78. }
  79. catch (e)
  80. {
  81. WScript.Echo("Exception encountered:");
  82. WScript.Echo(e.Description);
  83. TestSucceeded = false;
  84. }
  85. if (TestSucceeded)
  86. WScript.Echo("------Test completed successfully---------");
  87. else
  88. WScript.Echo("------Test completed with failures---------");
  89. </script>
  90. </job>