コード例 #1
0
 private static void DeleteUserTest(Iatec.Accounts.Client.Configuration apiConfig, Guid id)
 {
     try
     {
         var api = new UserApi(apiConfig);
         api.DeleteUserById(id);
     }
     catch (ApiException ex)
     {
         throw ex;
     }
 }
コード例 #2
0
        private static PagedResponse <UserModel> GetUsersByFilter(Iatec.Accounts.Client.Configuration apiConfig, string filter)
        {
            try
            {
                var api = new UserApi(apiConfig);

                return(api.GetPagerUserByFilter(10, 0, filter));
            }
            catch (ApiException ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        private static UserModel GetUserByEmailTest(Iatec.Accounts.Client.Configuration apiConfig, string email)
        {
            try
            {
                var api = new UserApi(apiConfig);

                return(api.GetUserByEmail(email));
            }
            catch (ApiException ex)
            {
                throw ex;
            }
        }
コード例 #4
0
        private static UserModel GetUserByIdTest(Iatec.Accounts.Client.Configuration apiConfig, Guid userId)
        {
            try
            {
                var api = new UserApi(apiConfig);

                return(api.GetUserById(userId));
            }
            catch (ApiException ex)
            {
                throw ex;
            }
        }
コード例 #5
0
        private static UserModel UpdateUserByEmailTest(Iatec.Accounts.Client.Configuration apiConfig, string email, UserInsertModel user)
        {
            try
            {
                var api = new UserApi(apiConfig);

                return(api.UpdateUserByEmail(email, user));
            }
            catch (ApiException ex)
            {
                throw ex;
            }
        }
コード例 #6
0
        private static UserModel UpdateUserByIdTest(Iatec.Accounts.Client.Configuration apiConfig, Guid id, UserInsertModel user)
        {
            try
            {
                var api = new UserApi(apiConfig);

                return(api.UpdateUserById(id, user));
            }
            catch (ApiException ex)
            {
                throw ex;
            }
        }
コード例 #7
0
        private static void ResetPasswordByEmailTest(Iatec.Accounts.Client.Configuration apiConfig, string email)
        {
            try
            {
                var api = new UserApi(apiConfig);

                api.ResetPasswordByEmail(email, "admin");
            }
            catch (ApiException ex)
            {
                throw ex;
            }
        }
コード例 #8
0
        private static void ChagePasswordByIdTest(Iatec.Accounts.Client.Configuration apiConfig, Guid id)
        {
            try
            {
                var api = new UserApi(apiConfig);

                api.ChangeUserPasswordById(id, "admin");
            }
            catch (ApiException ex)
            {
                throw ex;
            }
        }
コード例 #9
0
 private static UserModel CreateUserTest(Iatec.Accounts.Client.Configuration apiConfig)
 {
     try
     {
         var api = new UserApi(apiConfig);
         return(api.CreateUser(new UserInsertModel
         {
             FirstName = "William",
             LastName = "Moura",
             Password = "******",
             Email = "*****@*****.**",
             UserName = "******",
         }));
     }
     catch (ApiException ex)
     {
         throw ex;
     }
 }
コード例 #10
0
        private static void Main(string[] args)
        {
            const string CLIENT_ID     = "00000000000000000000000000000000";
            const string CLIENT_SECRET = "secretsecretsecretsecretsecretsecretsecretsecret";

            var discoveryClient = new DiscoveryClient("https://login-dev.sdasystems.org");
            var discovery       = discoveryClient.GetAsync().Result;

            var tokenClient = new TokenClient(discovery.TokenEndpoint, CLIENT_ID, CLIENT_SECRET);
            var tokens      = tokenClient.RequestClientCredentialsAsync("scope").Result;
            // ---------------------------------------------------------------------------------------------------------- //
            var apiConfig = new Iatec.Accounts.Client.Configuration()
            {
                AccessToken = tokens.AccessToken,
                BasePath    = "https://ws-accounts-dev.sdasystems.org",
            };

            var user = CreateUserTest(apiConfig);

            ResetPasswordByEmailTest(apiConfig, user.Email);
            ResetPasswordByUsernameTest(apiConfig, user.Username);

            Console.WriteLine(user.ToString());

            var newUser = new UserInsertModel()
            {
                Email     = "*****@*****.**",
                FirstName = "Azeite",
                LastName  = "Mouras",
                Password  = "******",
                UserName  = "******",
            };

            var user1 = UpdateUserByIdTest(apiConfig, user.Id, newUser);

            Console.WriteLine(user1.ToString());

            user1.Username = "******";

            var user2 = UpdateUserByUsernameTest(apiConfig, user1.Username, newUser);

            Console.WriteLine(user2.ToString());

            user2.Email = "*****@*****.**";

            var user3 = UpdateUserByEmailTest(apiConfig, user2.Email, newUser);

            Console.WriteLine(user3?.ToString());

            var a = GetUserByEmailTest(apiConfig, user?.Email);

            Console.WriteLine(a?.ToString() ?? "Not Found!");

            //ChagePasswordByIdTest(apiConfig, user.Id);
            //if (user != null && false)
            //{
            //    var a = GetUserByEmailTest(apiConfig, user.Email);
            //    var b = GetUserByIdTest(apiConfig, user.Id);
            //    var c = GetUserByUsernameTest(apiConfig, user.UserName);

            //    Console.WriteLine(c.ToString());
            //}
            var userList = GetUsersByFilter(apiConfig, "william");

            Console.WriteLine(userList.ToString());
            foreach (var item in userList.Items)
            {
                Console.WriteLine("*");
                Console.WriteLine(item.ToString());
                Console.WriteLine("*");
            }

            DeleteUserTest(apiConfig, user.Id);

            var b = GetUserByIdTest(apiConfig, user.Id);

            if (b == null)
            {
                Console.WriteLine("Delete works");
            }

            Console.WriteLine("-- END --");
            Console.ReadLine();
        }