Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogSuccessfulAuthorizationQueries()
        public virtual void ShouldLogSuccessfulAuthorizationQueries()
        {
            // Given
            when(Config.get(SecuritySettings.ldap_use_starttls)).thenReturn(true);

            LdapRealm realm = new TestLdapRealm(this, Config, _securityLog, false);
            JndiLdapContextFactory jndiLdapContectFactory = mock(typeof(JndiLdapContextFactory));

            when(jndiLdapContectFactory.Url).thenReturn("ldap://myserver.org:12345");

            // When
            realm.DoGetAuthorizationInfo(new SimplePrincipalCollection("olivia", "LdapRealm"));

            // Then
            verify(_securityLog).debug(contains("{LdapRealm}: Queried for authorization info for user 'olivia'"));
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogFailedAuthorizationQueries()
        public virtual void ShouldLogFailedAuthorizationQueries()
        {
            // Given
            when(Config.get(SecuritySettings.ldap_use_starttls)).thenReturn(true);

            LdapRealm realm = new TestLdapRealm(this, Config, _securityLog, true);
            JndiLdapContextFactory jndiLdapContectFactory = mock(typeof(JndiLdapContextFactory));

            when(jndiLdapContectFactory.Url).thenReturn("ldap://myserver.org:12345");

            // When
            AuthorizationInfo info = realm.DoGetAuthorizationInfo(new SimplePrincipalCollection("olivia", "LdapRealm"));

            // Then
            assertNull(info);
            verify(_securityLog).warn(contains("{LdapRealm}: Failed to get authorization info: " + "'LDAP naming error while attempting to retrieve authorization for user [olivia].'" + " caused by 'Simulated failure'"));
        }