예제 #1
1
 private void frmMain_Load(object sender, EventArgs e)
 {
     try
     {
         //login
         UserApiClient _userApiClient = new UserApiClient(Core.Client);
         //user
         RoleApiClient apiClientRole = new RoleApiClient(Core.Client);
         _userController = new UserController(_userApiClient, apiClientRole);
         //
         timer1.Enabled          = true;
         timerCheckLogin.Enabled = true;
         MasterList.Innit(Core.User, Core.Path);
         if (Core.IsLogin)
         {
             lbUser.Text = Core.User;
         }
         else
         {
             lbUser.Text = "no login";
             if (!_userController.IsLogin())
             {
                 Login();
             }
         }
     }
     catch (Exception)
     {
     }
 }
예제 #2
0
        public async Task GetAccessibleDatabasesAsync_ShouldUseQueryParameters_WhenProvided()
        {
            var mockTransport = new Mock <IApiClientTransport>();

            var mockResponse = new Mock <IApiClientResponse>();

            var mockResponseContent = new Mock <IApiClientResponseContent>();

            mockResponse.Setup(x => x.Content)
            .Returns(mockResponseContent.Object);

            mockResponse.Setup(x => x.IsSuccessStatusCode)
            .Returns(true);

            string requestUri = null;

            mockTransport.Setup(x => x.GetAsync(It.IsAny <string>()))
            .Returns((string uri) =>
            {
                requestUri = uri;
                return(Task.FromResult(mockResponse.Object));
            });

            var client = new UserApiClient(mockTransport.Object);

            await client.GetAccessibleDatabasesAsync("", new GetAccessibleDatabasesQuery()
            {
                Full = true
            });

            Assert.NotNull(requestUri);
            Assert.Contains("full=true", requestUri);
        }
예제 #3
0
 public frmUser()
 {
     InitializeComponent();
     apiClient     = new UserApiClient(Core.Client);
     apiClientRole = new RoleApiClient(Core.Client);
     controller    = new UserController(apiClient, apiClientRole);
 }
예제 #4
0
 public ServerApiCall(UiSettings settings)
 {
     Users         = new UserApiClient(settings);
     Subscriptions = new SubscriptionApiClient(settings);
     Orders        = new OrderApiClient(settings);
     EntityChanges = new EntityChangesApiClient(settings);
 }
예제 #5
0
        private async void CompleteRegBtn_Click(object sender, EventArgs e)
        {
            if (!(_sfDataForm.Validate() && _sfDataForm2.Validate()))
            {
                return;
            }
            _sfDataForm.Commit();
            _sfDataForm2.Commit();
            _client.FirstName = fullName.FirstName;
            _client.LastName  = fullName.LastName;
            if (_client.ProfilePhotoUrl == null)
            {
                _client.ProfilePhotoUrl = "default";
            }
            if (CrossConnectivity.Current.IsConnected)
            {
                //! Upload data to database and image to blob storage
                var userApiClient = new UserApiClient();
                await userApiClient.UpdateClient(_client);

                Toast.MakeText(Context.ApplicationContext, $"Welcome {_client.FirstName}", ToastLength.Short).Show();
                StartActivity(new Intent(Context.ApplicationContext, typeof(MainActivity)));
            }
            else
            {
                Toast.MakeText(Context.ApplicationContext, "No Internet Connection", ToastLength.Short).Show();
            }
        }
예제 #6
0
 public NotesController(ILogger <NotesController> logger, NotesContext context, UserApiClient userApiClient)
 {
     _logger        = logger;
     _context       = context;
     _userApiClient = userApiClient;
     _context.Database.EnsureCreated();
 }
