Example #1
0
        public void TestReadPersonWithMultiplePendingModificationsActivated()
        {
            // Make a separate copy from the main tree used in other tests
            var tempTree = new FamilySearchFamilyTree(true);
            var features = new List <Feature>();

            tempTree.AuthenticateViaOAuth2Password(Resources.TestUserName, Resources.TestPassword, Resources.TestClientId);

            // Get all the features that are pending
            IRestRequest request = new RedirectableRestRequest()
                                   .Accept(MediaTypes.APPLICATION_JSON_TYPE)
                                   .Build("https://sandbox.familysearch.org/platform/pending-modifications", Method.GET);
            IRestResponse response = tempTree.Client.Handle(request);

            // Get each pending feature
            features.AddRange(response.ToIRestResponse <FamilySearchPlatform>().Data.Features);

            // Add every pending feature to the tree's current client
            tempTree.Client.AddFilter(new ExperimentsFilter(features.Select(x => x.Name).ToArray()));

            var state = tempTree.AddPerson(TestBacking.GetCreateMalePerson());

            cleanup.Add(state);

            // Ensure a response came back
            Assert.IsNotNull(state);
            var requestedFeatures = String.Join(",", state.Request.GetHeaders().Get("X-FS-Feature-Tag").Select(x => x.Value.ToString()));

            // Ensure each requested feature was found in the request headers
            Assert.IsTrue(features.TrueForAll(x => requestedFeatures.Contains(x.Name)));
        }
        /// <summary>
        /// Authenticate Familytree Object.
        /// </summary>
        /// <returns> True if authentication was successful, false otherwise</returns>
        /// <param name="pUserID">User ID from input</param>
        /// <param name="pPassword">Password from user input</param>
        /// <param name="pDeveloperKey">Developer Key from user input</param>
        private bool authenticateMe(string pUserID, string pPassword, string pDeveloperKey)
        {
            //We start with Wait Cursor.
            Cursor.Current = Cursors.WaitCursor;

            //Initialize the Family Tree Objects.
            demoFamilyTree = new FamilySearchFamilyTree(useSandbox);

            try
            {
                //Try to authenticate.
                demoFamilyTree.AuthenticateViaOAuth2Password(pUserID, pPassword, pDeveloperKey);

                //Switch on buttons.
                EnableButtons();

                //Indicate success.
                return(true);
            }
            catch (Exception myError)
            {
                //Display Error Message.
                txtToken.Text = "Error " + myError.Message.ToString();

                //Indicate authentication unsuccessful.
                return(false);
            }
            finally
            {
                //Restore cursor.
                Cursor.Current = Cursors.Default;
            }
        }
Example #3
0
 public void Initialize()
 {
     tree = new FamilySearchFamilyTree(true);
     tree.AuthenticateViaOAuth2Password(Resources.TestUserName, Resources.TestPassword, Resources.TestClientId);
     Assert.DoesNotThrow(() => tree.IfSuccessful());
     Assert.IsNotNullOrEmpty(tree.CurrentAccessToken);
     cleanup = new List <GedcomxApplicationState>();
 }
Example #4
0
 public void Initialize()
 {
     tree = new FamilySearchFamilyTree(true);
     tree.AuthenticateViaOAuth2Password(Resources.TestUserName, Resources.TestPassword, Resources.TestClientId);
     memories = new FamilySearchMemories(true);
     memories = (FamilySearchMemories)memories.AuthenticateWithAccessToken(tree.CurrentAccessToken).Get();
     cleanup  = new List <GedcomxApplicationState>();
 }
Example #5
0
        public void TestReadPersonWithPendingModificationActivated()
        {
            // The default client is assumed to add a single pending feature (if it doesn't, this test will fail)
            var state = tree.AuthenticateViaOAuth2Password(Resources.TestUserName, Resources.TestPassword, Resources.TestClientId);

            Assert.IsNotNull(state);
            var requestedFeatures = String.Join(",", state.Request.GetHeaders().Get("X-FS-Feature-Tag").Select(x => x.Value.ToString()));

            Assert.IsNotNull(requestedFeatures);
            Assert.AreEqual(-1, requestedFeatures.IndexOf(","));
            Assert.Greater(requestedFeatures.Length, 0);
        }
Example #6
0
 public void Initialize()
 {
     tree = new FamilySearchFamilyTree(true);
     tree.AuthenticateViaOAuth2Password(Resources.TestUserName, Resources.TestPassword, Resources.TestClientId);
     cleanup = new List <GedcomxApplicationState>();
 }