Beispiel #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGetSpecifiedUsernameAndMetaDataInTXData()
        public virtual void ShouldGetSpecifiedUsernameAndMetaDataInTXData()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicReference<String> usernameRef = new java.util.concurrent.atomic.AtomicReference<>();
            AtomicReference <string> usernameRef = new AtomicReference <string>();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicReference<java.util.Map<String,Object>> metaDataRef = new java.util.concurrent.atomic.AtomicReference<>();
            AtomicReference <IDictionary <string, object> > metaDataRef = new AtomicReference <IDictionary <string, object> >();

            _db.registerTransactionEventHandler(GetBeforeCommitHandler(txData =>
            {
                usernameRef.set(txData.username());
                metaDataRef.set(txData.metaData());
            }));
            AuthSubject subject = mock(typeof(AuthSubject));

            when(subject.Username()).thenReturn("Christof");
            LoginContext loginContext             = new LoginContextAnonymousInnerClass(this, subject);
            IDictionary <string, object> metadata = genericMap("username", "joe");

            RunTransaction(loginContext, metadata);

            assertThat("Should have specified username", usernameRef.get(), equalTo("Christof"));
            assertThat("Should have metadata with specified username", metaDataRef.get(), equalTo(metadata));
        }
Beispiel #2
0
        public override AuthSubject SubjectOrAnonymous()
        {
            AuthSubject subject = mock(typeof(AuthSubject));

            when(subject.Username()).thenReturn("testUser");
            return(subject);
        }
Beispiel #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAccessUsernameFromAuthSubject()
        public virtual void ShouldAccessUsernameFromAuthSubject()
        {
            AuthSubject authSubject = mock(typeof(AuthSubject));

            when(authSubject.Username()).thenReturn("Christof");
            when(_transaction.securityContext()).thenReturn(new SecurityContext(authSubject, [email protected]_Static.Full));

            TxStateTransactionDataSnapshot transactionDataSnapshot = Snapshot();

            assertEquals("Christof", transactionDataSnapshot.Username());
        }
Beispiel #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup()
        public virtual void Setup()
        {
            AuthSubject subject = mock(typeof(AuthSubject));

            when(subject.Username()).thenReturn("pearl");

            EnterpriseSecurityContext ctx = mock(typeof(EnterpriseSecurityContext));

            when(ctx.Subject()).thenReturn(subject);
            when(ctx.Roles()).thenReturn(Collections.singleton("jammer"));

            _procedures = new SecurityProcedures();
            _procedures.securityContext = ctx;
            _procedures.userManager     = mock(typeof(EnterpriseUserManager));
        }
Beispiel #5
0
 private string WithSubject(AuthSubject subject, string msg)
 {
     return("[" + subject.Username() + "] " + msg);
 }
Beispiel #6
0
 private static string WithSubject(AuthSubject subject, string msg)
 {
     return("[" + escape(subject.Username()) + "]: " + msg);
 }