예제 #7
0
        public async Task Should_add_prod_judge_groups()
        {
            const string EMAIL_STEM = EmailData.FAKE_EMAIL_STEM;

            var prodJudge = new UserBuilder(EMAIL_STEM, 1)
                            .WithUserType(UserType.Judge)
                            .ForApplication(Application.TestApi)
                            .IsProdUser(true)
                            .BuildUserDto();

            var nonProdJudge = new UserBuilder(EMAIL_STEM, 2)
                               .WithUserType(UserType.Judge)
                               .ForApplication(Application.TestApi)
                               .IsProdUser(false)
                               .BuildUserDto();

            UserApiClient.Setup(x => x.AddUserToGroupAsync(It.IsAny <AddUserToGroupRequest>()))
            .Returns(Task.CompletedTask);

            var groupsForProdCount = await UserApiService.AddGroupsToUser(prodJudge, "1");

            var groupsForNonProdCount = await UserApiService.AddGroupsToUser(nonProdJudge, "2");

            groupsForProdCount.Should().BeGreaterThan(groupsForNonProdCount);
        }
        public async Task Should_create_new_user_in_aad(UserType userType)
        {
            const string EMAIL_STEM = EmailData.FAKE_EMAIL_STEM;

            var userRequest = new UserBuilder(EMAIL_STEM, 1)
                              .WithUserType(userType)
                              .ForApplication(Application.TestApi)
                              .BuildRequest();

            var newUserResponse = new NewUserResponse
            {
                OneTimePassword = "******",
                UserId          = "1234",
                Username        = userRequest.Username
            };

            UserApiClient.Setup(x => x.CreateUserAsync(It.IsAny <CreateUserRequest>())).ReturnsAsync(newUserResponse);
            UserApiClient.Setup(x => x.AddUserToGroupAsync(It.IsAny <AddUserToGroupRequest>()))
            .Returns(Task.CompletedTask);

            var userDetails = await UserApiService.CreateNewUserInAAD(userRequest.FirstName, userRequest.LastName, userRequest.ContactEmail, userRequest.IsProdUser);

            userDetails.OneTimePassword.Should().Be(newUserResponse.OneTimePassword);
            userDetails.UserId.Should().Be(newUserResponse.UserId);
            userDetails.Username.Should().Be(newUserResponse.Username);
        }
예제 #9
0
        protected override void Setup()
        {
            var connection = _adminConnection.Value;

            _userApiClient = connection.Users;
            SetRequiredData(_userApiClient);
        }
        public async Task Should_reset_user_password()
        {
            const string USERNAME     = EmailData.NON_EXISTENT_USERNAME;
            const string NEW_PASSWORD = UserData.NEW_PASSWORD;

            var request = new ResetUserPasswordRequest()
            {
                Username = USERNAME
            };

            var response = new UpdateUserResponse()
            {
                NewPassword = NEW_PASSWORD
            };

            UserApiClient
            .Setup(x => x.ResetUserPasswordAsync(USERNAME))
            .ReturnsAsync(response);

            var result = await Controller.ResetUserPassword(request);

            result.Should().NotBeNull();
            var objectResult = (OkObjectResult)result;

            objectResult.StatusCode.Should().Be((int)HttpStatusCode.OK);

            var passwordResponse = (UpdateUserResponse)objectResult.Value;

            passwordResponse.NewPassword.Should().Be(response.NewPassword);
        }
예제 #11
0
 private async Task DropUserAsync(string user)
 {
     using (var systemDbClient = GetHttpTransport("_system"))
     {
         var userApiClient = new UserApiClient(systemDbClient);
         await userApiClient.DeleteUserAsync(user);
     }
 }
        public UserApiClientTests()
        {
            var httpClient = new HttpClient(new FakeMessageHandler())
            {
                BaseAddress = new Uri("http://localhost")
            };

            _userApiClient = new UserApiClient(httpClient);
        }
예제 #13
0
 public UnloveTrackMethod(UserApiClient client, LastFmApi.Track track)
     : base(client, "track.unlove")
 {
     SetParameters(new Dictionary <ParameterKey, string>
     {
         { ParameterKey.Track, track.Title },
         { ParameterKey.Artist, track.Artist }
     });
 }
        public async Task Should_delete_user_in_aad()
        {
            const string USERNAME = EmailData.NON_EXISTENT_USERNAME;

            UserApiClient
            .Setup(x => x.DeleteUserAsync(It.IsAny <string>()))
            .Returns(Task.CompletedTask);

            await UserApiService.DeleteUserInAAD(USERNAME);
        }
예제 #15
0
 public CoreDockerClient(string urlBase)
 {
     UrlBase        = urlBase;
     _restClient    = new RestClient(UrlBase);
     Authenticate   = new AuthenticateApiClient(this);
     Projects       = new ProjectApiClient(this);
     Users          = new UserApiClient(this);
     Ping           = new PingApiClient(this);
     _graphQlClient = new GraphQLClient(UrlBase.UriCombine("/graphql"));
 }
예제 #16
0
        public GetSessionMethod(UserApiClient client, string token)
            : base(client, "auth.getSession")
        {
            _username = client.Username;

            SetParameters(new Dictionary <ParameterKey, string>
            {
                { ParameterKey.Token, token }
            });
        }
        public async Task Should_return_false_for_nonexistent_user_in_aad()
        {
            const string USERNAME = EmailData.NON_EXISTENT_USERNAME;

            UserApiClient.Setup(x => x.GetUserByAdUserNameAsync(USERNAME)).ThrowsAsync(NotFoundError);

            var userExists = await UserApiService.CheckUserExistsInAAD(USERNAME);

            userExists.Should().BeFalse();
        }
