Esempio n. 1
0
        public bool GetResetPasswordUrl(object[] lStrvalue)
        {
            clsGlobalVariable.strExceptionReport = string.Empty;
            string     statusCode   = string.Empty;
            string     result       = string.Empty;
            clsGeneric oGeneric     = new clsGeneric();
            string     URI          = string.Empty;
            Hashtable  htblTestData = new Hashtable();

            htblTestData = oGeneric.GetTestData(lStrvalue);
            bool _Flag = false;

            clsCoursePushDown clData = new clsCoursePushDown();

            GetAPICredentials oGetAPICredentials = new GetAPICredentials();

            try
            {
                if (htblTestData["OrgID"].ToString() != "")
                {
                    clsAPI.orgID  = htblTestData["OrgID"].ToString();
                    clsAPI.userid = htblTestData["UserID"].ToString();
                }


                oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.orgCredential.Replace("$", clsAPI.orgID), clData, "H2", "", "");

                var        orgCredential = JsonConvert.DeserializeObject <GetAPICredentials>(result);
                Crypto3DES _des          = new Crypto3DES(ApplicationSettings.EComModuleEncKey());

                _ecomTransactionKey = _des.Decrypt3DES(orgCredential.TransactionKey);
                _ecomLoginKey       = _des.Decrypt3DES(orgCredential.LoginID);
                // clsAPI.orgID = htblTestData["OrgID"].ToString();
                oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.apiResetPasswordURL.Replace("$", clsAPI.orgID).Replace("#", clsAPI.userid), clData, htblTestData["MethodType"].ToString(), _ecomLoginKey, _ecomTransactionKey);

                if (htblTestData["TestCaseType"].ToString().ToUpper() == "POSITIVE")
                {
                    if (result.Contains("Url"))
                    {
                        ResetPasswordURL oResetPasswordURL = new ResetPasswordURL();
                        var oResetPassword = JsonConvert.DeserializeObject <ResetPasswordURL>(result);
                        iWebdriver.Navigate().GoToUrl(oResetPassword.URL);
                        _Flag = true;
                    }
                }
                else
                {
                    if (!result.Contains("Url"))
                    {
                        _Flag = true;
                    }
                }

                return(_Flag);
            }
            catch (Exception e)
            {
                clsException.ExceptionHandler(e, iWebdriver, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name);

                return(false);
            }
        }
