Ejemplo n.º 1
0
        /// <summary>
        /// Check if given user exists in the group provided
        /// </summary>
        /// <param name="uname">User name</param>
        /// <param name="role">Group</param>
        /// <returns>bool value true/false</returns>
        internal static bool CheckIfUserExistsInGroup(string uname, WCSSecurityRole role)
        {
            DirectoryEntry    AD     = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
            DirectorySearcher search = new DirectorySearcher("WinNT://" + Environment.MachineName + ",computer");
            bool userExistsInGrp     = false;

            try
            {
                DirectoryEntry myEntry = AD.Children.Find(uname, "user");
                DirectoryEntry grp     = AD.Children.Find(role.ToString(), "group");
                if (grp != null)
                {
                    if (grp.Properties["member"].Contains(myEntry))
                    {
                        Tracer.WriteInfo("user exists in group :" + role.ToString());
                        userExistsInGrp = true;
                    }
                }
            }
            // This exception is thrown when group does not exist
            catch (System.Runtime.InteropServices.COMException)
            {
                // Return false if group cannot be found
                userExistsInGrp = false;
            }

            return(userExistsInGrp);
        }
        public bool GetChassisHealth(bool allPassed, WCSSecurityRole roleId)
        {
            try
            {
                this.TestChannelContext = this.ListTestChannelContexts[(int)roleId];
                if (this.TestChannelContext != null)
                {
                    // Test for chassishealth components are returned when all params are true : WorkItem(3373 & 2746)
                    CmTestLog.Info("Verifying chassis health information when all params are true");
                    ChassisHealthResponse chassisHealth = this.TestChannelContext.GetChassisHealth(true, true, true, true);
                    allPassed &= this.VerifyChassisHealth(allPassed, chassisHealth);
                    CmTestLog.Info("!!!! Finished verification of Getchassishealth when all params are true !!!!\n");

                    // Test for chassishealth with no params : WorkItem(4776)
                    CmTestLog.Info("Verifying chassis health information when all params are false OR no Params");
                    chassisHealth = this.TestChannelContext.GetChassisHealth(false, false, false, false);
                    allPassed &= this.VerifyChassisHealth(allPassed, chassisHealth);
                    CmTestLog.Info("!!!! Finished verification of Getchassishealth with no params !!!!\n");

                    // Test for chassishealth get only bladeshell information : WorkItem(3157)
                    CmTestLog.Info("Verifying chassis health information for only Blade Health param is true");
                    chassisHealth = this.TestChannelContext.GetChassisHealth(true, false, false, false);
                    allPassed &= this.VerifyOnlyChassisBladeHealth(allPassed, chassisHealth);
                    CmTestLog.Info("!!!! Finished verification of Getchassishealth for only BladeHealth !!!!\n");

                    // Test for chassishealth get only PSU's health information : WorkItem(3159)
                    CmTestLog.Info("Verifying chassis health information for only psuHealth param is true");
                    chassisHealth = this.TestChannelContext.GetChassisHealth(false, true, false, false);
                    allPassed &= this.VerifyOnlyChassisPsuHealth(allPassed, chassisHealth);
                    CmTestLog.Info("!!!! Finished verification of Getchassishealth for only psuHealth !!!!\n");

                    // Test for chassishealth get only Fan's health information : WorkItem(3158)
                    CmTestLog.Info("Verifying chassis health information for only fan Health param is true");
                    chassisHealth = this.TestChannelContext.GetChassisHealth(false, false, true, false);
                    allPassed &= this.VerifyOnlyChassisFanHealth(allPassed, chassisHealth);
                    CmTestLog.Info("!!!! Finished verification of Getchassishealth for only fanHealth !!!!");
                }
            }
            catch (Exception ex)
            {
                ChassisManagerTestHelper.IsTrue(false, ex.Message);
                allPassed &= false;
            }
            CmTestLog.End(allPassed);
            return allPassed;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Find group with given name, if not exists create
        /// </summary>
        /// <param name="role">Group name</param>
        /// <returns>Group DirectorEntry</returns>
        internal static DirectoryEntry FindGroupIfNotExistsCreate(WCSSecurityRole role)
        {
            try
            {
                DirectoryEntry AD  = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
                DirectoryEntry grp = AD.Children.Find(role.ToString(), "group");
                if (grp == null)
                {
                    ChassisManagerUtil.CreateNewGroup(role);
                }

                return(grp);
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                Tracer.WriteInfo(" Group: {0} not found , creating new", role.ToString());
                return(ChassisManagerUtil.CreateNewGroup(role));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Remove user from given group. This is required
        /// when user role is changes
        /// </summary>
        /// <returns></returns>
        internal static void RemoveUserFromWCSSecurityGroups(string uname, WCSSecurityRole role)
        {
            Tracer.WriteInfo("RemoveUserFromWCSSecurityGroups: user: {0}, role: {1}", uname, role.ToString());
            DirectoryEntry AD      = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
            DirectoryEntry myEntry = AD.Children.Find(uname, "user");

            try
            {
                if (myEntry != null)
                {
                    DirectoryEntry grp = AD.Children.Find(role.ToString(), "group");
                    if (grp != null)
                    {
                        grp.Invoke("Remove", new object[] { myEntry.Path.ToString() });
                        grp.CommitChanges();
                        grp.Close();

                        Tracer.WriteInfo("RemoveUserFromWCSSecurityGroups: Removed uname: {0} from role: {1}", uname, role.ToString());
                    }
                }
            }
            catch (DirectoryServicesCOMException)
            {
                // Do nothing if group cannot be found/ if user is not a member of given group.
                // If group does not exists we don't need to remove user from it.
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                // Do nothing if group cannot be found/ if user is not a member of given group.
                // If group does not exists we don't need to remove user from it.
            }
            catch (Exception)
            {
                // Do nothing if group cannot be found/ if user is not a member of given group.
                // If group does not exists we don't need to remove user from it.
            }
        }
        private TestResponse GetChassisInfoByAllUsers(WCSSecurityRole roleId)
        {
            TestResponse response = new TestResponse();
            try
            {
                // Use the Domain User Channel
                this.TestChannelContext = this.ListTestChannelContexts[(int)roleId];
                if (this.TestChannelContext != null)
                {
                    ChassisInfoResponse chassisInfo = new ChassisInfoResponse();

                    // Test GetChassisInfo, get all information
                    CmTestLog.Info("Verifying chassis information when all params are true");
                    chassisInfo = this.TestChannelContext.GetChassisInfo(true, true, true, true);

                    TestResponse testResponse = this.VerifyChassisInfo(chassisInfo);
                    response.Result &= testResponse.Result;
                    response.ResultDescription.Append(testResponse.ResultDescription);

                    CmTestLog.Info("Finished verification of GetchassisInfo when all information was returned blade, PSU, battery and chassis controller \n");

                    // Test GetChassisInfo with no params
                    CmTestLog.Info("Verifying chassis information when all params are false OR no Params\n");
                    chassisInfo = this.TestChannelContext.GetChassisInfo(false, false, false, false);

                    testResponse = this.VerifyChassisInfo(chassisInfo);
                    response.Result &= testResponse.Result;
                    response.ResultDescription.Append(testResponse.ResultDescription);

                    CmTestLog.Info("Finished verification of GetchassisInfo with no params \n");

                    // Test for GetChassisInfo with only blade info
                    CmTestLog.Info("Verifying chassis information for only Blade, bladeInfo param is true\n");
                    chassisInfo = this.TestChannelContext.GetChassisInfo(true, false, false, false);

                    testResponse = this.VerifyOnlyChassisBladeInfo(chassisInfo);
                    response.Result &= testResponse.Result;
                    response.ResultDescription.Append(testResponse.ResultDescription);

                    CmTestLog.Info("Finished verification of GetchassisInfo for only Blade information \n");

                    // Test for GetChassisInfo for only PSU information
                    CmTestLog.Info("Verifying chassis information for only psuInfo param is true\n");
                    chassisInfo = this.TestChannelContext.GetChassisInfo(false, true, false, false);

                    testResponse = this.VerifyOnlyChassisPsuInfo(chassisInfo);
                    response.Result &= testResponse.Result;
                    response.ResultDescription.Append(testResponse.ResultDescription);

                    CmTestLog.Info("Finished verification of GetChassisInfo for only PSU information \n");

                    // Test for GetChassisInfo for only Battery information
                    CmTestLog.Info("Verifying chassis information for only batteryInfo param is true\n");
                    chassisInfo = this.TestChannelContext.GetChassisInfo(false, false, false, true);

                    testResponse = this.VerifyOnlyChassisBatteryInfo(chassisInfo);
                    response.Result = testResponse.Result;
                    response.ResultDescription.Append(testResponse.ResultDescription);

                    CmTestLog.Info("Finished verification of GetChassisInfo for only battery information \n");

                    // Test for GetChassisInfo for only chassis controller information
                    CmTestLog.Info("Verifying chassis information for only chassisControllerInfo param is true\n");
                    chassisInfo = this.TestChannelContext.GetChassisInfo(false, false, true, false);

                    testResponse = this.VerifyOnlyChassisControllerInfo(chassisInfo);
                    response.Result = testResponse.Result;
                    response.ResultDescription.Append(testResponse.ResultDescription);

                    CmTestLog.Info("Finished verification of GetChassisInfo for only chassis controller information \n");
                }
            }
            catch (Exception ex)
            {
                ChassisManagerTestHelper.IsTrue(false, ex.Message);
                response.Result &= false;
                response.ResultDescription.Append(ex.Message);
            }
            return response;
        }
        private bool GetSetNextBoots(bool testPassed, int bladeIndex, string failureMessage, int index,
                                     WCSSecurityRole roleId)
        {
            // Use different user context
            TestChannelContext = ListTestChannelContexts[(int)roleId];

            foreach (BladeBootType testedBootType in Enum.GetValues(typeof(BladeBootType)))
            {
                //Doing the same setting twice to make sure we are handling this properly.
                if (testedBootType.ToString() != BladeBootType.Unknown.ToString())
                {
                    //set to persistent.
                    BootResponse bBootType = TestChannelContext.SetNextBoot(bladeIndex, testedBootType, false, false, 0);
                    if (bBootType.completionCode != CompletionCode.Success)
                    {
                        failureMessage = string.Format("!!!Failed to set non persistant boot type to: {0}",
                                                       testedBootType);
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }

                    bBootType = TestChannelContext.GetNextBoot(bladeIndex);
                    if (testedBootType.ToString() != bBootType.nextBoot.ToString())
                    {
                        failureMessage = "!!!The Non persistent boot type did not match what it was set to.";
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }

                    //set to non persistent.
                    bBootType = TestChannelContext.SetNextBoot(bladeIndex, testedBootType, false, true, 1);
                    if (bBootType.completionCode != CompletionCode.Success)
                    {
                        failureMessage = string.Format("!!!Failed to set Persistent boot type to: {0}", testedBootType);
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }

                    //Make sure if no restart happens it keeps its value.
                    bBootType = TestChannelContext.GetNextBoot(bladeIndex);
                    if (testedBootType.ToString() != bBootType.nextBoot.ToString())
                    {
                        failureMessage = "!!!The boot type did not match what it was set to.";
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }
                    //Make sure it loses its value after restart
                    Channel.SetBladeActivePowerCycle(bladeIndex, 0);
                    Thread.Sleep(60000);
                    bBootType = Channel.GetNextBoot(bladeIndex);
                    if (testedBootType.ToString() != BladeBootType.ForcePxe.ToString() &&
                        testedBootType.ToString() != bBootType.nextBoot.ToString())
                    {
                        failureMessage =
                            string.Format(
                                "!!!The boot type did not match what it was set to before power cycle. {0} vs {1} this is round# {2}",
                                testedBootType, bBootType.nextBoot, index);
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }
                }
            }

            //reset for next test
            Channel.SetNextBoot(bladeIndex, BladeBootType.NoOverride, false, true, 0);


            return(testPassed);
        }
        /// <summary>
        /// A test for Set and Get Chassis LED
        /// </summary>
        public bool SetGetChassisLedOnOffTest(WCSSecurityRole roleId)
        {
            CmTestLog.Start();
            ChassisResponse chassisResponse;
            bool testPassed = false;

            CmTestLog.Info("Starting execution of SetChassisLEDOnOffTest.");
            try
            {
                // Use the Domain User Channel
                this.TestChannelContext = this.ListTestChannelContexts[(int)roleId];
                if (this.TestChannelContext != null)
                {
                    chassisResponse = this.TestChannelContext.GetChassisAttentionLEDStatus();
                    if (this.TestChannelContext.GetChassisAttentionLEDStatus().completionCode != CompletionCode.Success)
                    {
                        CmTestLog.Failure("SetChassisLEDOnOffTest: Failed to Get the LED status.");
                        return false;
                    }
                    testPassed = true;

                    chassisResponse = this.TestChannelContext.SetChassisAttentionLEDOn();

                    if (chassisResponse.completionCode != CompletionCode.Success || this.TestChannelContext.GetChassisAttentionLEDStatus().ledState != LedState.ON)
                    {
                        CmTestLog.Failure("SetChassisLEDOnOffTest: Failed to set the LED ON.");
                        return false;
                    }

                    //Turn On again
                    chassisResponse = this.TestChannelContext.SetChassisAttentionLEDOn();

                    if (chassisResponse.completionCode != CompletionCode.Success || this.TestChannelContext.GetChassisAttentionLEDStatus().ledState != LedState.ON)
                    {
                        CmTestLog.Failure("SetChassisLEDOnOffTest: Failed to set the LED ON.");
                        return false;
                    }
                    // Turn off
                    chassisResponse = this.TestChannelContext.SetChassisAttentionLEDOff();

                    if (chassisResponse.completionCode != CompletionCode.Success || this.TestChannelContext.GetChassisAttentionLEDStatus().ledState != LedState.OFF)
                    {
                        CmTestLog.Failure("SetChassisLEDOnOffTest: Failed to set the LED OFF.");
                        return false;
                    }
                    //turn off again
                    chassisResponse = this.TestChannelContext.SetChassisAttentionLEDOff();

                    if (chassisResponse.completionCode != CompletionCode.Success || this.TestChannelContext.GetChassisAttentionLEDStatus().ledState != LedState.OFF)
                    {
                        CmTestLog.Failure("SetChassisLEDOnOffTest: Failed to set the LED OFF.");
                        return false;
                    }
                    //turn on from Off
                    chassisResponse = this.TestChannelContext.SetChassisAttentionLEDOn();

                    if (chassisResponse.completionCode != CompletionCode.Success || this.TestChannelContext.GetChassisAttentionLEDStatus().ledState != LedState.ON)
                    {
                        CmTestLog.Failure("SetChassisLEDOnOffTest: Failed to set the LED ON.");
                        return false;
                    }
                }
            }
            catch (Exception ex)
            {
                // Check error is due to permission HTTP 400 unauthorize
                if (roleId == WCSSecurityRole.WcsCmUser && !ex.Message.Contains("400"))
                {
                    // Test failed, http response should contain http 401 error
                    CmTestLog.Failure("We are expecting 400 error due to user not having rights to set LED");
                }
                if(!testPassed)
                {
                    CmTestLog.Failure("All users have the right to GetChassisAttentionLedStatus. User from the follwoing role failed: " + roleId);
                }
                ChassisManagerTestHelper.IsTrue(false, ex.Message);
                return false;
            }
            return true;
        }
 private TestResponse VerifyStartBladeSerialSessionByUser(TestResponse response, WCSSecurityRole roleId, StartSerialResponse startResponse)
 {
     if (!(startResponse.completionCode == CompletionCode.Success || CompletionCode.SerialSessionActive == startResponse.completionCode) && (roleId == WCSSecurityRole.WcsCmAdmin))
     {
         response.Result = false;
         response.ResultDescription.Append(string.Format("\nFailed to start serial session with WcsAdmin User {0}, completion code returned: {1} ", roleId, startResponse.completionCode));
         CmTestLog.Failure(response.ResultDescription.ToString());
         return response;
     }
     else if ((startResponse.completionCode == CompletionCode.Success || CompletionCode.SerialSessionActive == startResponse.completionCode) && (roleId == WCSSecurityRole.WcsCmUser || roleId == WCSSecurityRole.WcsCmOperator))
     {
         response.Result = false;
         response.ResultDescription.Append(string.Format("User/Operator is able to start blade serial session {0}", roleId, "completion code returned: {1} ", startResponse.completionCode));
         CmTestLog.Failure(response.ResultDescription.ToString());
         return response;
     }
     else
     {
         response.Result &= ChassisManagerTestHelper.IsTrue((startResponse.completionCode == CompletionCode.Success || CompletionCode.SerialSessionActive == startResponse.completionCode),
             string.Format("Received success with user {0}", Enum.GetName(typeof(WCSSecurityRole), roleId)));
     }
     return response;
 }
        /// <summary>
        /// Method to change chassis controller user role
        /// </summary>
        /// <param name="userName">User name</param>
        /// <param name="role">WCS Security role</param>
        /// <returns>Chassis Response indicating if the update user settings was a success/failure</returns>
        public Contracts.ChassisResponse ChangeChassisControllerUserRole(string userName, WCSSecurityRole role)
        {
            Contracts.ChassisResponse response = new Contracts.ChassisResponse();
            DirectoryEntry grp;
            response.completionCode = Contracts.CompletionCode.Unknown;
            response.statusDescription = String.Empty;

            Tracer.WriteUserLog(String.Format("Invoked ChangeChassisControllerUserRole(userName: {0}, role: {1})", userName, role.ToString()));
            try
            {
                // Validate input parameters

                // Check if input user security role is valid
                if (!Enum.IsDefined(typeof(WCSSecurityRole), role))
                {
                    Tracer.WriteError("ChangeChassisControllerUser: Invalid security role " + role.ToString());
                    response.completionCode = Contracts.CompletionCode.ParameterOutOfRange;
                    response.statusDescription = "Input security role is invalid";
                    return response;
                }

                userName = userName.Trim();

                if (userName == null)
                {
                    Tracer.WriteError("ChangeChassisControllerUserRole: Invalid input parameters.");
                    response.completionCode = Contracts.CompletionCode.ParameterOutOfRange;
                    response.statusDescription = "User name provided is null";
                    return response;
                }

                DirectoryEntry AD = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
                DirectoryEntry myEntry = AD.Children.Find(userName, "user");

                // Remove user from other WCS security group , if it exists in them
                // This step is required as if the user permissions are decreased from
                // admin to user, then he should no longer be in admin role.Similar with operator to user.

                if (role != WCSSecurityRole.WcsCmAdmin)
                {
                    ChassisManagerUtil.RemoveUserFromWCSSecurityGroups(userName, WCSSecurityRole.WcsCmAdmin);
                }

                if (role != WCSSecurityRole.WcsCmOperator)
                {
                    ChassisManagerUtil.RemoveUserFromWCSSecurityGroups(userName, WCSSecurityRole.WcsCmOperator);
                }

                if (role != WCSSecurityRole.WcsCmUser)
                {
                    ChassisManagerUtil.RemoveUserFromWCSSecurityGroups(userName, WCSSecurityRole.WcsCmUser);
                }

                // Add if user does not already exists in the given group
                if (!ChassisManagerUtil.CheckIfUserExistsInGroup(userName, role))
                {
                    // Find group if not exists create new
                    grp = ChassisManagerUtil.FindGroupIfNotExistsCreate(role);

                    if (grp != null)
                    {
                        // Add user to group
                        grp.Invoke("Add", new object[] { myEntry.Path.ToString() });
                        grp.CommitChanges();
                        grp.Close();
                    }
                    else
                    {
                        Tracer.WriteError("ChangeChassisControllerUserRole: Failed to change user role, failed to find/add group");
                        response.completionCode = Contracts.CompletionCode.Failure;
                        response.statusDescription = String.Format("ChangeChassisControllerUserRole: Failed to change user role, failed to find/add group");
                        return response;
                    }
                }

                Tracer.WriteInfo("ChangeChassisControllerUserRole: Role changed successfully");
                response.completionCode = Contracts.CompletionCode.Success;
                return response;
            }
            catch (Exception ex)
            {
                Tracer.WriteError("ChangeChassisControllerUserRole: failed with exception: " + ex);

                // user already belongs to the role, we don't need any action hence consider it success
                if (ex.ToString().Contains("The specified account name is already a member of the group"))
                {
                    response.completionCode = Contracts.CompletionCode.Success;
                }
                // check if password did not meet the requirements, display appropriate message to user.
                else if (ex.ToString().Contains("0x800708C5") || ex.ToString().Contains("password does not meet"))
                {
                    response.completionCode = Contracts.CompletionCode.UserPasswordDoesNotMeetRequirement;
                    response.statusDescription = "User password does not meet system requirements";
                }
                // check the exception code for user not found
                else if (ex.ToString().Contains("0x800708AD"))
                {
                    response.completionCode = Contracts.CompletionCode.UserNotFound;
                    response.statusDescription = "User name provided cannot be found";
                }
                else
                {
                    response.completionCode = Contracts.CompletionCode.Failure;
                    response.statusDescription = String.Format("ChangeChassisControllerUserRole failed. Unknown Error.");
                }
                return response;
            }
        }
 private TestResponse VerifySendPortSerialDataByUser(TestResponse response, WCSSecurityRole roleId, ChassisResponse sendPortSerialDataResponse)
 {
     if (!(CompletionCode.Success == sendPortSerialDataResponse.completionCode) && (roleId == WCSSecurityRole.WcsCmAdmin || roleId == WCSSecurityRole.WcsCmOperator))
     {
         response.Result = false;
         response.ResultDescription.Append(string.Format("\nFailed to send port serial data with WcsAdmin/WcsOperator User {0}, completion code returned: {1} ", roleId, sendPortSerialDataResponse.completionCode));
         CmTestLog.Failure(response.ResultDescription.ToString());
         return response;
     }
     else if ((CompletionCode.Success == sendPortSerialDataResponse.completionCode) && (roleId == WCSSecurityRole.WcsCmUser))
     {
         response.Result = false;
         response.ResultDescription.Append(string.Format("User is able to send port serial data {0}", roleId, "completion code returned: {1} ", sendPortSerialDataResponse.completionCode));
         CmTestLog.Failure(response.ResultDescription.ToString());
         return response;
     }
     else
     {
         response.Result &= ChassisManagerTestHelper.IsTrue(CompletionCode.Success == sendPortSerialDataResponse.completionCode,
             string.Format("Received success with user {0}", Enum.GetName(typeof(WCSSecurityRole), roleId)));
     }
     return response;
 }
 private bool VerifySetAllBladesDefaultPowerState(ref bool testPassed, WCSSecurityRole roleId, AllBladesResponse allPowerResponse)
 {
     if (allPowerResponse.completionCode != CompletionCode.Success && (roleId == WCSSecurityRole.WcsCmAdmin || roleId == WCSSecurityRole.WcsCmOperator))
     {
         CmTestLog.Failure(string.Format("Cannot set all blades default power state With User {0}", roleId));
         CmTestLog.End(false);
         return false;
     }
     else if (allPowerResponse.completionCode == CompletionCode.Success && (roleId == WCSSecurityRole.WcsCmUser))
     {
         CmTestLog.Failure(string.Format("User is able to set all blades default power state {0}", roleId));
         CmTestLog.End(false);
         return false;
     }
     else
     {
         testPassed &= ChassisManagerTestHelper.AreEqual(allPowerResponse.completionCode, CompletionCode.Success,
             string.Format("Received success with user {0}", Enum.GetName(typeof(WCSSecurityRole), roleId)));
     }
     return testPassed;
 }
        public bool GetBladeHealth(bool allPassed, WCSSecurityRole roleId)
        {
            try
            {
                this.TestChannelContext = this.ListTestChannelContexts[(int)roleId];
                if (this.TestChannelContext != null)
                {
                    // get health information for each blade
                    for (int bladeId = 1; bladeId <= CmConstants.Population; bladeId++)
                    {
                        // If the slot is empty [WorkItem(3372)]
                        if (this.EmptyLocations != null && this.EmptyLocations.Contains(bladeId))
                        {
                            CmTestLog.Info(string.Format("Slot# {0} is empty", bladeId));
                            allPassed = this.BladeHealthForEmptyBlades(ref allPassed, bladeId);
                        }
                        // If the slot is JBOD: WorkItem(3371)
                        else if (this.JbodLocations != null && this.JbodLocations.Contains(bladeId))
                        {
                            CmTestLog.Info(string.Format("Slot# {0} is JBOD", bladeId));
                            allPassed = this.VerifyJbodBladeHealth(allPassed, bladeId);

                            // Test for only DiskInformation for JBOD : WorkItem(3445)
                            allPassed = this.GetOnlyDiskInformationBladeHealth(allPassed, bladeId);
                            CmTestLog.Info("!!!! Finished verification of disk information for JBOD !!!!\n");
                        }
                        else
                        {
                            // Testing all blade health components are returned: WorkItem(4775)
                            CmTestLog.Info(string.Format("Verifying health information when all params are true for Blade# {0}", bladeId));
                            BladeHealthResponse bladeHealth = this.TestChannelContext.GetBladeHealth(bladeId, true, true, true, true, true, true, true);

                            allPassed = this.GetServerHealth(allPassed, bladeHealth, bladeId);
                            CmTestLog.Info("!!!! Finished verification of Getbladehealth when all params are true !!!!\n");

                            //Test for all blade health components are returned when all params are false : WorkItem(3370)
                            CmTestLog.Info(string.Format("Verifying health information when all params are false for Blade# {0}", bladeId));
                            bladeHealth = this.TestChannelContext.GetBladeHealth(bladeId, false, false, false, false, false, false, false);
                            allPassed = this.GetServerHealth(allPassed, bladeHealth, bladeId);
                            CmTestLog.Info("!!!! Finished verification of Getbladehealth when all params are False !!!!\n");

                            //Test for only processor information: WorkItem(3443 & 4655)
                            allPassed = this.GetOnlyProcessorInformationBladeHealth(allPassed, bladeId);
                            CmTestLog.Info("!!!! Finished verification of processor information for GetBladeHealth !!!!\n");

                            //Test for only memory information : WorkItem(3444)
                            allPassed = this.GetOnlyMemoryInformationBladeHealth(allPassed, bladeId);
                            CmTestLog.Info("!!!!  Finished verification of Memory information for GetBladeHealth !!!!\n");

                            //Test for only PCIe Information : WorkItem(3446)
                            allPassed = this.GetOnlyPCIeInformationBladeHealth(allPassed, bladeId);
                            CmTestLog.Info("!!!! Finished verification of PCIe information for GetBladeHealth !!!!\n");

                            // Test for only sensor information : WorkItem(3447)
                            allPassed = this.GetOnlySensorInformationBladeHealth(allPassed, bladeId);
                            CmTestLog.Info("!!!! Finished verification of sensor information for GetBladeHealth !!!!\n");

                            // Test for only temparature information : WorkItem(4656)
                            allPassed = this.GetOnlyTemperatureInformationBladeHealth(allPassed, bladeId);
                            CmTestLog.Info("!!!! Finished verification of temparature information for GetBladeHealth !!!!\n");

                            //Test for only FRU Information :  WorkItem(3452)
                            allPassed = this.GetOnlyFruInformationBladeHealth(allPassed, bladeId);
                            CmTestLog.Info("!!!! Finished verification of FRU information for GetBladeHealth !!!!\n");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ChassisManagerTestHelper.IsTrue(false, ex.Message);
                allPassed = false;
            }

            CmTestLog.End(allPassed);
            return allPassed;
        }
 /// <summary>
 ///     Remove
 /// </summary>
 /// <param name="roleId"></param>
 /// <returns></returns>
 private bool AddDomainUserToLocalWcsRole(WCSSecurityRole roleId)
 {
     try
     {
         //Add domain test user to local Wcs group
         using (
         var localMachine = new DirectoryEntry(string.Format("WinNT://{0},computer", this.defaultCmName),
             this.defaultAdminUserName, this.defaultAdminPassword))
         {
             string userPath = string.Format("WinNT://{0}.Lab/{1},user", this.labDomainName, this.labDomainTestUser);
             string groupPath = string.Format("WinNT://{0}/{1},group", this.defaultCmName, roleId);
             using (DirectoryEntry dComUsersGrp = localMachine.Children.Find(roleId.ToString(), "group"))
             {
                 dComUsersGrp.Invoke("Add", userPath);
                 dComUsersGrp.CommitChanges();
                 Console.WriteLine("Domain account added Successfully");
             }
         }
     }
     catch
     {
         //Shouldn't be here, user must be already there.
         return false;
     }
     return true;
 }
        /// <summary>
        ///     Remove test domain user from Local WcsCM group
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="roleId"></param>
        /// <returns></returns>
        private bool RemoveDomainuserFromLocalWcsRole(string userName, WCSSecurityRole roleId)
        {
            if (userName == null)
            {
                throw new ArgumentNullException("userName");
            }
            try
            {
                //Remove domain test user to local Wcs group
                using (
                var localMachine = new DirectoryEntry(string.Format("WinNT://{0},computer", this.defaultCmName),
                    this.defaultAdminUserName, this.defaultAdminPassword))
                {
                    string userPath = string.Format("WinNT://{0}.Lab/{1},user", this.labDomainName, userName);

                    string groupPath = string.Format("WinNT://{0}/{1},group", this.defaultCmName, roleId);

                    using (DirectoryEntry dComUsersGrp = localMachine.Children.Find(roleId.ToString(), "group"))
                    {
                        // Delete Domain user from a group
                        dComUsersGrp.Invoke("Remove", new object[] { userPath });
                        dComUsersGrp.CommitChanges();
                        Console.WriteLine("Domain account removed Successfully");
                    }
                }
            }
            catch
            {
                return false;
            }
            return true;
        }
 private TestResponse VerifyStopSerialPortConsoleByUser(TestResponse response, WCSSecurityRole roleId, ChassisResponse stopResponse)
 {
     if (!(CompletionCode.NoActiveSerialSession == stopResponse.completionCode || CompletionCode.Success == stopResponse.completionCode) && (roleId == WCSSecurityRole.WcsCmAdmin || roleId == WCSSecurityRole.WcsCmOperator))
     {
         response.Result = false;
         response.ResultDescription.Append(string.Format("\nFailed to stop Port serial session with WcsAdmin/WcsOperator User {0}, completion code returned: {1} ", roleId, stopResponse.completionCode));
         return response;
     }
     else if ((CompletionCode.NoActiveSerialSession == stopResponse.completionCode || CompletionCode.Success == stopResponse.completionCode) && (roleId == WCSSecurityRole.WcsCmUser))
     {
         response.Result = false;
         response.ResultDescription.Append(string.Format("WcsUser is able to stop port serial session {0}", roleId, "completion code returned: {1} ", stopResponse.completionCode));
         return response;
     }
     else
     {
         response.Result &= ChassisManagerTestHelper.IsTrue((CompletionCode.NoActiveSerialSession == stopResponse.completionCode || CompletionCode.Success == stopResponse.completionCode),
             string.Format("Received success with user {0}", Enum.GetName(typeof(WCSSecurityRole), roleId)));
     }
     return response;
 }
Ejemplo n.º 16
0
        /// <summary>
        ///     Verify only users member of Operator or Admin is able to execute following command
        /// </summary>
        /// <param name="testPassed"></param>
        /// <param name="bladeIndex"></param>
        /// <param name="powerLimitValue"></param>
        /// <param name="failureMessage"></param>
        /// <param name="roleId"></param>
        /// <param name="allbladeResponse"></param>
        private void SetBladPowerLimitByAdminOperator(ref Boolean testPassed, ref int bladeIndex, int powerLimitValue,
            ref string failureMessage, WCSSecurityRole roleId, out AllBladesResponse allbladeResponse)
        {
            BladeResponse bladeResponse;

            allbladeResponse = TestChannelContext.SetAllBladesPowerLimit(powerLimitValue);
            foreach (BladeResponse bResponse in allbladeResponse.bladeResponseCollection)
            {
                if (!JbodLocations.Contains(bladeIndex) && !EmptyLocations.Contains(bladeIndex))
                {
                    if (bResponse.completionCode != CompletionCode.Success &&
                        (roleId == WCSSecurityRole.WcsCmAdmin || roleId == WCSSecurityRole.WcsCmOperator))
                    {
                        failureMessage = string.Format("Failed to set blade power limit for blade# {0} by {1}",
                            bladeIndex, roleId);
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }
                    else if (bResponse.completionCode == CompletionCode.Success && (roleId == WCSSecurityRole.WcsCmUser))
                    {
                        failureMessage =
                            string.Format("wcsUser successfully to set blade power limit for blade# {0}", bladeIndex);
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }

                    // This must be valid blade, try to set the set power limit
                    bladeResponse = TestChannelContext.SetBladePowerLimit(bladeIndex, powerLimitValue);
                    if (bladeResponse.completionCode != CompletionCode.Success &&
                        (roleId == WCSSecurityRole.WcsCmAdmin || roleId == WCSSecurityRole.WcsCmOperator))
                    {
                        failureMessage = "Admin/Operator Failed to set power limit.";
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }
                    else if (bladeResponse.completionCode == CompletionCode.Success &&
                             roleId == WCSSecurityRole.WcsCmUser)
                    {
                        failureMessage = "WcsUser shouldn't allow to set the power limit.";
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }
                }
                else
                {
                    if (JbodLocations.Contains(bladeIndex) &&
                        bResponse.completionCode != CompletionCode.CommandNotValidForBlade)
                    {
                        failureMessage =
                            "This must have been a JBOD. it must fail with commandNotValidForBlade for blade# " +
                            bladeIndex;
                        Console.WriteLine(failureMessage);
                        testPassed = false;
                    }
                    if (!EmptyLocations.Contains(bladeIndex))
                    {
                        // This must be Jbod, send requests for set power limit
                        bladeResponse = TestChannelContext.SetBladePowerLimit(bladeIndex, powerLimitValue);
                        if (bladeResponse.completionCode == CompletionCode.Success &&
                            (roleId == WCSSecurityRole.WcsCmAdmin || roleId == WCSSecurityRole.WcsCmOperator))
                        {
                            failureMessage = "It must fail with commandNotValidForBlade for blade";
                            Console.WriteLine(failureMessage);
                            testPassed = false;
                        }
                    }
                }
                bladeIndex++;
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        ///     Verify only users member of Operator or Admin is able to execute following command
        ///     SetAllBladesPowerLimitOn
        ///     SetBladePowerLimitOn
        ///     SetAllBladesPowerLimitOff
        ///     SetBladePowerLimitOff
        /// </summary>
        /// <returns></returns>
        private void SetBladePowerLimitOnOff(ref Boolean testPassed, ref int bladeIndex, ref string failureMessage,
            WCSSecurityRole roleId)
        {
            BladeResponse bladeResponse;
            AllBladesResponse allbladeResponse;

            allbladeResponse = TestChannelContext.SetAllBladesPowerLimitOn();
            foreach (BladeResponse bResponse in allbladeResponse.bladeResponseCollection)
            {
                if (!JbodLocations.Contains(bladeIndex) && !EmptyLocations.Contains(bladeIndex))
                {
                    if (bResponse.completionCode != CompletionCode.Success &&
                        (roleId == WCSSecurityRole.WcsCmAdmin || roleId == WCSSecurityRole.WcsCmOperator))
                    {
                        failureMessage = string.Format("Failed to set blade power limit On for blade# {0} by {1}",
                            bladeIndex, roleId);
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }
                    else if (bResponse.completionCode == CompletionCode.Success && (roleId == WCSSecurityRole.WcsCmUser))
                    {
                        failureMessage = string.Format(
                            "WcsUser successfully set blade power limit for blade# {0} ", bladeIndex);
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }

                    // This must be valid blade, try to set the set power limit Off
                    bladeResponse = TestChannelContext.SetBladePowerLimitOn(bladeIndex);
                    if (bladeResponse.completionCode != CompletionCode.Success &&
                        (roleId == WCSSecurityRole.WcsCmAdmin || roleId == WCSSecurityRole.WcsCmOperator))
                    {
                        failureMessage = "Admin/Operator failed to set power limit off";
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }
                    else if (bladeResponse.completionCode == CompletionCode.Success &&
                             roleId == WCSSecurityRole.WcsCmUser)
                    {
                        failureMessage = "WcsUser successfully allow to set the power limit On.";
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }
                }
                else
                {
                    if (JbodLocations.Contains(bladeIndex) &&
                        bResponse.completionCode != CompletionCode.CommandNotValidForBlade)
                    {
                        failureMessage =
                            "This must have been a JBOD. it must fail with commandNotValidForBlade for blade# " +
                            bladeIndex;
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }
                    if (!EmptyLocations.Contains(bladeIndex))
                    {
                        bladeResponse = TestChannelContext.SetBladePowerLimitOn(bladeIndex);
                        if (bladeResponse.completionCode == CompletionCode.Success &&
                            (roleId == WCSSecurityRole.WcsCmAdmin || roleId == WCSSecurityRole.WcsCmOperator))
                        {
                            failureMessage = "This is JBOD. it must fail with commandNotValidForBlade for blade";
                            CmTestLog.Failure(failureMessage);
                            testPassed = false;
                        }
                    }
                }
                bladeIndex++;
            }

            // Reset blade
            bladeIndex = 1;

            // Set the Blade Power off
            allbladeResponse = TestChannelContext.SetAllBladesPowerLimitOff();
            foreach (BladeResponse bResponse in allbladeResponse.bladeResponseCollection)
            {
                if (!JbodLocations.Contains(bladeIndex) && !EmptyLocations.Contains(bladeIndex))
                {
                    if (bResponse.completionCode != CompletionCode.Success &&
                        (roleId == WCSSecurityRole.WcsCmAdmin || roleId == WCSSecurityRole.WcsCmOperator))
                    {
                        failureMessage = string.Format("Failed to set blade power limit Off for blade# {0} by {1}",
                            bladeIndex, roleId);
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }
                    else if (bResponse.completionCode == CompletionCode.Success && (roleId == WCSSecurityRole.WcsCmUser))
                    {
                        failureMessage =
                            string.Format("WcsUser successfully to set blade power limit Off for blade# {0} ",
                                bladeIndex);
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }

                    // This must be valid blade, try to set the set power limit On
                    bladeResponse = TestChannelContext.SetBladePowerLimitOn(bladeIndex);
                    if (bladeResponse.completionCode != CompletionCode.Success &&
                        (roleId == WCSSecurityRole.WcsCmAdmin || roleId == WCSSecurityRole.WcsCmOperator))
                    {
                        failureMessage = "";
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }
                    else if (bladeResponse.completionCode == CompletionCode.Success &&
                             roleId == WCSSecurityRole.WcsCmUser)
                    {
                        failureMessage = "WcsUser shouldn't allow to set the power limit Off.";
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }
                }
                else
                {
                    if (JbodLocations.Contains(bladeIndex) &&
                        bResponse.completionCode != CompletionCode.CommandNotValidForBlade)
                    {
                        failureMessage =
                            "This must have been a JBOD. it must fail with commandNotValidForBlade for blade# " +
                            bladeIndex;
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }
                    if (!EmptyLocations.Contains(bladeIndex))
                    {
                        bladeResponse = TestChannelContext.SetBladePowerLimitOn(bladeIndex);
                        if (bladeResponse.completionCode == CompletionCode.Success &&
                            (roleId == WCSSecurityRole.WcsCmAdmin || roleId == WCSSecurityRole.WcsCmOperator))
                        {
                            failureMessage = "This is a JBOD. It must fail with commandNotValidForBlade for blade# " +
                                             bladeIndex;
                            CmTestLog.Failure(failureMessage);
                            testPassed = false;
                        }
                    }
                }
                bladeIndex++;
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        ///     SetACSocketPowerStateOff: Verify that only Operator and Admin can execute the command
        /// </summary>
        /// <param name="testPassed"></param>
        /// <param name="failureMessage"></param>
        /// <param name="numAcSocket"></param>
        /// <param name="roleId"></param>
        private void AcSocketSetGetValidation(ref bool testPassed, ref string failureMessage, uint numAcSocket,
                                              WCSSecurityRole roleId)
        {
            ChassisResponse       acSocketResponse = null;
            ACSocketStateResponse acSocketPower    = null;

            // Use different user context
            this.TestChannelContext = this.ListTestChannelContexts[(int)roleId];

            for (int testedAcSocket = 1; testedAcSocket <= numAcSocket; testedAcSocket++)
            {
                // Turn On ACSocket
                acSocketResponse = this.TestChannelContext.SetACSocketPowerStateOn(testedAcSocket);
                if (acSocketResponse.completionCode != CompletionCode.Success &&
                    (roleId == WCSSecurityRole.WcsCmAdmin || roleId == WCSSecurityRole.WcsCmOperator))
                {
                    failureMessage =
                        string.Format("!!!Failed to power ON AC socket when it is already ON for AC Socket# {0}",
                                      testedAcSocket);
                    CmTestLog.Failure(failureMessage);
                    testPassed = false;
                }
                else if (acSocketResponse.completionCode == CompletionCode.Success &&
                         (roleId == WCSSecurityRole.WcsCmUser))
                {
                    failureMessage =
                        string.Format("User is not allow to called out to SetACSocketPowerStateOn {0} Socket# {1}",
                                      roleId, testedAcSocket);
                    CmTestLog.Failure(failureMessage);
                    testPassed = false;
                }
                else
                {
                    // Verify power state
                    acSocketPower = this.Channel.GetACSocketPowerState(testedAcSocket);
                    if (acSocketPower.powerState != PowerState.ON)
                    {
                        failureMessage =
                            string.Format(
                                "!!!Failed to power ON AC socket when it is already ON for AC Socket# {0}",
                                testedAcSocket);
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }
                }

                // Turn  off ACSocket
                acSocketResponse = this.TestChannelContext.SetACSocketPowerStateOff(testedAcSocket);
                if (acSocketResponse.completionCode != CompletionCode.Success &&
                    (roleId == WCSSecurityRole.WcsCmAdmin || roleId == WCSSecurityRole.WcsCmOperator))
                {
                    failureMessage =
                        string.Format("!!!Failed to power ON AC socket when it is already ON for AC Socket# {0}",
                                      testedAcSocket);
                    CmTestLog.Failure(failureMessage);
                    testPassed = false;
                }
                else if (acSocketResponse.completionCode == CompletionCode.Success && roleId == WCSSecurityRole.WcsCmUser)
                {
                    failureMessage =
                        string.Format(
                            "User is not allow to called out to SetACSocketPowerStateOff {0} Socket# {1}", roleId,
                            testedAcSocket);
                    CmTestLog.Failure(failureMessage);
                    testPassed = false;
                }
                else
                {
                    // Verify power state
                    acSocketPower = this.Channel.GetACSocketPowerState(testedAcSocket);
                    if (acSocketPower.powerState != PowerState.OFF)
                    {
                        failureMessage =
                            string.Format(
                                "!!!Failed to power ON AC socket when it is already ON for AC Socket# {0}",
                                testedAcSocket);
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }
                }
            }// end of for loop
        }
        private void VerifyReadChassisLog(ref bool chassisPassed, WCSSecurityRole user)
        {
            string currentApi = "ReadChassisLog";
            string logParentDirectory = @"\\" + defaultCMName + @"\c$\";
            string[] userLogPaths = new string[] { null, null };

            ChassisLogResponse chassisLog = new ChassisLogResponse();
            CmTestLog.Info("TestChannelContext user " + (int)user);
            this.TestChannelContext = this.ListTestChannelContexts[(int)user];

            chassisLog = this.TestChannelContext.ReadChassisLog();

            chassisPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.Success, chassisLog.completionCode,
                currentApi + ": Completion Code success for user " + user.ToString());

            if (StartStopCmService("stop"))
                CmTestLog.Success(currentApi + ": Stopped Chassis Manager Service");
            else
            {
                CmTestLog.Failure(currentApi +
                    ": Unable to stop Chassis Manager Service. Will not check log entry contents");
                chassisPassed = false;
                return;
            }

            // Check Log entries are populated in ChassisLogResponse and not greater than 50 entries
            if (chassisLog.logEntries.Count < 1)
            {
                CmTestLog.Failure(currentApi + ": Command does not return Log Entries");
                chassisPassed = false;
                ChassisManagerTestHelper.IsTrue(StartStopCmService("start"),
                    currentApi + ": Stopped Chassis Manager Service");
                return;
            }
            else if (chassisLog.logEntries.Count > 50)
            {
                CmTestLog.Failure(currentApi + ": Command returns more than 50 Log Entries");
                chassisPassed = false;
                ChassisManagerTestHelper.IsTrue(StartStopCmService("start"),
                    currentApi + ": Stopped Chassis Manager Service");
                return;
            }
            else
                CmTestLog.Success(currentApi + ": Command returns between 1 and 50 Log Entries");

            IntPtr token = IntPtr.Zero;

            // Impersonate remote user
            bool successLogon = LogonUser(defaultAdminUserName, defaultCMName, defaultAdminPassword,
                (int)DwLogonType.NewCredentials, (int)DwLogonProvider.WinNT50, ref token);

            if (successLogon)
            {
                using (WindowsImpersonationContext context = WindowsIdentity.Impersonate(token))
                {
                    // Verify that User Logs exist to compare log entries with ChassisLogResponse
                    if (!Directory.Exists(logParentDirectory))
                    {
                        CmTestLog.Failure(currentApi + ": Directory to User Log files does not exist");
                        chassisPassed = false;
                        ChassisManagerTestHelper.IsTrue(StartStopCmService("start"),
                            currentApi + ": Stopped Chassis Manager Service");
                        return;
                    }

                    foreach (string filePath in Directory.GetFiles(logParentDirectory))
                    {
                        Match fileMatch00 = Regex.Match(filePath, @"ChassisManagerUserLog00\.svclog");
                        Match fileMatch01 = Regex.Match(filePath, @"ChassisManagerUserLog01\.svclog");

                        if (fileMatch00.Success)
                            userLogPaths[0] = filePath;
                        else if (fileMatch01.Success)
                            userLogPaths[1] = filePath;
                    }

                    if (userLogPaths[0] == null && userLogPaths[1] == null)
                    {
                        CmTestLog.Failure(currentApi + ": Could not find user logs");
                        chassisPassed = false;
                        ChassisManagerTestHelper.IsTrue(StartStopCmService("start"),
                            currentApi + ": Started Chassis Manager Service");
                        return;
                    }

                    // Compare and match log entries in ChassisLogResponse to User Logs in Chassis Manager
                    int entryCount = 0;
                    bool allEntriesPassed = true;
                    foreach (LogEntry entry in chassisLog.logEntries)
                    {
                        if (entry.eventDescription == null && entry.eventTime == null)
                        {
                            CmTestLog.Failure(currentApi +
                                string.Format(": Log Entry {0} returns no data for either eventDescription or eventTime or both", entryCount));
                            allEntriesPassed = false;
                            entryCount++;
                            continue;
                        }

                        // Find log entry in either UserLog00 or UserLog01
                        int userLogCount = 0;
                        bool userLogEntryFound = false;
                        string propertyValue;
                        foreach (string userLogPath in userLogPaths)
                        {
                            if (userLogPath == null)
                            {
                                CmTestLog.Info(currentApi + string.Format(": User Log {0} does not exist", userLogCount));
                                userLogCount++;
                                continue;
                            }

                            XmlReaderSettings xmlSettings = new XmlReaderSettings();
                            xmlSettings.ConformanceLevel = ConformanceLevel.Fragment;

                            XmlReader userLogReader = XmlReader.Create(userLogPath, xmlSettings);

                            try
                            {
                                while (!userLogEntryFound)
                                {
                                    while (userLogReader.Read())
                                    {
                                        if (userLogReader.Name == "ApplicationData")
                                            break;
                                    }

                                    if (userLogReader.Name != "ApplicationData")
                                    {
                                        userLogReader.Close();
                                        break;
                                    }

                                    // Read User Log Entry and condition both strings for comparison
                                    propertyValue = userLogReader.ReadElementContentAsString();
                                    propertyValue = propertyValue.Replace(@"\", "");
                                    propertyValue = propertyValue.Replace(@"(", "");
                                    propertyValue = propertyValue.Replace(@")", "");
                                    entry.eventDescription = entry.eventDescription.Replace(@"\", "");
                                    entry.eventDescription = entry.eventDescription.Replace(@"(", "");
                                    entry.eventDescription = entry.eventDescription.Replace(@")", "");

                                    Match eventTimeMatch = Regex.Match(propertyValue,
                                        entry.eventTime.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                                    Match eventDescriptionMatch = Regex.Match(propertyValue, entry.eventDescription);

                                    if (eventTimeMatch.Success && eventDescriptionMatch.Success)
                                    {
                                        CmTestLog.Success(currentApi +
                                            string.Format(": Found eventTime match and eventDescription match for entry {0} in user log {1}", entryCount, userLogCount));
                                        userLogEntryFound = true;
                                    }
                                }
                            }
                            catch (Exception exc)
                            {
                                if (exc.Message.Contains(@"Not enough )'s"))
                                {
                                    CmTestLog.Info(currentApi + string.Format(": Entry {0} throwing exception 'Not enough )'s' in User Log {1}", entryCount, userLogCount));
                                    userLogCount++;
                                    continue;
                                }
                                else
                                    throw new Exception(exc.Message);
                            }

                            if (!userLogEntryFound)
                            {
                                CmTestLog.Info(currentApi + string.Format(": User Log {0} does not contain entry {1}", userLogCount, entryCount));
                                userLogReader.Close();
                                userLogCount++;
                                continue;
                            }

                            userLogReader.Close();
                            userLogCount++;
                        }

                        if (!userLogEntryFound)
                        {
                            CmTestLog.Failure(currentApi + string.Format(": Entry {0} was not found in either user logs", entryCount));
                            allEntriesPassed = false;
                            entryCount++;
                            continue;
                        }

                        chassisPassed &= allEntriesPassed;
                        entryCount++;
                    }
                    ChassisManagerTestHelper.IsTrue(allEntriesPassed,
                        currentApi + string.Format(": All Log Entries passed", entryCount));

                    // Revert back to original user
                    context.Undo();
                }
            }
            else
            {
                CmTestLog.Failure("UserLogon: User failed to be created");
                chassisPassed = false;
            }

            ChassisManagerTestHelper.IsTrue(StartStopCmService("start"),
                currentApi + ": Started Chassis Manager Service");
        }
        /// <summary>
        ///     Add local test user account to WcsCM group.
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="testCmUri"></param>
        /// <param name="roleId"></param>
        /// <returns></returns>
        private bool LocalTestUserToWcsCMroup(string userName, string testCmUri, WCSSecurityRole roleId)
        {
            try
            {
                using (
                var ad = new DirectoryEntry(string.Format("WinNT://{0},computer", testCmUri), this.defaultAdminUserName,
                    this.defaultAdminPassword))
                {
                    DirectoryEntries users = ad.Children;
                    DirectoryEntry user = users.Find(userName);

                    DirectoryEntry grp = ad.Children.Find(roleId.ToString(), "group");
                    grp.Invoke("Add", new object[] { user.Path });
                }
            }
            catch
            {
                return false;
            }
            return true;
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Check if given user exists in the group provided
        /// </summary>
        /// <param name="uname">User name</param>
        /// <param name="role">Group</param>
        /// <returns>bool value true/false</returns>
        internal static bool CheckIfUserExistsInGroup(string uname, WCSSecurityRole role)
        {
            DirectoryEntry AD = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
            DirectorySearcher search = new DirectorySearcher("WinNT://" + Environment.MachineName + ",computer");
            bool userExistsInGrp = false;
            try
            {
                DirectoryEntry myEntry = AD.Children.Find(uname, "user");
                DirectoryEntry grp = AD.Children.Find(role.ToString(), "group");
                if (grp != null)
                {
                    if (grp.Properties["member"].Contains(myEntry))
                    {
                        Tracer.WriteInfo("user exists in group :" + role.ToString());
                        userExistsInGrp = true;
                    }
                }
            }
            // This exception is thrown when group does not exist
            catch (System.Runtime.InteropServices.COMException)
            {
                // Return false if group cannot be found
                userExistsInGrp = false;
            }

            return userExistsInGrp;
        }
        public bool GetAllBladesInfo(bool testPassed, WCSSecurityRole roleId)
        {
            try
            {
                this.TestChannelContext = this.ListTestChannelContexts[(int)roleId];
                if (this.TestChannelContext != null)
                {
                    // get all blades info
                    GetAllBladesInfoResponse allBladesInfoResponse = null;
                    CmTestLog.Info("Trying to get all blades information");
                    allBladesInfoResponse = this.TestChannelContext.GetAllBladesInfo();
                    if (allBladesInfoResponse != null && allBladesInfoResponse.completionCode == CompletionCode.Success)
                    {
                        testPassed &= ChassisManagerTestHelper.IsTrue(allBladesInfoResponse != null, "Received GetAllBladesInfo response");
                        testPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.Success, allBladesInfoResponse.completionCode, "GetAllBladesInfo returns success as the completion code");
                    }
                    else
                    {
                        testPassed = false;
                        return testPassed;
                    }
                    testPassed &= ChassisManagerTestHelper.AreEqual(CmConstants.Population, allBladesInfoResponse.bladeInfoResponseCollection.Count,
                        string.Format("The response contains information for all {0} slots", CmConstants.Population));

                    // WorkItem(2839)
                    CmTestLog.Info("Verifying each blade info response");
                    foreach (var bladeInfo in allBladesInfoResponse.bladeInfoResponseCollection)
                    {
                        if (this.EmptyLocations != null && this.EmptyLocations.Contains(bladeInfo.bladeNumber))
                        {
                            testPassed = this.VerifyEmptybladeInfo(testPassed, bladeInfo);
                        }
                        // If the slot is JBOD: WorkItem(2748)
                        else if (this.JbodLocations != null && this.JbodLocations.Contains(bladeInfo.bladeNumber))
                        {
                            testPassed = this.VerifyJbodBladeInfo(testPassed, bladeInfo);
                        }
                        else
                        {
                            testPassed = this.VerifyServerBladeInfo(testPassed, bladeInfo);
                        }
                    }

                    if (!testPassed)
                    {
                        CmTestLog.End(false);
                        return false; // if failed here, no need to continue
                    }

                    int[] nonEmptyBlades;
                    int powerOffBladeId;
                    this.PowerOffRandomBlade(allBladesInfoResponse, out nonEmptyBlades, out powerOffBladeId);

                    // verify the blade powered off returns a failure
                    CmTestLog.Info("Trying to get all blades information");
                    allBladesInfoResponse = this.TestChannelContext.GetAllBladesInfo();
                    testPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.DevicePoweredOff, allBladesInfoResponse.bladeInfoResponseCollection
                                                                                                                          .Single(blade => blade.bladeNumber == powerOffBladeId)
                                                                                                                          .completionCode, "Power-off blade returns DevicePoweredOff");

                    // blade off a random blade
                    int bladeOffBladeId;
                    this.BladeOffRandomBlade(nonEmptyBlades, out bladeOffBladeId);

                    // verify the blade with state off still returns success
                    CmTestLog.Info("Trying to get all blades information");
                    allBladesInfoResponse = this.TestChannelContext.GetAllBladesInfo();
                    testPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.Success, allBladesInfoResponse.bladeInfoResponseCollection
                                                                                                                 .Single(blade => blade.bladeNumber == bladeOffBladeId)
                                                                                                                 .completionCode, "Blade-off blade returns Success");
                }
            }
            catch (Exception ex)
            {
                ChassisManagerTestHelper.IsTrue(false, ex.Message);
                testPassed = false;
            }

            CmTestLog.End(testPassed);
            return testPassed;
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Find group with given name, if not exists create
        /// </summary>
        /// <param name="role">Group name</param>
        /// <returns>Group DirectorEntry</returns>
        internal static DirectoryEntry FindGroupIfNotExistsCreate(WCSSecurityRole role)
        {
            try
            {
                DirectoryEntry AD = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
                DirectoryEntry grp = AD.Children.Find(role.ToString(), "group");
                if (grp == null)
                {
                    ChassisManagerUtil.CreateNewGroup(role);
                }

                return grp;
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                Tracer.WriteInfo(" Group: {0} not found , creating new", role.ToString());
                return (ChassisManagerUtil.CreateNewGroup(role));
            }
        }
 private bool VerifySetBladePower(ref bool testPassed, WCSSecurityRole roleId, BladeResponse bladeRes)
 {
     if (bladeRes.completionCode != CompletionCode.Success && (roleId == WCSSecurityRole.WcsCmAdmin))
     {
         CmTestLog.Failure(string.Format("Cannot Set blade Power using WcsAdmin User {0}", roleId));
         CmTestLog.End(false);
         return false;
     }
     else if (bladeRes.completionCode == CompletionCode.Success && (roleId == WCSSecurityRole.WcsCmUser || roleId == WCSSecurityRole.WcsCmOperator))
     {
         CmTestLog.Failure(string.Format("User/Operator is able to set blade power {0}", roleId));
         CmTestLog.End(false);
         return false;
     }
     else
     {
         testPassed &= ChassisManagerTestHelper.AreEqual(bladeRes.completionCode, CompletionCode.Success, string.Format("Received success with user {0}", Enum.GetName(typeof(WCSSecurityRole), roleId)));
     }
     return testPassed;
 }
Ejemplo n.º 25
0
        /// <summary>
        /// Remove user from given group. This is required
        /// when user role is changes
        /// </summary>
        /// <returns></returns>
        internal static void RemoveUserFromWCSSecurityGroups(string uname, WCSSecurityRole role)
        {
            Tracer.WriteInfo("RemoveUserFromWCSSecurityGroups: user: {0}, role: {1}", uname, role.ToString());
            DirectoryEntry AD = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
            DirectoryEntry myEntry = AD.Children.Find(uname, "user");
            try
            {
                if (myEntry != null)
                {
                    DirectoryEntry grp = AD.Children.Find(role.ToString(), "group");
                    if (grp != null)
                    {
                        grp.Invoke("Remove", new object[] { myEntry.Path.ToString() });
                        grp.CommitChanges();
                        grp.Close();

                        Tracer.WriteInfo("RemoveUserFromWCSSecurityGroups: Removed uname: {0} from role: {1}", uname, role.ToString());
                    }
                }
            }
            catch (DirectoryServicesCOMException)
            {
                // Do nothing if group cannot be found/ if user is not a member of given group.
                // If group does not exists we don't need to remove user from it.
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                // Do nothing if group cannot be found/ if user is not a member of given group.
                // If group does not exists we don't need to remove user from it.
            }
            catch (Exception)
            {
                // Do nothing if group cannot be found/ if user is not a member of given group.
                // If group does not exists we don't need to remove user from it.
            }
        }
        public bool GetBladeInfo(bool testPassed, WCSSecurityRole roleId)
        {
            try
            {
                this.TestChannelContext = this.ListTestChannelContexts[(int)roleId];
                if (this.TestChannelContext != null)
                {
                    // TFS WorkItem(1895)
                    BladeInfoResponse bladeInfo = null;
                    // get blade information for each blade
                    for (int bladeId = 1; bladeId <= CmConstants.Population; bladeId++)
                    {
                        // TFS WorkItem(1897)
                        if (this.EmptyLocations != null && this.EmptyLocations.Contains(bladeId))
                        {
                            bladeInfo = this.TestChannelContext.GetBladeInfo(bladeId);
                            testPassed = this.VerifyEmptybladeInfo(testPassed, bladeInfo);
                        }
                        // TFS WorkItem(2747)
                        else if (this.JbodLocations != null && this.JbodLocations.Contains(bladeId))
                        {
                            bladeInfo = this.TestChannelContext.GetBladeInfo(bladeId);
                            testPassed = this.VerifyJbodBladeInfo(testPassed, bladeInfo);
                        }
                        else
                        {
                            bladeInfo = this.TestChannelContext.GetBladeInfo(bladeId);
                            testPassed = this.VerifyServerBladeInfo(testPassed, bladeInfo);
                        }
                        if (!testPassed)
                        {
                            CmTestLog.End(false);
                            return false; // if failed here, no need to continue
                        }
                    }

                    // verify the blade for out of range bladeId
                    CmTestLog.Info("Trying to get information for invalid blade");
                    bladeInfo = this.TestChannelContext.GetBladeInfo(CmConstants.InvalidBladeId);
                    testPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.ParameterOutOfRange, bladeInfo.completionCode, "Inavlid blade returns ParameterOutOfRange");

                    if (!testPassed)
                    {
                        CmTestLog.End(false);
                        return false; // if failed here, no need to continue
                    }

                    // TFS WorkItem(2854)
                    // Power-off a random blade
                    int powerOffBladeId = this.ServerLocations.RandomOrDefault();
                    CmTestLog.Info(string.Format("Trying to power off Blade# {0}", powerOffBladeId));

                    if (!this.SetPowerState(PowerState.OFF, powerOffBladeId))
                    {
                        return false;
                    }

                    // verify the blade powered off returns a DevicePoweredOFF
                    CmTestLog.Info("Trying to get blade information for powered off blade");
                    bladeInfo = this.TestChannelContext.GetBladeInfo(powerOffBladeId);
                    testPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.DevicePoweredOff, bladeInfo.completionCode, "Power-off blade returns DevicePoweredOff");

                    // blade off a random blade
                    int bladeOffBladeId;
                    this.BladeOffRandomBlade(ServerLocations, out bladeOffBladeId);

                    // verify the blade with state off still returns success
                    CmTestLog.Info("Trying to get blade information");
                    bladeInfo = this.TestChannelContext.GetBladeInfo(bladeOffBladeId);
                    testPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.Success, bladeInfo.completionCode, "Blade-off blade returns Success");
                }
            }
            catch (Exception ex)
            {
                ChassisManagerTestHelper.IsTrue(false, ex.Message);
                testPassed = false;
            }

            CmTestLog.End(testPassed);
            return testPassed;
        }
Ejemplo n.º 27
0
        private bool GetSetNextBoots(bool testPassed, int bladeIndex, string failureMessage, int index,
            WCSSecurityRole roleId)
        {
            // Use different user context
            TestChannelContext = ListTestChannelContexts[(int) roleId];

            foreach (BladeBootType testedBootType in Enum.GetValues(typeof (BladeBootType)))
            {
                //Doing the same setting twice to make sure we are handling this properly.
                if (testedBootType.ToString() != BladeBootType.Unknown.ToString())
                {
                    //set to persistent.
                    BootResponse bBootType = TestChannelContext.SetNextBoot(bladeIndex, testedBootType, false, false, 0);
                    if (bBootType.completionCode != CompletionCode.Success)
                    {
                        failureMessage = string.Format("!!!Failed to set non persistant boot type to: {0}",
                            testedBootType);
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }

                    bBootType = TestChannelContext.GetNextBoot(bladeIndex);
                    if (testedBootType.ToString() != bBootType.nextBoot.ToString())
                    {
                        failureMessage = "!!!The Non persistent boot type did not match what it was set to.";
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }

                    //set to non persistent.
                    bBootType = TestChannelContext.SetNextBoot(bladeIndex, testedBootType, false, true, 1);
                    if (bBootType.completionCode != CompletionCode.Success)
                    {
                        failureMessage = string.Format("!!!Failed to set Persistent boot type to: {0}", testedBootType);
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }

                    //Make sure if no restart happens it keeps its value.
                    bBootType = TestChannelContext.GetNextBoot(bladeIndex);
                    if (testedBootType.ToString() != bBootType.nextBoot.ToString())
                    {
                        failureMessage = "!!!The boot type did not match what it was set to.";
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }
                    //Make sure it loses its value after restart
                    Channel.SetBladeActivePowerCycle(bladeIndex, 0);
                    Thread.Sleep(60000);
                    bBootType = Channel.GetNextBoot(bladeIndex);
                    if (testedBootType.ToString() != BladeBootType.ForcePxe.ToString() &&
                        testedBootType.ToString() != bBootType.nextBoot.ToString())
                    {
                        failureMessage =
                            string.Format(
                                "!!!The boot type did not match what it was set to before power cycle. {0} vs {1} this is round# {2}",
                                testedBootType, bBootType.nextBoot, index);
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }
                }
            }

            //reset for next test
            Channel.SetNextBoot(bladeIndex, BladeBootType.NoOverride, false, true, 0);

            return testPassed;
        }
        /// <summary>
        ///     SetACSocketPowerStateOff: Verify that only Operator and Admin can execute the command
        /// </summary>
        /// <param name="testPassed"></param>
        /// <param name="failureMessage"></param>
        /// <param name="numAcSocket"></param>
        /// <param name="roleId"></param>
        private void AcSocketSetGetValidation(ref bool testPassed, ref string failureMessage, uint numAcSocket,
            WCSSecurityRole roleId)
        {
            ChassisResponse acSocketResponse = null;
            ACSocketStateResponse acSocketPower = null;

            // Use different user context
            this.TestChannelContext = this.ListTestChannelContexts[(int)roleId];

            for (uint testedAcSocket = 1; testedAcSocket <= numAcSocket; testedAcSocket++)
            {
                // Turn On ACSocket
                acSocketResponse = this.TestChannelContext.SetACSocketPowerStateOn(testedAcSocket);
                if (acSocketResponse.completionCode != CompletionCode.Success &&
                    (roleId == WCSSecurityRole.WcsCmAdmin || roleId == WCSSecurityRole.WcsCmOperator))
                {
                    failureMessage =
                        string.Format("!!!Failed to power ON AC socket when it is already ON for AC Socket# {0}",
                            testedAcSocket);
                    CmTestLog.Failure(failureMessage);
                    testPassed = false;
                }
                else if (acSocketResponse.completionCode == CompletionCode.Success &&
                         (roleId == WCSSecurityRole.WcsCmUser))
                {
                    failureMessage =
                        string.Format("User is not allow to called out to SetACSocketPowerStateOn {0} Socket# {1}",
                            roleId, testedAcSocket);
                    CmTestLog.Failure(failureMessage);
                    testPassed = false;
                }
                else
                {
                    // Verify power state
                    acSocketPower = this.Channel.GetACSocketPowerState(testedAcSocket);
                    if (acSocketPower.powerState != PowerState.ON)
                    {
                        failureMessage =
                            string.Format(
                                "!!!Failed to power ON AC socket when it is already ON for AC Socket# {0}",
                                testedAcSocket);
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }
                }

                // Turn  off ACSocket
                acSocketResponse = this.TestChannelContext.SetACSocketPowerStateOff(testedAcSocket);
                if (acSocketResponse.completionCode != CompletionCode.Success &&
                    (roleId == WCSSecurityRole.WcsCmAdmin || roleId == WCSSecurityRole.WcsCmOperator))
                {
                    failureMessage =
                        string.Format("!!!Failed to power ON AC socket when it is already ON for AC Socket# {0}",
                            testedAcSocket);
                    CmTestLog.Failure(failureMessage);
                    testPassed = false;
                }
                else if (acSocketResponse.completionCode == CompletionCode.Success && roleId == WCSSecurityRole.WcsCmUser)
                {
                    failureMessage =
                        string.Format(
                            "User is not allow to called out to SetACSocketPowerStateOff {0} Socket# {1}", roleId,
                            testedAcSocket);
                    CmTestLog.Failure(failureMessage);
                    testPassed = false;
                }
                else
                {
                    // Verify power state
                    acSocketPower = this.Channel.GetACSocketPowerState(testedAcSocket);
                    if (acSocketPower.powerState != PowerState.OFF)
                    {
                        failureMessage =
                            string.Format(
                                "!!!Failed to power ON AC socket when it is already ON for AC Socket# {0}",
                                testedAcSocket);
                        CmTestLog.Failure(failureMessage);
                        testPassed = false;
                    }
                }
            }// end of for loop
        }
        private void VerifyReadChassisLog(ref bool chassisPassed, WCSSecurityRole user)
        {
            string currentApi         = "ReadChassisLog";
            string logParentDirectory = @"\\" + defaultCMName + @"\c$\";

            string[] userLogPaths = new string[] { null, null };

            ChassisLogResponse chassisLog = new ChassisLogResponse();

            CmTestLog.Info("TestChannelContext user " + (int)user);
            this.TestChannelContext = this.ListTestChannelContexts[(int)user];

            chassisLog = this.TestChannelContext.ReadChassisLog();

            chassisPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.Success, chassisLog.completionCode,
                                                               currentApi + ": Completion Code success for user " + user.ToString());

            if (StartStopCmService("stop"))
            {
                CmTestLog.Success(currentApi + ": Stopped Chassis Manager Service");
            }
            else
            {
                CmTestLog.Failure(currentApi +
                                  ": Unable to stop Chassis Manager Service. Will not check log entry contents");
                chassisPassed = false;
                return;
            }

            // Check Log entries are populated in ChassisLogResponse and not greater than 50 entries
            if (chassisLog.logEntries.Count < 1)
            {
                CmTestLog.Failure(currentApi + ": Command does not return Log Entries");
                chassisPassed = false;
                ChassisManagerTestHelper.IsTrue(StartStopCmService("start"),
                                                currentApi + ": Stopped Chassis Manager Service");
                return;
            }
            else if (chassisLog.logEntries.Count > 50)
            {
                CmTestLog.Failure(currentApi + ": Command returns more than 50 Log Entries");
                chassisPassed = false;
                ChassisManagerTestHelper.IsTrue(StartStopCmService("start"),
                                                currentApi + ": Stopped Chassis Manager Service");
                return;
            }
            else
            {
                CmTestLog.Success(currentApi + ": Command returns between 1 and 50 Log Entries");
            }

            IntPtr token = IntPtr.Zero;

            // Impersonate remote user
            bool successLogon = LogonUser(defaultAdminUserName, defaultCMName, defaultAdminPassword,
                                          (int)DwLogonType.NewCredentials, (int)DwLogonProvider.WinNT50, ref token);

            if (successLogon)
            {
                using (WindowsImpersonationContext context = WindowsIdentity.Impersonate(token))
                {
                    // Verify that User Logs exist to compare log entries with ChassisLogResponse
                    if (!Directory.Exists(logParentDirectory))
                    {
                        CmTestLog.Failure(currentApi + ": Directory to User Log files does not exist");
                        chassisPassed = false;
                        ChassisManagerTestHelper.IsTrue(StartStopCmService("start"),
                                                        currentApi + ": Stopped Chassis Manager Service");
                        return;
                    }

                    foreach (string filePath in Directory.GetFiles(logParentDirectory))
                    {
                        Match fileMatch00 = Regex.Match(filePath, @"ChassisManagerUserLog00\.svclog");
                        Match fileMatch01 = Regex.Match(filePath, @"ChassisManagerUserLog01\.svclog");

                        if (fileMatch00.Success)
                        {
                            userLogPaths[0] = filePath;
                        }
                        else if (fileMatch01.Success)
                        {
                            userLogPaths[1] = filePath;
                        }
                    }

                    if (userLogPaths[0] == null && userLogPaths[1] == null)
                    {
                        CmTestLog.Failure(currentApi + ": Could not find user logs");
                        chassisPassed = false;
                        ChassisManagerTestHelper.IsTrue(StartStopCmService("start"),
                                                        currentApi + ": Started Chassis Manager Service");
                        return;
                    }

                    // Compare and match log entries in ChassisLogResponse to User Logs in Chassis Manager
                    int  entryCount       = 0;
                    bool allEntriesPassed = true;
                    foreach (LogEntry entry in chassisLog.logEntries)
                    {
                        if (entry.eventDescription == null && entry.eventTime == null)
                        {
                            CmTestLog.Failure(currentApi +
                                              string.Format(": Log Entry {0} returns no data for either eventDescription or eventTime or both", entryCount));
                            allEntriesPassed = false;
                            entryCount++;
                            continue;
                        }

                        // Find log entry in either UserLog00 or UserLog01
                        int    userLogCount      = 0;
                        bool   userLogEntryFound = false;
                        string propertyValue;
                        foreach (string userLogPath in userLogPaths)
                        {
                            if (userLogPath == null)
                            {
                                CmTestLog.Info(currentApi + string.Format(": User Log {0} does not exist", userLogCount));
                                userLogCount++;
                                continue;
                            }

                            XmlReaderSettings xmlSettings = new XmlReaderSettings();
                            xmlSettings.ConformanceLevel = ConformanceLevel.Fragment;

                            XmlReader userLogReader = XmlReader.Create(userLogPath, xmlSettings);

                            try
                            {
                                while (!userLogEntryFound)
                                {
                                    while (userLogReader.Read())
                                    {
                                        if (userLogReader.Name == "ApplicationData")
                                        {
                                            break;
                                        }
                                    }

                                    if (userLogReader.Name != "ApplicationData")
                                    {
                                        userLogReader.Close();
                                        break;
                                    }

                                    // Read User Log Entry and condition both strings for comparison
                                    propertyValue          = userLogReader.ReadElementContentAsString();
                                    propertyValue          = propertyValue.Replace(@"\", "");
                                    propertyValue          = propertyValue.Replace(@"(", "");
                                    propertyValue          = propertyValue.Replace(@")", "");
                                    entry.eventDescription = entry.eventDescription.Replace(@"\", "");
                                    entry.eventDescription = entry.eventDescription.Replace(@"(", "");
                                    entry.eventDescription = entry.eventDescription.Replace(@")", "");

                                    Match eventTimeMatch = Regex.Match(propertyValue,
                                                                       entry.eventTime.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                                    Match eventDescriptionMatch = Regex.Match(propertyValue, entry.eventDescription);

                                    if (eventTimeMatch.Success && eventDescriptionMatch.Success)
                                    {
                                        CmTestLog.Success(currentApi +
                                                          string.Format(": Found eventTime match and eventDescription match for entry {0} in user log {1}", entryCount, userLogCount));
                                        userLogEntryFound = true;
                                    }
                                }
                            }
                            catch (Exception exc)
                            {
                                if (exc.Message.Contains(@"Not enough )'s"))
                                {
                                    CmTestLog.Info(currentApi + string.Format(": Entry {0} throwing exception 'Not enough )'s' in User Log {1}", entryCount, userLogCount));
                                    userLogCount++;
                                    continue;
                                }
                                else
                                {
                                    throw new Exception(exc.Message);
                                }
                            }

                            if (!userLogEntryFound)
                            {
                                CmTestLog.Info(currentApi + string.Format(": User Log {0} does not contain entry {1}", userLogCount, entryCount));
                                userLogReader.Close();
                                userLogCount++;
                                continue;
                            }

                            userLogReader.Close();
                            userLogCount++;
                        }

                        if (!userLogEntryFound)
                        {
                            CmTestLog.Failure(currentApi + string.Format(": Entry {0} was not found in either user logs", entryCount));
                            allEntriesPassed = false;
                            entryCount++;
                            continue;
                        }

                        chassisPassed &= allEntriesPassed;
                        entryCount++;
                    }
                    ChassisManagerTestHelper.IsTrue(allEntriesPassed,
                                                    currentApi + string.Format(": All Log Entries passed", entryCount));

                    // Revert back to original user
                    context.Undo();
                }
            }
            else
            {
                CmTestLog.Failure("UserLogon: User failed to be created");
                chassisPassed = false;
            }

            ChassisManagerTestHelper.IsTrue(StartStopCmService("start"),
                                            currentApi + ": Started Chassis Manager Service");
        }