예제 #18
0
        public ApiMethodBase(UserApiClient client, string methodName)
        {
            _apiSecret = client.ApiSecret;

            Parameters = new Dictionary <ParameterKey, string>();
            Parameters.Add(ParameterKey.Method, methodName);
            Parameters.Add(ParameterKey.ApiKey, client.ApiKey);
            Parameters.Add(ParameterKey.SessionKey, client.SessionKey);

            _authorized = true;
        }
        public async Task Should_return_true_for_existing_user_in_aad()
        {
            const string USERNAME = EmailData.NON_EXISTENT_USERNAME;

            UserApiClient
            .Setup(x => x.GetUserByAdUserNameAsync(USERNAME)).ReturnsAsync(It.IsAny <UserProfile>());

            var userExists = await UserApiService.CheckUserExistsInAAD(USERNAME);

            userExists.Should().BeTrue();
        }
예제 #20
0
        public async Task <CurrentUser> GetCurrentUser(string accessToken)
        {
            var           path       = "/Me";
            UserApiClient userClient = new UserApiClient();
            var           response   = await userClient.GetResponseFromUrlAsString(path, accessToken);

            if (response != null)
            {
                return(JsonConvert.DeserializeObject <CurrentUser>(response));
            }
            return(new CurrentUser(null, null, null));
        }
예제 #21
0
        public HarvestRestClient(string bearerToken, string accountId)
        {
            if (bearerToken == null)
            {
                throw new ArgumentNullException(nameof(bearerToken));
            }

            Clients    = new ClientApiClient(bearerToken, accountId);
            Projects   = new ProjectApiClient(bearerToken, accountId);
            Users      = new UserApiClient(bearerToken, accountId);
            Timesheets = new TimesheetApiClient(bearerToken, accountId);
        }
예제 #22
0
 public UpdateNowPlayingMethod(UserApiClient client, LastFmApi.Track track, int duration)
     : base(client, "track.updateNowPlaying")
 {
     SetParameters(new Dictionary <ParameterKey, string>
     {
         { ParameterKey.Track, track.Title },
         { ParameterKey.Artist, track.Artist },
         { ParameterKey.Album, track.Album },
         { ParameterKey.AlbumArtist, track.AlbumArtist },
         { ParameterKey.Duration, duration.ToString() }
     });
 }
예제 #23
0
        public static User CreateUser(string username, string password)
        {
            var userApiClient = new UserApiClient();

            var response = userApiClient.CreateUser(username, password);

            Assert.AreEqual(HttpStatusCode.OK, response.Status, $"Unable to create user '{username}'");

            return(new User
            {
                UserName = response.Content.userName
            });
        }
예제 #24
0
 public CommunicationProvider(CommunicationConfigurationProvider communicationConfigurationProvider, UserApiClient userApiClient,
                              RoleApiClient roleApiClient, PermissionApiClient permissionApiClient, RegistrationApiClient registrationApiClient,
                              ContactApiClient contactApiClient, FulltextServiceClient fulltextServiceClient, CardFilesClient cardFilesClient)
 {
     m_configurationProvider = communicationConfigurationProvider;
     m_userApiClient         = userApiClient;
     m_roleApiClient         = roleApiClient;
     m_permissionApiClient   = permissionApiClient;
     m_registrationApiClient = registrationApiClient;
     m_contactApiClient      = contactApiClient;
     m_fulltextServiceClient = fulltextServiceClient;
     m_cardFilesClient       = cardFilesClient;
 }
예제 #25
0
        public async Task Should_refresh_judges_cache()
        {
            UserApiClient
            .Setup(x => x.RefreshJudgeCacheAsync())
            .Returns(Task.CompletedTask);

            var result = await Controller.RefreshJudgesCache();

            result.Should().NotBeNull();
            var objectResult = (OkResult)result;

            objectResult.StatusCode.Should().Be((int)HttpStatusCode.OK);
        }
