Example #1
0
        private void CheckOkEnable()
        {
            bool isEnable = !txtConfig.Visible;

            if (txtName.Text.Length == 0 || cboNotifier.SelectedIndex < 0 || SelectedEntry.Configuration == null || SelectedEntry.Configuration.Length == 0)
            {
                isEnable = false;
            }

            cmdOK.Enabled = isEnable;
            configureEditButtonNotifier.Enabled = cboNotifier.SelectedIndex > -1 && !txtConfig.Visible;
            lblAgentDescription.Text            = "";
            if (cboNotifier.SelectedIndex > -1)
            {
                try
                {
                    AgentRegistration          ar = (AgentRegistration)cboNotifier.SelectedItem;
                    System.Reflection.Assembly a  = System.Reflection.Assembly.LoadFrom(ar.AssemblyPath);
                    System.Reflection.AssemblyDescriptionAttribute ad = (System.Reflection.AssemblyDescriptionAttribute)System.Reflection.AssemblyDescriptionAttribute.GetCustomAttribute(
                        a, typeof(System.Reflection.AssemblyDescriptionAttribute));
                    lblAgentDescription.Text = "Description: " + ad.Description;
                }
                catch { }
            }
        }
Example #2
0
 //Register New Agents
 public bool RegisterNewAgent(RegistrationModel model)
 {
     try
     {
         if (model != null)
         {
             AgentRegistration reg = new AgentRegistration();
             reg.AgetName          = model.AgentName;
             reg.Mobile            = model.Mobile;
             reg.Email             = model.Email;
             reg.Aadhar            = model.Aaadhar;
             reg.PAN               = model.PAN;
             reg.AgentId           = CommonMethods.GenerateuniqueAgentId();
             reg.Password          = model.Password;
             reg.AccountHolderName = model.AccountHolderName;
             reg.BankAccountNumber = model.BankAccountNumber;
             reg.IFSCCode          = model.IFSCCode;
             reg.CreatedDate       = DateTime.Now.ToString("dd-MM-yyyy");
             reg.IsActive          = true;
             reg.Status            = false;
             _context.AgentRegistration.Add(reg);
             _context.SaveChanges();
             return(true);
         }
         return(false);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void OnAgentRegistrationUpdated(AgentConnection clientConnection, AgentRegistration registration)
 {
     if (AgentRegistrationUpdated != null)
     {
         AgentRegistrationUpdated.Invoke(clientConnection, registration);
     }
 }
Example #4
0
    public async Async.Task Post_SetsCorrectVersion()
    {
        await Context.InsertAll(
            new Pool(_poolName, _poolId, Os.Linux, false, Architecture.x86_64, PoolState.Init, null));

        var auth = new TestEndpointAuthorization(RequestType.Agent, Logger, Context);
        var func = new AgentRegistration(Logger, auth, Context);

        var req = TestHttpRequestData.Empty("POST");

        req.SetUrlParameter("machine_id", _machineId);
        req.SetUrlParameter("pool_name", _poolName);
        req.SetUrlParameter("scaleset_id", _scalesetId);
        req.SetUrlParameter("version", "1.2.3");

        var result = await func.Run(req);

        Assert.Equal(HttpStatusCode.OK, result.StatusCode);

        // should be one node with provided version
        var nodes = await Context.NodeOperations.SearchAll().ToListAsync();

        var node = Assert.Single(nodes);

        Assert.Equal("1.2.3", node.Version);
    }
Example #5
0
    public async Async.Task Post_ChecksRequiredParameters(string parameterToSkip)
    {
        await Context.InsertAll(
            new Pool(_poolName, _poolId, Os.Linux, false, Architecture.x86_64, PoolState.Init, null));

        var auth = new TestEndpointAuthorization(RequestType.Agent, Logger, Context);
        var func = new AgentRegistration(Logger, auth, Context);

        var req = TestHttpRequestData.Empty("POST");

        if (parameterToSkip != "machine_id")
        {
            req.SetUrlParameter("machine_id", _machineId);
        }

        if (parameterToSkip != "pool_name")
        {
            req.SetUrlParameter("pool_name", _poolName);
        }

        var result = await func.Run(req);

        Assert.Equal(HttpStatusCode.BadRequest, result.StatusCode);

        var err = BodyAs <Error>(result);

        Assert.Equal(ErrorCode.INVALID_REQUEST, err.Code);
        Assert.Equal($"'{parameterToSkip}' query parameter must be provided", err.Errors?.Single());
    }
Example #6
0
    public async Async.Task Post_DeletesExistingNodeForMachineId()
    {
        await Context.InsertAll(
            new Node(PoolName.Parse("another-pool"), _machineId, _poolId, "1.0.0"),
            new Pool(_poolName, _poolId, Os.Linux, false, Architecture.x86_64, PoolState.Init, null));

        var auth = new TestEndpointAuthorization(RequestType.Agent, Logger, Context);
        var func = new AgentRegistration(Logger, auth, Context);

        var req = TestHttpRequestData.Empty("POST");

        req.SetUrlParameter("machine_id", _machineId);
        req.SetUrlParameter("pool_name", _poolName);
        req.SetUrlParameter("scaleset_id", _scalesetId);

        var result = await func.Run(req);

        Assert.Equal(HttpStatusCode.OK, result.StatusCode);

        // there should only be one node, the old one with the same machineID was deleted
        var nodes = await Context.NodeOperations.SearchAll().ToListAsync();

        var node = Assert.Single(nodes);

        Assert.Equal(_poolName, node.PoolName);
    }
        public bool EditAgentRoleOption(AgentRegistration agent1, out string output)
        {
            string outMsg = "";

            try
            {
                if (!VerifyAgentExists_BaseOnUserName(agent1.UserName))
                {
                    agent1.Status = AgentRegistration.AgentStatus.Active.ToString();
                    outMsg        = CreateAgent(agent1.FistName, agent1.LastName, agent1.Role, agent1.UserName, agent1.Password, agent1.Status);
                }

                Driver.FindElement(By.XPath("//span[text()='" + agent1.UserName + "']//parent::td//parent::tr//a[text()='Edit']")).ClickElement();
                SelectElement_AndSelectByText(Select_Role, agent1.Role);
                Click_OnButton(Button_Save);
                if (Driver.IsElementPresent(Label_Success, 1))
                {
                    output = outMsg + "Agent: " + agent1.UserName + " ; Role Option: " + agent1.Role.ToString() + " changed successfully";
                    return(true);
                }
                else
                {
                    throw new Exception("Failed To change the agent Role refer screenshot for more info");
                }
            }
            catch (Exception)
            {
                throw new Exception("Failed To change the agent Role refer screenshot for more info");
            }
        }
Example #8
0
 private void cmdConfig_Click(object sender, EventArgs e)
 {
     if (cboNotifier.SelectedItem != null)
     {
         try
         {
             AgentRegistration ar       = (AgentRegistration)cboNotifier.SelectedItem;
             INotifier         notifier = NotifierEntry.CreateNotifierEntry(ar.AssemblyPath, ar.ClassName);
             if (notifier != null)
             {
                 SelectedEntry.Notifier = notifier;
                 if (SelectedEntry.Configuration == null)
                 {
                     SelectedEntry.Configuration = "";
                 }
                 string newConfig = notifier.ConfigureAgent(SelectedEntry.Configuration);
                 if (newConfig.Length > 0)
                 {
                     SelectedEntry.Configuration = newConfig;
                     CheckOkEnable();
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Example #9
0
        private void CheckOkEnable()
        {
            bool isEnable = !manualEditPanel.Visible;

            if (txtName.Text.Length == 0 || cboParentCollector.SelectedIndex < 0 ||
                (!chkFolder.Checked && (cboCollector.SelectedIndex < 0 || SelectedEntry.Configuration == null || SelectedEntry.Configuration.Length == 0)))
            {
                isEnable = false;
            }

            cmdOK.Enabled = isEnable;

            configureEditButtonCollector.Enabled = cboCollector.SelectedIndex > -1 && !txtConfig.Visible && !chkFolder.Checked;
            cboCollector.Enabled = !chkFolder.Checked && allowCollectorChange;
            chkCollectOnParentWarning.Enabled      = !chkFolder.Checked;
            numericUpDownRepeatAlertInXMin.Enabled = !chkFolder.Checked;
            AlertOnceInXMinNumericUpDown.Enabled   = !chkFolder.Checked;
            delayAlertSecNumericUpDown.Enabled     = !chkFolder.Checked;

            lblAgentDescription.Text = "";
            if (cboCollector.SelectedIndex > -1)
            {
                try
                {
                    AgentRegistration          ar = (AgentRegistration)cboCollector.SelectedItem;
                    System.Reflection.Assembly a  = System.Reflection.Assembly.LoadFrom(ar.AssemblyPath);
                    System.Reflection.AssemblyDescriptionAttribute ad = (System.Reflection.AssemblyDescriptionAttribute)System.Reflection.AssemblyDescriptionAttribute.GetCustomAttribute(
                        a, typeof(System.Reflection.AssemblyDescriptionAttribute));
                    lblAgentDescription.Text = "Description: " + ad.Description;
                }
                catch { }
            }
        }
Example #10
0
    public async Async.Task UserAuthorization_IsNotPermitted()
    {
        var auth = new TestEndpointAuthorization(RequestType.User, Logger, Context);
        var func = new AgentRegistration(Logger, auth, Context);

        var result = await func.Run(TestHttpRequestData.Empty("POST"));

        Assert.Equal(HttpStatusCode.Unauthorized, result.StatusCode);
    }
Example #11
0
    public async Async.Task AgentAuthorization_IsAccepted()
    {
        var auth = new TestEndpointAuthorization(RequestType.Agent, Logger, Context);
        var func = new AgentRegistration(Logger, auth, Context);

        var result = await func.Run(TestHttpRequestData.Empty("POST"));

        Assert.Equal(HttpStatusCode.BadRequest, result.StatusCode); // BadRequest due to missing parameters, not Unauthorized
    }
        public AgentRegistration CheckAdminExitsSendPassword(string id)
        {
            AgentRegistration details = _context.AgentRegistration.Where(x => x.Email == id).FirstOrDefault();

            if (details != null)
            {
                return(details);
            }
            return(null);
        }
Example #13
0
 //
 public bool   UpdateProjectUnitStatus(AgentRegistration agentDetails, ProjectDetails project, string projectId, string unitId)
 {
     try
     {
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(false);
 }
Example #14
0
        public bool  DeleteAgentFromDb(string agentId)
        {
            AgentRegistration agent = _context.AgentRegistration.Where(x => x.AgentId == agentId).FirstOrDefault();

            if (agent != null)
            {
                agent.Status = true;
                _context.SaveChanges();
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// Create Agent with different role
        /// </summary>
        /// <param name="FirstName">First Name of the Agent</param>
        /// <param name="LastName">Last Name of the Agent</param>
        /// <param name="Role">Role of the Agent</param>
        /// <param name="AgentUserName">User Name of the Agent</param>
        /// <param name="Password">Password of the Agent</param>
        /// <param name="Status">Status of the Agent</param>
        /// <returns>
        /// returns string is agent create or not
        /// </returns>
        public string CreateAgentWithIsPasswordRequiredOption(AgentRegistration agentRegistration)
        {
            string Message = "";

            try
            {
                if (!VerifyAgentExists(agentRegistration.FistName, agentRegistration.LastName, agentRegistration.Role, agentRegistration.UserName, agentRegistration.Status))
                {
                    var intialcount = GetInitialWordCountFromLogFile();
                    Click_OnButton(Link_CreateNewAgent);
                    Driver.GetElement(TextBox_FirstName).SendText(agentRegistration.FistName);
                    Driver.GetElement(TextBox_LastName).SendText(agentRegistration.LastName);
                    SelectElement_AndSelectByText(Select_Role, agentRegistration.Role);
                    Driver.GetElement(TextBox_UserName).SendText(agentRegistration.UserName);
                    Driver.GetElement(TextBox_Password).SendText(agentRegistration.Password);
                    SelectElement_AndSelectByText(Select_Status, agentRegistration.Status);
                    CheckBoxElmandCheck(CheckBox_PasswordChangeRequired, agentRegistration.PasswordChangeRequired);
                    Click_OnButton(Button_Save);
                    if (Driver.IsElementPresent(Label_Success, 2))
                    {
                        VerifyAgentExists(agentRegistration.FistName, agentRegistration.LastName, agentRegistration.Role, agentRegistration.UserName, agentRegistration.Status);
                        if (VerifyAdminCreatedFromLog(intialcount, out string output))
                        {
                            Message = "Agent Created Successfully and Please Details Below:" +
                                      ";AgentName:" + agentRegistration.UserName +
                                      ";Password:"******";FirstName:" + agentRegistration.FistName +
                                      ";LastName:" + agentRegistration.LastName +
                                      ";Role:" + agentRegistration.Role +
                                      ";Password Change Reqiured:" + agentRegistration.PasswordChangeRequired.ToString() +
                                      ";Status:" + agentRegistration.Status;
                            return(Message);
                        }
                    }
                    else
                    {
                        throw new Exception("Failed to Verify Existing Agent " + agentRegistration.UserName);
                    }
                }
                else
                {
                    Message = "Agent Available Already and Please Details Below:" +
                              ";AgentName:" + agentRegistration.UserName +
                              ";FirstName:" + agentRegistration.FistName +
                              ";LastName:" + agentRegistration.LastName +
                              ";Role:" + agentRegistration.Role +
                              ";Status:" + agentRegistration.Status;
                    return(Message);
                }
                return(Message);
            }
            catch (Exception e) { throw new Exception("Failed to Create Agent" + agentRegistration.UserName + " Due to " + e); }
        }
Example #16
0
 public override void OpenEnvelope()
 {
     try
     {
         AgentRegistration       = Message.GetPayload <AgentRegistration>();
         Agent.AgentRegistration = AgentRegistration;
     }
     catch (Exception ex)
     {
         logger.Error(ex, $"Cannot open envelop for the AgentRegistration");
         return;
     }
 }
Example #17
0
    public async Async.Task Get_UrlParameterRequired()
    {
        var auth = new TestEndpointAuthorization(RequestType.Agent, Logger, Context);
        var func = new AgentRegistration(Logger, auth, Context);

        var req    = TestHttpRequestData.Empty("GET");
        var result = await func.Run(req);

        Assert.Equal(HttpStatusCode.BadRequest, result.StatusCode);
        var body = BodyAs <Error>(result);

        Assert.Equal(ErrorCode.INVALID_REQUEST, body.Code);
        Assert.Equal("'machine_id' query parameter must be provided", body.Errors?.Single());
    }
        protected void timerRefresh_Tick(object sender, EventArgs e)
        {
            if (!page.IsAuthorized)
            {
                Response.Redirect("../default.aspx");
            }
            //----------------------------------------



            if (ucSideMenu.UpdateMenu())
            {
                upMenu.Update();
            }



            //------------------------------------------------------ 0 - Show Time
            //lblTimer.Text = DateTime.Now.ToLongTimeString();


            //------------------------------------------------------ 1 - Update Agent Status
            if (AgentRegistration.UpdateAgentStatus())
            {
                upAgentRegistration.Update();
                //if (AgentRegistration.IsOnline)
                //{
                //    pnlVideoTransmitter.Visible = true;
                //}
                //else
                //{
                //    pnlVideoTransmitter.Visible = false;
                //}
                //upVideoChat.Update();
            }

            //------------------------------------------------------ 2 - Update Agent Status
            if (page.UpdateContent())
            {
                upBusinessControlPanel.Update();
            }



            //----------------------------------------
            Context.Items.Add("IsAutoPostBack", true);
        }
Example #19
0
    public async Async.Task Get_MissingNode()
    {
        var auth = new TestEndpointAuthorization(RequestType.Agent, Logger, Context);
        var func = new AgentRegistration(Logger, auth, Context);

        var req = TestHttpRequestData.Empty("GET");

        req.SetUrlParameter("machine_id", _machineId);

        var result = await func.Run(req);

        Assert.Equal(HttpStatusCode.BadRequest, result.StatusCode);
        var body = BodyAs <Error>(result);

        Assert.Equal(ErrorCode.INVALID_REQUEST, body.Code);
        Assert.Contains("unable to find a registration", body.Errors?.Single());
    }
 public JsonResult ForgotPassword(string id)
 {
     if (!string.IsNullOrEmpty(id))
     {
         AgentRegistration data = _agent.CheckAdminExitsSendPassword(id);
         if (data != null)
         {
             //string message = cs.ForgotPasswordSMS(data, "https://Sarkpayouts.in/AdminLogin");
             //_sender.SendEmail(data.Email, "", "ForgotPassword", message, null);
             //_sender.SendSMS(data.Name, message, data.Mobile);
         }
         else
         {
             return(Json("Please Enter Valid Email"));
         }
     }
     return(Json("Please Enter Email Id"));
 }
Example #21
0
        public bool UpdateActiveStatus(string agentId, bool status)
        {
            AgentRegistration agent = _context.AgentRegistration.Where(x => x.AgentId == agentId).FirstOrDefault();

            if (agent != null)
            {
                if (status)
                {
                    agent.IsActive = false;
                }
                else
                {
                    agent.IsActive = true;
                }
                _context.SaveChanges();
                return(true);
            }
            return(false);
        }
 public bool VerifyAgentPasswordSelectionOnEditMode(AgentRegistration agent1, out string output)
 {
     try {
         if (VerifyAgentExists_BaseOnUserName(agent1.UserName))
         {
             Driver.FindElement(By.XPath("//span[text()='" + agent1.UserName + "']//parent::td//parent::tr//a[text()='Edit']")).ClickElement();
             if (IsChecked(CheckBox_PasswordChangeRequired))
             {
                 output = "Password Change Required Options Checked as Expected";
                 return(true);
             }
             throw new Exception("Password Change Required Options is not Checked refer screenshot for more Inforation");
         }
         throw new Exception("Failed to Find Agent:" + agent1.UserName);
     }
     catch (Exception e)
     {
         throw new Exception("Password Change Required Options due to:" + e.Message);
     }
 }
        public TestStep CreateAgentWithIsPasswordRequiredOption(AgentRegistration agentRegistration, List <TestStep> listOfTestSteps)
        {
            string stepName = "Create New Agent" + agentRegistration.UserName + " if user is not existed";

            testStep = TestStepHelper.StartTestStep(testStep);
            try
            {
                testStep.SetOutput(CreateAgentWithIsPasswordRequiredOption(agentRegistration));
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                return(testStep);
            }
            catch (Exception e)
            {
                testStep.SetOutput(e.Message);
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                throw new Exception(e.Message);
            }
        }
        public TestStep VerifyAgentPasswordSelectionOnEditMode(AgentRegistration agentRegistration, List <TestStep> listOfTestSteps)
        {
            string stepName = "Verify  Agent" + agentRegistration.UserName + " Password Selection on Edit Mode";

            testStep = TestStepHelper.StartTestStep(testStep);
            try
            {
                VerifyAgentPasswordSelectionOnEditMode(agentRegistration, out string output); testStep.SetOutput(output);
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                return(testStep);
            }
            catch (Exception e)
            {
                testStep.SetOutput(e.Message);
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                throw new Exception(e.Message);
            }
        }
        public TestStep EditAgentRole(AgentRegistration agentRegistration, List <TestStep> listOfTestSteps)
        {
            string stepName = "Edit Agent :" + agentRegistration.UserName + " Role, if user is not existed create Agent with Active Status";

            testStep = TestStepHelper.StartTestStep(testStep);
            try
            {
                EditAgentRoleOption(agentRegistration, out string Messge); testStep.SetOutput(Messge);
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                return(testStep);
            }
            catch (Exception e)
            {
                testStep.SetOutput(e.Message);
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                throw new Exception(e.Message);
            }
        }
Example #26
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            try
            {
                SelectedEntry.Name        = txtName.Text;
                SelectedEntry.Enabled     = chkEnabled.Checked;
                SelectedEntry.AlertLevel  = (AlertLevel)cboAlertLevel.SelectedIndex;
                SelectedEntry.DetailLevel = (DetailLevel)cboDetailLevel.SelectedIndex;
                SelectedEntry.NotifierRegistrationName = ((AgentRegistration)cboNotifier.SelectedItem).Name;
                AgentRegistration ar = (AgentRegistration)cboNotifier.SelectedItem;
                SelectedEntry.Notifier = NotifierEntry.CreateNotifierEntry(ar.AssemblyPath, ar.ClassName);

                DialogResult = System.Windows.Forms.DialogResult.OK;
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public TestStep ChangeAgentPassword(AgentRegistration agentRegistration, List <TestStep> listOfTestSteps)
        {
            string stepName = "Change Password for Test Agent";

            testStep = TestStepHelper.StartTestStep(testStep);
            try
            {
                ChangeAgentPassword(agentRegistration.UserName, agentRegistration.Password, agentRegistration.Password, out string changepassword);
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB"));
                testStep.SetOutput(changepassword);
                listOfTestSteps.Add(testStep);
                return(testStep);
            }
            catch (Exception e)
            {
                testStep.SetOutput(e.Message);
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                throw new Exception(e.Message);
            }
        }
Example #28
0
 private void cmdManualConfig_Click(object sender, EventArgs e)
 {
     try
     {
         if ((SelectedEntry.Configuration == null || SelectedEntry.Configuration.Length == 0) && cboNotifier.SelectedItem != null)
         {
             AgentRegistration ar  = (AgentRegistration)cboNotifier.SelectedItem;
             INotifier         col = NotifierEntry.CreateNotifierEntry(ar.AssemblyPath, ar.ClassName);
             txtConfig.Text = XmlFormattingUtils.NormalizeXML(col.GetDefaultOrEmptyConfigString());
         }
         else
         {
             txtConfig.Text = XmlFormattingUtils.NormalizeXML(SelectedEntry.Configuration);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(string.Format("Error getting new/existing configuration\r\n{0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     ShowManualConfig();
 }
Example #29
0
    public async Async.Task Get_HappyPath()
    {
        await Context.InsertAll(
            new Node(_poolName, _machineId, _poolId, "1.0.0"),
            new Pool(_poolName, _poolId, Os.Linux, false, Architecture.x86_64, PoolState.Init, null));

        var auth = new TestEndpointAuthorization(RequestType.Agent, Logger, Context);
        var func = new AgentRegistration(Logger, auth, Context);

        var req = TestHttpRequestData.Empty("GET");

        req.SetUrlParameter("machine_id", _machineId);

        var result = await func.Run(req);

        Assert.Equal(HttpStatusCode.OK, result.StatusCode);
        var body = BodyAs <AgentRegistrationResponse>(result);

        Assert.NotNull(body.CommandsUrl);
        Assert.NotNull(body.EventsUrl);
        Assert.NotNull(body.WorkQueue);
    }
Example #30
0
        public void BTA270_CSP_Change_Password()
        {
            ProjectBasePage basePages = new ProjectBasePage(driverContext);

            testCase        = new TestCase(TestContext.TestName);
            listOfTestSteps = new List <TestStep>();
            testStep        = new TestStep();
            string stepName = "";
            bool   stepstatus;
            string StepOutput;

            try
            {
                var CSP_HomePage = new CSPortal_HomePage(DriverContext);
                var CSPortal_UserAdministration          = new CSPortal_UserAdministration(DriverContext);
                var CSPortal_UserAdministrationAgentPage = new CSPortal_UserAdministrationAgentPage(DriverContext);
                AgentRegistration agent = new AgentRegistration();

                #region Step1:Launch CSPortal Portal
                stepName = "Launch Customer Service Portal URL";
                testStep = TestStepHelper.StartTestStep(testStep);
                var CSP_LoginPage = new CSPortal_LoginPage(DriverContext);
                CSP_LoginPage.LaunchCSPortal(login.Csp_url, out string Step_Output); testStep.SetOutput(Step_Output);
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                #endregion

                #region Step2:Login As csadmin
                stepName       = "Login As csadmin User";
                testStep       = TestStepHelper.StartTestStep(testStep);
                login.UserName = CsPortalData.csadmin;
                login.Password = CsPortalData.csadmin_password;
                CSP_LoginPage.LoginCSPortal(login.UserName, login.Password, out Step_Output); testStep.SetOutput(Step_Output);
                testStep.SetOutput("Login As csadmin User is Successful");
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                #endregion

                #region Step3:Navigate to User Administration
                stepName   = "Navigate to UserAdministration Page";
                testStep   = TestStepHelper.StartTestStep(testStep);
                stepstatus = CSP_HomePage.NavigateToDashBoardMenu(CSPortal_HomePage.DashBoard.UserAdministration, out StepOutput); testStep.SetOutput(StepOutput);
                testStep   = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                #endregion

                #region Step4:Navigate to Agent Page
                stepName   = "Navigate to Agent Page";
                testStep   = TestStepHelper.StartTestStep(testStep);
                stepstatus = CSPortal_UserAdministration.NavigateToSectionMenu(CSPortal_UserAdministration.Menu.Agents);
                testStep   = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB"));
                testStep.SetOutput("Navigate to Agent Page is Successful");
                listOfTestSteps.Add(testStep);
                #endregion

                #region Step5:Create new TestAgent user as per config file,if not existed
                testStep       = TestStepHelper.StartTestStep(testStep);
                agent.FistName = AgentValues.ChangePasswordTestAgent;
                agent.LastName = AgentValues.ChangePasswordTestAgent;
                agent.Role     = RoleValue.Admin.ToString();
                agent.Status   = AgentRegistration.AgentStatus.Active.ToString();
                agent.UserName = AgentValues.ChangePasswordTestAgent;
                stepName       = "Create New Agent if user is not existed";
                agent.Password = RandomDataHelper.RandomAlphanumericStringWithSpecialChars(8);
                testStep.SetOutput(CSPortal_UserAdministrationAgentPage.CreateAgent(agent.FistName, agent.LastName, agent.Role, agent.UserName, agent.Password, agent.Status));
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                #endregion

                #region Step6:Change Password for Test Agent
                testStep   = TestStepHelper.StartTestStep(testStep);
                stepName   = "Change Password for Test Agent";
                stepstatus = CSPortal_UserAdministrationAgentPage.ChangeAgentPassword(agent.UserName, agent.Password, agent.Password, out StepOutput); testStep.SetOutput(StepOutput);
                testStep   = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                #endregion

                #region Step7:Logout As Test User
                stepName = "Logout from CS Portal";
                testStep = TestStepHelper.StartTestStep(testStep);
                CSP_HomePage.LogoutCSPortal();
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB"));
                testStep.SetOutput("LogOut is Successful as csadmin");
                listOfTestSteps.Add(testStep);
                #endregion

                #region Step8:Login As Test User
                stepName = "Login As User, User Name:" + agent.UserName;
                testStep = TestStepHelper.StartTestStep(testStep);
                CSP_LoginPage.LoginCSPortal(agent.UserName, agent.Password, out StepOutput); testStep.SetOutput(StepOutput);
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); testStep.SetOutput(stepName);
                listOfTestSteps.Add(testStep);
                #endregion

                #region Step9:Verify First Name and Last Name
                stepName = "Verify First Name and Last Name";
                testStep = TestStepHelper.StartTestStep(testStep);
                testStep.SetOutput(CSP_HomePage.VerifyFirstNameAndLastName(agent.FistName, agent.LastName));
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                #endregion

                #region Step10:Navigate to Change Password
                testStep   = TestStepHelper.StartTestStep(testStep);
                stepName   = "Navigate to Change Password";
                stepstatus = CSP_HomePage.NavigateToDashBoardMenu(CSPortal_HomePage.DashBoard.ChangePassword, out StepOutput); testStep.SetOutput(StepOutput);
                testStep   = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                #endregion

                #region Stept11: Change Password
                testStep = TestStepHelper.StartTestStep(testStep);
                stepName = "Change Password for Test Agent";
                var    cSP_ChangePassword = new CSPortal_ChangePassword(DriverContext);
                string agen_OldPassword   = agent.Password;
                agent.Password = RandomDataHelper.RandomAlphanumericStringWithSpecialChars(8);
                cSP_ChangePassword.EnterPasswordDetails(agen_OldPassword, agent.Password, agent.Password, out string ValidationMessage);
                cSP_ChangePassword.SavePassword();
                stepstatus = cSP_ChangePassword.VerifySuccessMessage(agen_OldPassword, agent.Password, out StepOutput); testStep.SetOutput(StepOutput);
                testStep   = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                #endregion

                #region Step12:Logout As Test User
                stepName = "Logout from CS Portal User:"******"WEB"));
                testStep.SetOutput("LogOut is Successful as User:"******"Login As User, User Name:" + agent.UserName;
                testStep = TestStepHelper.StartTestStep(testStep);
                CSP_LoginPage.LoginCSPortal(agent.UserName, agent.Password, out StepOutput); testStep.SetOutput(Step_Output);
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); testStep.SetOutput(stepName);
                #endregion

                #region Step14:Verify First Name and Last Name
                stepName = "Verify First Name and Last Name";
                testStep = TestStepHelper.StartTestStep(testStep);
                testStep.SetOutput(CSP_HomePage.VerifyFirstNameAndLastName(agent.FistName, agent.LastName));
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                #endregion

                #region Step15:Logout As Test User
                stepName = "Logout from CS Portal User:"******"WEB"));
                testStep.SetOutput("LogOut is Successful as User:"******"WEB"));
                listOfTestSteps.Add(testStep);
                testCase.SetStatus(false);
                testStep.SetOutput(e.Message);
                testCase.SetErrorMessage(e.Message);
                testCase.SetImageContent(DriverContext.TakeScreenshot().ToString());
                Assert.Fail();
            }
            finally
            {
                testCase.SetTestCaseSteps(listOfTestSteps);
                testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow());
                listOfTestCases.Add(testCase);
            }
        }