Ejemplo n.º 1
0
        /// <summary>
        /// Return an auth token of a test profile
        /// </summary>
        /// <returns>Auth token</returns>
        private async Task<string> GetTestToken()
        {
            DedaloClient client = new DedaloClient();
            DedaloResponse<Utente> response = await client.SignIn("test", "ciao");

            return response.Data.AuthToken ?? null;
        }
Ejemplo n.º 2
0
        public async Task TestMeWithInternalAuthToken()
        {
            string authToken = await GetTestToken();
        
            DedaloClient client = new DedaloClient(authToken);
            DedaloResponse<Utente> response = await client.GetMe();

            Assert.IsNotNull(response.Data);
        }
Ejemplo n.º 3
0
        public async Task TestAuthWithDifferentUserAgent()
        {
            DedaloClient client = new DedaloClient(string.Empty, "user-agent1");

            DedaloResponse<Utente> response = await client.SignIn(username, password);
            Utente user = response.Data;

            Assert.IsNotNull(user);
        }
Ejemplo n.º 4
0
        public async Task TestAuthWithAuthToken()
        {
            DedaloClient client = new DedaloClient(string.Empty);

            DedaloResponse<Utente> response = await client.SignIn(username, password);
            Utente user = response.Data;

            Assert.IsNotNull(user);
        }
Ejemplo n.º 5
0
        public async Task TestAuthWithDefaultValues()
        {
            DedaloClient client = new DedaloClient();

            DedaloResponse<Utente> response = await client.SignIn(username, password);
            Utente user = response.Data;

            Assert.IsNotNull(user);
        }
Ejemplo n.º 6
0
        public async void DoLogin()
        {
            if (string.IsNullOrWhiteSpace(this.username) || string.IsNullOrWhiteSpace(this.password))
            {
                MessageBoxHelper.Show(
                    Properties.Resources.LoginMissingField,
                    Properties.Resources.MessageBoxErrorTitle,
                    MessageBoxButton.OK,
                    MessageBoxImage.Information);
                return;
            }

            DedaloClient client = new DedaloClient();
            DedaloResponse<Utente> loginResponse = await client.SignIn(this.username, this.password);
            if (loginResponse.Error != null)
            {
                if (loginResponse.Error.Code == 1)
                {
                    // wrong username
                    MessageBoxHelper.Show(
                        Properties.Resources.WrongUsername,
                        Properties.Resources.MessageBoxErrorTitle,
                        MessageBoxButton.OK,
                        MessageBoxImage.Error);
                }
                else if (loginResponse.Error.Code == 13)
                {
                    // wrong password
                    MessageBoxHelper.Show(
                        Properties.Resources.WrongPassword,
                        Properties.Resources.MessageBoxErrorTitle,
                        MessageBoxButton.OK,
                        MessageBoxImage.Error);
                }
                else
                {
                    // general error
                    MessageBoxHelper.Show(
                        Properties.Resources.GeneralErrorMessage,
                        Properties.Resources.MessageBoxErrorTitle,
                        MessageBoxButton.OK,
                        MessageBoxImage.Error);
                }
            }
            else
            {
                Constants.ActualUser = loginResponse.Data;
            }
        }