예제 #26
0
        public static User GetUserByName(string username)
        {
            var userApiClient = new UserApiClient();

            var response = userApiClient.GetUser(username);

            Assert.AreEqual(HttpStatusCode.OK, response.Status, $"Unable to find user {username}");

            return(new User
            {
                UserName = response.Content.userName
            });
        }
        public async void OnComplete(Task task)
        {
            if (task.IsSuccessful)
            {
                if (_userInfo == null)
                {
                    StartActivity(new Intent(Context.ApplicationContext, typeof(MainActivity)));
                }
                else
                {
                    var client = new Client
                    {
                        Email           = _userInfo.Email,
                        FirstName       = _userInfo.FirstName,
                        LastName        = _userInfo.LastName,
                        PhoneNumber     = string.Concat(_phoneInfo.CountryCode, _phoneInfo.PhoneNumber),
                        Residence       = "Residence",
                        ProfilePhotoUrl = "my-url"
                    };
                    var userApiClient = new UserApiClient();
                    var newClient     = await userApiClient.AddClientAsync(client);

                    var fragment = new CompleteRegistrationFragment();
                    var bundle   = new Bundle();
                    bundle.PutString("client", JsonConvert.SerializeObject(newClient));
                    fragment.Arguments = bundle;

                    FragmentManager.BeginTransaction()
                    .SetCustomAnimations(Resource.Animation.anim_enter, Resource.Animation.anim_exit)
                    .Replace(Resource.Id.authorizationContainer, fragment)
                    .Commit();

                    //TODO Remove From Backstack
                }
            }
            else
            {
                var exception = task.Exception;
                switch (exception)
                {
                case FirebaseAuthInvalidCredentialsException _:
                    Toast.MakeText(Context.ApplicationContext, "The verification code entered was invalid", ToastLength.Long).Show();
                    break;

                default:
                    Toast.MakeText(Context.ApplicationContext, exception.Message, ToastLength.Long).Show();
                    break;
                }
            }
        }
 private void InitializeApis(
     IApiClientTransport transport,
     IApiClientSerialization serialization)
 {
     AqlFunction = new AqlFunctionApiClient(transport, serialization);
     Auth        = new AuthApiClient(transport, serialization);
     Cursor      = new CursorApiClient(transport, serialization);
     Database    = new DatabaseApiClient(transport, serialization);
     Document    = new DocumentApiClient(transport, serialization);
     Collection  = new CollectionApiClient(transport, serialization);
     Transaction = new TransactionApiClient(transport, serialization);
     Graph       = new GraphApiClient(transport, serialization);
     User        = new UserApiClient(transport, serialization);
 }
예제 #29
0
        static void Main(string[] args)
        {
            var consumerPact = new ConsumerMyApiPact();

            _mockProviderService        = consumerPact.MockProviderService;
            _mockProviderServiceBaseUri = consumerPact.MockProviderServiceBaseUri;
            consumerPact.MockProviderService.ClearInteractions();
            //NOTE: Clears any previously registered interactions before the test is run


            _mockProviderService
            .Given("Get user with id '1'")
            .UponReceiving("A GET request to retrieve the user")
            .With(new ProviderServiceRequest
            {
                Method  = HttpVerb.Get,
                Path    = "/user/1",
                Headers = new Dictionary <string, string>
                {
                    { "Accept", "application/json" }
                }
            })
            .WillRespondWith(new ProviderServiceResponse
            {
                Status  = 200,
                Headers = new Dictionary <string, string>
                {
                    { "Content-Type", "application/json; charset=utf-8" }
                },
                Body = new     //NOTE: Note the case sensitivity here, the body will be serialised as per the casing defined
                {
                    id        = 1,
                    firstName = "Tanmoy",
                    lastName  = "Saha"
                }
            });     //NOTE: WillRespondWith call must come last as it will register the interaction

            var consumer = new UserApiClient(_mockProviderServiceBaseUri);

            //Act
            var result = consumer.GetUsers(1);

            //Assert
            result.Should().NotBeNull();
            _mockProviderService.VerifyInteractions();
            //NOTE: Verifies that interactions registered on the mock provider are called once and only once

            consumerPact.Dispose();
        }
예제 #30
0
        public ScrobbleMethod(UserApiClient client, LastFmApi.Track track, DateTime timePlayed)
            : base(client, "track.scrobble")
        {
            var scrobbleTime  = timePlayed.ToUniversalTime();
            var unixTimeStamp = (scrobbleTime.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;

            SetParameters(new Dictionary <ParameterKey, string>
            {
                { ParameterKey.Track, track.Title },
                { ParameterKey.Artist, track.Artist },
                { ParameterKey.Album, track.Album },
                { ParameterKey.AlbumArtist, track.AlbumArtist },
                { ParameterKey.Timestamp, unixTimeStamp.ToString() }
            });
        }