public void EmptyInstance_Import_Failure() { UserLdap oUserLdap = new UserLdap(); var res = oUserLdap.Import("1234234", "alias"); Assert.IsFalse(res.Success, "Importing an empty instance should fail"); }
public void GetLdapUsers_InvalidPageNumber_Failure() { List <UserLdap> oUsers; var res = UserLdap.GetLdapUsers(_connectionServer, out oUsers, 99999, 100, null); Assert.IsFalse(res.Success, "GetLdapUsers with invalid page number should fail"); }
public void GetLdapUsers_NullConnectionServer_Failure() { List <UserLdap> oUsers; var res = UserLdap.GetLdapUsers(null, out oUsers, 0, 20, ""); Assert.IsFalse(res.Success, "GetLdapUsers with null Connection server should fail"); }
public void ImportLdapUser_EmptyProperties_Failure() { UserFull oUser; ConnectionPropertyList oProps = new ConnectionPropertyList(); var res = UserLdap.ImportLdapUser(_mockServer, "templatealias", "pkid", "alias", "firstname", "lastname", "extension", oProps, out oUser); Assert.IsFalse(res.Success, "Calling ImportLdapUser with empty properties should fail"); }
public void ImportLdapUser_InvalidPkid_Failure() { UserFull oUser; ConnectionPropertyList oProps = new ConnectionPropertyList(); oProps.Add("Test", "test"); var res = UserLdap.ImportLdapUser(_connectionServer, "templatealias", "pkid", "alias", "firstname", "lastname", "extension", oProps, out oUser); Assert.IsFalse(res.Success, "Calling ImportLdapUser with invalid pkid should fail"); }
public void ImportLdapUser_GarbageResults_Failure() { //garbage response _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), It.IsAny <MethodType>(), It.IsAny <ConnectionServerRest>(), It.IsAny <string>(), true)).Returns(new WebCallResult { Success = true, ResponseText = "garbage result" }); var res = UserLdap.ImportLdapUser(_mockServer, "InvalidResultText", "pkid", "Alias", "FirstName", "LastName", "Extension", null); Assert.IsTrue(res.Success, "Calling ImportLdapUser with InvalidResultText should not fail:" + res); }
public void ImportLdapUser_ReturnedObjectId_Success() { //return objectId _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), It.IsAny <MethodType>(), It.IsAny <ConnectionServerRest>(), It.IsAny <string>(), true)).Returns(new WebCallResult { Success = true, ResponseText = "/vmrest/users/junk" }); var res = UserLdap.ImportLdapUser(_mockServer, "test", "pkid", "Alias", "FirstName", "LastName", "Extension", null); Assert.IsTrue(res.Success, "Calling ImportLdapUser with ReturnSpecificText using junk ObjectId value failed:" + res); Assert.IsTrue(res.ReturnedObjectId.Equals("junk"), "junk not returned as ObjecId of newly imported uses:" + res); }
public void ImportLdapUser_ErrorResponse_Failure() { //error response _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), It.IsAny <MethodType>(), It.IsAny <ConnectionServerRest>(), It.IsAny <string>(), true)).Returns(new WebCallResult { Success = false, ResponseText = "error text", StatusCode = 404 }); var res = UserLdap.ImportLdapUser(_mockServer, "ErrorResponse", "pkid", "Alias", "FirstName", "LastName", "Extension", null); Assert.IsFalse(res.Success, "Calling ImportLdapUser with ErrorResponse did not fail"); }
public ActionResult Login(LoginLDAP user) { // var user = authService.Login(userName, password); UserLdap objuser = authService.Login(user.userName, user.password); if (user != null) { responsedata = new ResponseData(objuser, "success", ""); } else { responsedata = new ResponseData(null, "ERROR", "ERROR MESSAGE"); } return(Ok(responsedata)); }
public void GetLdapUsers_InvalidQuery() { List <UserLdap> oUsers; var res = UserLdap.GetLdapUsers(_connectionServer, out oUsers, 0, 20, "query=(alias is _bogus_)"); if (res.ResponseText.Contains("LDAP_DIRECTORY_SYNCH_NOT_ACTIVATED")) { Console.WriteLine("LDAP not enabled on box -skipping invalid query test"); return; } Assert.IsTrue(res.Success, "GetLdapUsers with invalid query server should not fail:" + res); Assert.IsNotNull(oUsers, "Bogus query should not return a null list"); Assert.IsTrue(oUsers.Count == 0, "Bogus query should return empty list"); }
public void ImportLdapUser_EmptyResponse_Failure() { UserFull oUser; //empty results _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), It.IsAny <MethodType>(), It.IsAny <ConnectionServerRest>(), It.IsAny <string>(), true)).Returns(new WebCallResult { Success = true, ResponseText = "" }); var res = UserLdap.ImportLdapUser(_mockServer, "EmptyResultText", "pkid", "Alias", "FirstName", "LastName", "Extension", null, out oUser); Assert.IsFalse(res.Success, "Calling ImportLdapUser with EmptyResultText did not fail"); }
public void GetLdapUsers_ErrorResponse_Failure() { List <UserLdap> oUsers; //error response _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.GET, It.IsAny <ConnectionServerRest>(), It.IsAny <string>(), true)).Returns(new WebCallResult { Success = false, ResponseText = "error text", StatusCode = 404 }); var res = UserLdap.GetLdapUsers(_mockServer, out oUsers, 0, 20, "ErrorResponse"); Assert.IsFalse(res.Success, "Calling GetLdapUsers with ErrorResponse did not fail"); }
public void GetLdapUsers_GarbageResults_Success() { List <UserLdap> oUsers; //garbage response _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.GET, It.IsAny <ConnectionServerRest>(), It.IsAny <string>(), true)).Returns(new WebCallResult { Success = true, ResponseText = "garbage result" }); var res = UserLdap.GetLdapUsers(_mockServer, out oUsers, 0, 20, "InvalidResultText"); Assert.IsTrue(res.Success, "Calling GetLdapUsers with InvalidResultText should not fail:" + res); Assert.IsTrue(oUsers.Count == 0, "Invalid result text should produce an empty list of templates"); }
public void GetLdapUsers_EmptyResults_Failure() { List <UserLdap> oUsers; //empty results _mockTransport.Setup( x => x.GetCupiResponse(It.IsAny <string>(), It.IsAny <MethodType>(), It.IsAny <ConnectionServerRest>(), It.IsAny <string>(), true)).Returns(new WebCallResult { Success = true, ResponseText = "" }); var res = UserLdap.GetLdapUsers(_mockServer, out oUsers, 0, 20, "EmptyResultText"); Assert.IsFalse(res.Success, "Calling GetLdapUsers with EmptyResultText did not fail"); }
public void GetLdapUsers_Success() { List <UserLdap> oUsers; var res = UserLdap.GetLdapUsers(_connectionServer, out oUsers, 0, 5); if (res.ResponseText.Contains("LDAP_DIRECTORY_SYNCH_NOT_ACTIVATED")) { Console.WriteLine("LDAP not enabled on box -skipping live tests of LDAP import"); return; } Assert.IsTrue(res.Success, "Failed fetching LDAP users:" + res); Assert.IsNotNull(oUsers, "Fetch of LDAP users returned null list"); foreach (var oUser in oUsers) { Console.WriteLine(oUser.ToString()); Console.WriteLine(oUser.SelectionDisplayString); Console.WriteLine(oUser.UniqueIdentifier); } }