Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Setup()
        {
            _testRealm = new TestRealm(thisnew InMemoryUserRepository(), new InMemoryRoleRepository(), new BasicPasswordPolicy(), NewRateLimitedAuthStrategy(), mock(typeof(JobScheduler)), new InMemoryUserRepository(), new InMemoryUserRepository()
                                       );

            IList <Realm> realms = listOf(_testRealm);

            _authManager = new MultiRealmAuthManager(_testRealm, realms, new MemoryConstrainedCacheManager(), mock(typeof(SecurityLog)), true, false, Collections.emptyMap());

            _authManager.init();
            _authManager.start();

            _authManager.UserManager.newUser("mike", password("123"), false);
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotLogAuthenticationIfFlagSaysNo() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotLogAuthenticationIfFlagSaysNo()
        {
            // Given
            _manager.shutdown();
            _manager = CreateAuthManager(false);

            Users.create(NewUser("jake", "abc123", false));
            _manager.start();
            SetMockAuthenticationStrategyResult("jake", "abc123", AuthenticationResult.SUCCESS);

            // When
            AuthenticationResult result = _manager.login(authToken("jake", "abc123")).subject().AuthenticationResult;

            // Then
            assertThat(result, equalTo(AuthenticationResult.SUCCESS));
            _logProvider.assertNone(Info("[jake]: logged in"));
        }
Esempio n. 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Setup()
        {
            SecurityLog           securityLog           = mock(typeof(SecurityLog));
            InternalFlatFileRealm internalFlatFileRealm = new InternalFlatFileRealm(new InMemoryUserRepository(), new InMemoryRoleRepository(), new BasicPasswordPolicy(), new RateLimitedAuthenticationStrategy(Clock.systemUTC(), Config.defaults()), mock(typeof(JobScheduler)), new InMemoryUserRepository(), new InMemoryUserRepository()
                                                                                    );

            _testRealm = new TestRealm(this, LdapConfig, securityLog, new SecureHasher());

            IList <Realm> realms = listOf(internalFlatFileRealm, _testRealm);

            _fakeTicker  = new FakeTicker();
            _authManager = new MultiRealmAuthManager(internalFlatFileRealm, realms, new ShiroCaffeineCache.Manager(_fakeTicker.read, 100, 10, true), securityLog, false, false, Collections.emptyMap());
            _authManager.init();
            _authManager.start();

            _authManager.UserManager.newUser("mike", password("123"), false);
            _authManager.UserManager.newUser("mats", password("456"), false);
        }
Esempio n. 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldMakeOnlyUserAdminIfNoRolesFile() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldMakeOnlyUserAdminIfNoRolesFile()
        {
            // Given
            Users.create(NewUser("jake", "abc123", false));

            // When
            _manager.start();

            // Then
            assertThat(_manager.UserManager.getRoleNamesForUser("jake"), contains(PredefinedRoles.ADMIN));
        }