Ejemplo n.º 1
0
        public void GetActiveAccessTokens_UserSpecified_ActiveTokensForUser()
        {
            var context = new AlvTimeDbContextBuilder()
                          .WithUsers()
                          .CreateDbContext();

            var storage = new AccessTokenStorage(context);

            var tokens = storage.GetActiveTokens(1);

            Assert.Equal(context.AccessTokens.Where(x => x.UserId == 1).ToList().Count(), tokens.Count());
        }
Ejemplo n.º 2
0
 public WeChatWorkClient(
     WeChatWorkSettings settings,
     IStorage storage,
     ILogger logger = null)
 {
     _settings          = settings;
     _attachmentStorage = new WeChatAttachmentStorage(storage);
     _tokenStorage      = new AccessTokenStorage(storage);
     _logger            = logger ?? NullLogger.Instance;
     _attachmentHash    = new AttachmentHash();
     _semaphore         = new SemaphoreSlim(1);
 }
Ejemplo n.º 3
0
        public void DeleteToken_TokenIdSpecified_TokenWithIdDeleted()
        {
            var context = new AlvTimeDbContextBuilder()
                          .WithPersonalAccessTokens()
                          .WithUsers()
                          .CreateDbContext();

            var storage = new AccessTokenStorage(context);

            storage.DeleteActiveTokens(1, 1);

            var tokens = storage.GetActiveTokens(1);

            Assert.Empty(tokens);
        }
Ejemplo n.º 4
0
        public void CreateLifetimeToken_FriendlyNameSpecified_TokenWithFriendlyNameCreated()
        {
            var context = new AlvTimeDbContextBuilder()
                          .WithPersonalAccessTokens()
                          .WithUsers()
                          .CreateDbContext();

            var storage = new AccessTokenStorage(context);

            storage.CreateLifetimeToken("new token", 1);

            var tokens = storage.GetActiveTokens(1);

            Assert.Equal(context.AccessTokens.Where(x => x.UserId == 1).ToList().Count(), tokens.Count());
        }