Esempio n. 2
0
        public bool GetIlmsConnectSharedKey(object[] lStrvalue)
        {
            clsGlobalVariable.strExceptionReport = string.Empty;
            string     statusCode   = string.Empty;
            string     result       = string.Empty;
            clsGeneric oGeneric     = new clsGeneric();
            string     URI          = string.Empty;
            Hashtable  htblTestData = new Hashtable();

            htblTestData = oGeneric.GetTestData(lStrvalue);
            bool _Flag = false;

            clsCoursePushDown clData = new clsCoursePushDown();

            GetAPICredentials oGetAPICredentials = new GetAPICredentials();

            try
            {
                if (htblTestData["OrgID"].ToString() != "")
                {
                    clsAPI.orgID = htblTestData["OrgID"].ToString();
                }

                oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.orgCredential.Replace("$", clsAPI.orgID), clData, "H2", "", "");

                var        orgCredential = JsonConvert.DeserializeObject <GetAPICredentials>(result);
                Crypto3DES _des          = new Crypto3DES(ApplicationSettings.EComModuleEncKey());

                _ecomTransactionKey = _des.Decrypt3DES(orgCredential.TransactionKey);
                _ecomLoginKey       = _des.Decrypt3DES(orgCredential.LoginID);
                //  clsAPI.orgID = htblTestData["OrgID"].ToString();
                oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.apiILMSConnect.Replace("$", clsAPI.orgID), clData, htblTestData["MethodType"].ToString(), _ecomLoginKey, _ecomTransactionKey);
                if (htblTestData["TestCaseType"].ToString().ToUpper() == "POSITIVE")
                {
                    if (result.Contains("SharedKey") && result.Contains("BaseURL"))
                    {
                        var    oSharedKey = JsonConvert.DeserializeObject <IlmsConnectSharedKey>(result);
                        string URL        = oSharedKey.BaseURL;
                        _decriptedKey            = _des.Decrypt3DES(oSharedKey.SharedKey);
                        clsAPI.ilmsconnectFormat = clsAPI.ilmsconnectFormat.Replace("{OrgID}", clsAPI.orgID).Replace("{Key}", _decriptedKey).Replace("{UserID}", clsAPI.userid);

                        _Encriptedstring = _des.Encrypt3DES(clsAPI.ilmsconnectFormat);
                        iWebdriver.Navigate().GoToUrl(URL + "?enc=" + _Encriptedstring);
                        try
                        {
                            iWebdriver.SwitchTo().Frame(clsPageObject.strHeaderFrameID);
                            string strActualResult = iWebdriver.FindElement(clsPageObject.lvLearnerLogout).Text;
                            StringAssert.AreEqualIgnoringCase("Logout", strActualResult);
                            _Flag = true;
                        }
                        catch (Exception exc)
                        {
                            clsGlobalVariable.strExceptionReport = exc.Message.ToString();
                            _Flag = false;
                        }


                        _Flag = true;
                    }
                }
                else
                {
                    if (!result.Contains("SharedKey") && !result.Contains("BaseURL"))
                    {
                        _Flag = true;
                    }
                }

                return(_Flag);
            }
            catch (Exception e)
            {
                clsException.ExceptionHandler(e, iWebdriver, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name);

                return(false);
            }
        }
        /// <summary>
        /// Function to pass Account Request ID and get data related to Request
        /// </summary>
        /// <param name="lStrvalue">XML Parameter</param>
        /// <returns></returns>
        public bool APIGetAccountRequestStatus(object[] lStrvalue)
        {
            string strError = string.Empty;

            clsGlobalVariable.strExceptionReport = string.Empty;
            string     statusCode   = string.Empty;
            string     result       = string.Empty;
            clsGeneric oGeneric     = new clsGeneric();
            string     URI          = string.Empty;
            Hashtable  htblTestData = new Hashtable();

            htblTestData = oGeneric.GetTestData(lStrvalue);
            string[] strCourseName = htblTestData["CourseName"].ToString().Split(',');

            bool _Flag = false;
            clsCoursePushDown clData = new clsCoursePushDown();

            try
            {
                oGeneric.GetApiResponseCodeData(out statusCode, out result, htblTestData["MethodType"].ToString(), ApplicationSettings.APIURI() + htblTestData["URI"].ToString(), clData, htblTestData["HeaderType"].ToString(), "", "");

                if (htblTestData["TestCaseType"].ToString().ToUpper() == "POSITIVE")
                {
                    if (statusCode.Contains("201"))
                    {
                        var oAccountRequest = JsonConvert.DeserializeObject <AccountRequests>(result);
                        for (int courseNameCounter = 0; courseNameCounter < strCourseName.Length; courseNameCounter++)
                        {
                            for (int courseResultCounter = 0; courseResultCounter < oAccountRequest.CourseResults.Count; courseResultCounter++)
                            {
                                if (oAccountRequest.CourseResults[courseResultCounter].SuperAdminCourseID.ToString() == strCourseName[courseNameCounter])
                                {
                                    if (oAccountRequest.CourseResults[courseResultCounter].IsErrorOccurred != "true")
                                    {
                                        _Flag = true;
                                        break;
                                    }
                                    else
                                    {
                                        strError = oAccountRequest.CourseResults[courseResultCounter].ErrorDescription;
                                    }
                                }
                            }
                        }

                        if (_Flag == true)
                        {
                            return(true);
                        }
                        else
                        {
                            clsGlobalVariable.strExceptionReport = strError;
                            return(false);
                        }
                    }
                }
                else if (htblTestData["TestCaseType"].ToString().ToUpper() == "NEGATIVE")
                {
                    if (statusCode.Contains("40") || statusCode.Contains("50"))
                    {
                        return(true);
                    }
                    else
                    {
                        clsGlobalVariable.strExceptionReport = "Negative Case Failed!";
                        return(false);
                    }
                }
                return(true);
            }
            catch (Exception e)
            {
                clsException.ExceptionHandler(e, iWebdriver, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name);

                return(false);
            }
        }
        /// <summary>
        /// Function to create organization ,Copy super admin course to created org and create ecom manager
        /// </summary>
        /// <param name="lStrvalue">XML Parameter</param>
        /// <returns></returns>
        public bool APICreateOrganizationCopyCourse(object[] lStrvalue)
        {
            clsGlobalVariable.strExceptionReport = string.Empty;
            string     statusCode   = string.Empty;
            string     result       = string.Empty;
            clsGeneric oGeneric     = new clsGeneric();
            string     URI          = string.Empty;
            Hashtable  htblTestData = new Hashtable();

            htblTestData = oGeneric.GetTestData(lStrvalue);
            bool _Flag = false;
            clsCoursePushDown clData = new clsCoursePushDown();

            Organization organization = new Organization();

            organization.Name = htblTestData["OrganizationName"].ToString();

            User user = new User();

            user.F001 = htblTestData["UserFirstName"].ToString();
            user.F003 = htblTestData["UserLastName"].ToString();
            user.F015 = htblTestData["UserEmail"].ToString();
            user.F023 = htblTestData["TimeZone"].ToString();
            user.F006 = htblTestData["Language"].ToString();

            List <SuperAdminCourseRecords> lstRecords = new List <SuperAdminCourseRecords>();

            string[] strCourses = htblTestData["SuperAdminCourseId"].ToString().Split(',');

            foreach (string strCourseID in strCourses)
            {
                SuperAdminCourseRecords course = new SuperAdminCourseRecords();
                course.NumberOfSeats      = htblTestData["Seats"].ToString();
                course.SuperAdminCourseID = string.Empty;
                course.SuperAdminCourseID = strCourseID;
                lstRecords.Add(course);
            }

            clData.Organization            = organization;
            clData.User                    = user;
            clData.SuperAdminCourseRecords = lstRecords;
            clData.OrderID                 = htblTestData["OrderID"].ToString();
            clData.PurchaseDate            = htblTestData["PurchaseDate"].ToString();

            try
            {
                oGeneric.GetApiResponseCodeData(out statusCode, out result, htblTestData["MethodType"].ToString(), ApplicationSettings.APIURI() + htblTestData["URI"].ToString(), clData, htblTestData["HeaderType"].ToString(), "", "");

                if (htblTestData["TestCaseType"].ToString().ToUpper() == "POSITIVE")
                {
                    if (result.ToUpper().Contains("!DOCTYPE"))
                    {
                        clsGlobalVariable.strExceptionReport = "Resource not found";
                        return(true);
                    }

                    if (statusCode.Contains("201"))
                    {
                        RequestID oRequest = JsonConvert.DeserializeObject <RequestID>(result);
                        URI    = ApplicationSettings.APIURI() + htblTestData["URI"].ToString() + "/" + oRequest.requestID.ToString();
                        result = string.Empty;
                        //   oGeneric.GetApiResponseCodeData(out statusCode, out result, "Get", URI, clData, htblTestData["HeaderType"].ToString(), "", "");
                        Thread.Sleep(20000);

                        AccountRequests oRequestData;
                        do
                        {
                            Thread.Sleep(10000);
                            oGeneric.GetApiResponseCodeData(out statusCode, out result, "Get", URI, clData, htblTestData["HeaderType"].ToString(), "", "");
                            Application.DoEvents();
                            oRequestData = JsonConvert.DeserializeObject <AccountRequests>(result);
                        } while (oRequestData.NewlyCreatedOrganizaitonInformation.OrganizationID == "0");

                        int courseCounter = 0;

                        clsAPI.orgID  = oRequestData.NewlyCreatedOrganizaitonInformation.OrganizationID;
                        clsAPI.userid = oRequestData.NewlyCreatedeComMgrInformation.UserID;
                        foreach (string strCourseID in strCourses)
                        {
                            if (strCourseID == oRequestData.CourseResults[courseCounter].SuperAdminCourseID.ToString())
                            {
                                courseCounter++;
                                _Flag = true;
                            }
                            else
                            {
                                courseCounter++;
                                _Flag = false;
                            }
                        }

                        if (_Flag == true)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        var oError = JsonConvert.DeserializeObject <List <SuperAdminCoursePushDownError> >(result);
                        clsGlobalVariable.strExceptionReport = "Invalid URI: Error Code: " + oError[0].ErrorCode + "\n Error Description: " + oError[0].ErrorMessage;
                        return(false);
                    }
                }
                else if (htblTestData["TestCaseType"].ToString().ToUpper() == "NEGATIVE")
                {
                    if (result.ToUpper().Contains("!DOCTYPE"))
                    {
                        clsGlobalVariable.strExceptionReport = "Resource not found";
                        return(true);
                    }

                    if (statusCode.Contains("4") || statusCode.Contains("5"))
                    {
                        if (statusCode.Contains("404") || statusCode.Contains("500") || statusCode.Contains("405"))
                        {
                            clsGlobalVariable.strExceptionReport = "Resource not found";
                            return(true);
                        }
                        var oError = JsonConvert.DeserializeObject <List <SuperAdminCoursePushDownError> >(result);
                        SuperAdminCoursePushDownErrorCode oErrorCode = new SuperAdminCoursePushDownErrorCode();
                        foreach (string strErrorCode in oErrorCode.coursePushDownErrorCode)
                        {
                            if (strErrorCode == oError[0].ErrorCode)
                            {
                                _Flag = true;
                            }
                        }
                        if (_Flag == true)
                        {
                            return(true);
                        }
                        else
                        {
                            clsGlobalVariable.strExceptionReport = "Negative Case Failed!";
                            return(false);
                        }
                    }
                    else
                    {
                        clsGlobalVariable.strExceptionReport = "Resource or URI Wrong!";
                        return(false);
                    }
                }
                return(true);
            }
            catch (Exception e)
            {
                clsException.ExceptionHandler(e, iWebdriver, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name);

                return(false);
            }
        }
        public bool APIEnrollments(object[] lStrvalue)
        {
            clsGlobalVariable.strExceptionReport = string.Empty;
            string     statusCode   = string.Empty;
            string     result       = string.Empty;
            clsGeneric oGeneric     = new clsGeneric();
            string     URI          = string.Empty;
            Hashtable  htblTestData = new Hashtable();

            htblTestData = oGeneric.GetTestData(lStrvalue);
            bool _Flag = false;
            clsCoursePushDown clData = new clsCoursePushDown();

            GetAPICredentials oGetAPICredentials = new GetAPICredentials();

            try {
                oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.orgCredential.Replace("$", htblTestData["OrgID"].ToString()), clData, "H2", "", "");

                var        orgCredential = JsonConvert.DeserializeObject <GetAPICredentials>(result);
                Crypto3DES _des          = new Crypto3DES(ApplicationSettings.EComModuleEncKey());

                _ecomTransactionKey = _des.Decrypt3DES(orgCredential.TransactionKey);
                _ecomLoginKey       = _des.Decrypt3DES(orgCredential.LoginID);



                clsAPI.orgID = htblTestData["OrgID"].ToString();
                oGeneric.GetApiResponseCodeData(out statusCode, out result, htblTestData["MethodType"].ToString(), ApplicationSettings.APIURI() + clsAPI.apiEnrollment.Replace("&", htblTestData["OrgID"].ToString()).Replace("$", htblTestData["EcomID"].ToString()).Replace("#", htblTestData["CourseID"].ToString()), clData, htblTestData["HeaderType"].ToString(), _ecomLoginKey, _ecomTransactionKey);



                if (htblTestData["TestCaseType"].ToString().ToUpper() == "POSITIVE")
                {
                    var oEnrolledUserCourseUserData = JsonConvert.DeserializeObject <List <EnrolledUserCourseUserData> >(result);
                    if (oEnrolledUserCourseUserData.Count > 0)
                    {
                        for (int iEnrolUser = 0; iEnrolUser < oEnrolledUserCourseUserData.Count; iEnrolUser++)
                        {
                            if (oEnrolledUserCourseUserData[iEnrolUser].CourseID.ToString().Contains(htblTestData["CourseID"].ToString()))
                            {
                                _Flag = true;
                            }
                        }
                    }
                }
                else if (htblTestData["TestCaseType"].ToString().ToUpper() == "NEGATIVE")
                {
                    if (_ecomTransactionKey == "" && _ecomLoginKey == "")
                    {
                        return(true);
                    }
                    if (result.ToUpper().Contains("!DOCTYPE"))
                    {
                        return(true);
                    }

                    if (statusCode.Contains("40") || statusCode.Contains("50"))
                    {
                        if (statusCode.Contains("404") || statusCode.Contains("500") || statusCode.Contains("405"))
                        {
                            return(true);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                clsException.ExceptionHandler(e, iWebdriver, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name);

                return(false);
            }
            return(_Flag);
        }