public virtual void TestFsWithMyOwnExistsAndChildTokens()
        {
            Credentials credentials = new Credentials();
            Text        service1    = new Text("singleTokenFs1");
            Text        service2    = new Text("singleTokenFs2");
            Text        myService   = new Text("multiTokenFs");

            Org.Apache.Hadoop.Security.Token.Token <object> token = Org.Mockito.Mockito.Mock <Org.Apache.Hadoop.Security.Token.Token
                                                                                              >();
            credentials.AddToken(myService, token);
            FileSystemTestHelper.MockFileSystem fs1 = CreateFileSystemForServiceName(service1
                                                                                     );
            FileSystemTestHelper.MockFileSystem fs2 = CreateFileSystemForServiceName(service2
                                                                                     );
            FileSystemTestHelper.MockFileSystem multiFs = CreateFileSystemForServiceName(myService
                                                                                         , fs1, fs2);
            multiFs.AddDelegationTokens(renewer, credentials);
            VerifyTokenFetch(multiFs, false);
            // we had added its token to credentials
            VerifyTokenFetch(fs1, true);
            VerifyTokenFetch(fs2, true);
            Assert.Equal(3, credentials.NumberOfTokens());
            NUnit.Framework.Assert.AreSame(token, credentials.GetToken(myService));
            NUnit.Framework.Assert.IsNotNull(credentials.GetToken(service1));
            NUnit.Framework.Assert.IsNotNull(credentials.GetToken(service2));
        }
        public virtual void TestFsWithNoToken()
        {
            FileSystemTestHelper.MockFileSystem fs = CreateFileSystemForServiceName(null);
            Credentials credentials = new Credentials();

            fs.AddDelegationTokens(renewer, credentials);
            VerifyTokenFetch(fs, false);
            Assert.Equal(0, credentials.NumberOfTokens());
        }
        public virtual void TestFsWithToken()
        {
            Text service = new Text("singleTokenFs");

            FileSystemTestHelper.MockFileSystem fs = CreateFileSystemForServiceName(service);
            Credentials credentials = new Credentials();

            fs.AddDelegationTokens(renewer, credentials);
            VerifyTokenFetch(fs, true);
            Assert.Equal(1, credentials.NumberOfTokens());
            NUnit.Framework.Assert.IsNotNull(credentials.GetToken(service));
        }
        public virtual void TestFsWithDuplicateChildren()
        {
            Credentials credentials = new Credentials();
            Text        service     = new Text("singleTokenFs1");

            FileSystemTestHelper.MockFileSystem fs      = CreateFileSystemForServiceName(service);
            FileSystemTestHelper.MockFileSystem multiFs = CreateFileSystemForServiceName(null
                                                                                         , fs, new FilterFileSystem(fs));
            multiFs.AddDelegationTokens(renewer, credentials);
            VerifyTokenFetch(multiFs, false);
            VerifyTokenFetch(fs, true);
            Assert.Equal(1, credentials.NumberOfTokens());
            NUnit.Framework.Assert.IsNotNull(credentials.GetToken(service));
        }
        public virtual void TestFsWithTokenExists()
        {
            Credentials credentials = new Credentials();
            Text        service     = new Text("singleTokenFs");

            FileSystemTestHelper.MockFileSystem             fs    = CreateFileSystemForServiceName(service);
            Org.Apache.Hadoop.Security.Token.Token <object> token = Org.Mockito.Mockito.Mock <Org.Apache.Hadoop.Security.Token.Token
                                                                                              >();
            credentials.AddToken(service, token);
            fs.AddDelegationTokens(renewer, credentials);
            VerifyTokenFetch(fs, false);
            Assert.Equal(1, credentials.NumberOfTokens());
            NUnit.Framework.Assert.AreSame(token, credentials.GetToken(service));
        }
        public virtual void TestFsWithNestedDuplicatesChildren()
        {
            Credentials credentials  = new Credentials();
            Text        service1     = new Text("singleTokenFs1");
            Text        service2     = new Text("singleTokenFs2");
            Text        service4     = new Text("singleTokenFs4");
            Text        multiService = new Text("multiTokenFs");

            Org.Apache.Hadoop.Security.Token.Token <object> token2 = Org.Mockito.Mockito.Mock <
                Org.Apache.Hadoop.Security.Token.Token>();
            credentials.AddToken(service2, token2);
            FileSystemTestHelper.MockFileSystem fs1 = CreateFileSystemForServiceName(service1
                                                                                     );
            FileSystemTestHelper.MockFileSystem fs1B = CreateFileSystemForServiceName(service1
                                                                                      );
            FileSystemTestHelper.MockFileSystem fs2 = CreateFileSystemForServiceName(service2
                                                                                     );
            FileSystemTestHelper.MockFileSystem fs3 = CreateFileSystemForServiceName(null);
            FileSystemTestHelper.MockFileSystem fs4 = CreateFileSystemForServiceName(service4
                                                                                     );
            // now let's get dirty!  ensure dup tokens aren't fetched even when
            // repeated and dupped in a nested fs.  fs4 is a real test of the drill
            // down: multi-filter-multi-filter-filter-fs4.
            FileSystemTestHelper.MockFileSystem multiFs = CreateFileSystemForServiceName(multiService
                                                                                         , fs1, fs1B, fs2, fs2, new FilterFileSystem(fs3), new FilterFileSystem(new FilterFileSystem
                                                                                                                                                                    (fs4)));
            FileSystemTestHelper.MockFileSystem superMultiFs = CreateFileSystemForServiceName
                                                                   (null, fs1, fs1B, fs1, new FilterFileSystem(fs3), new FilterFileSystem(multiFs));
            superMultiFs.AddDelegationTokens(renewer, credentials);
            VerifyTokenFetch(superMultiFs, false);
            // does not have its own token
            VerifyTokenFetch(multiFs, true);
            // has its own token
            VerifyTokenFetch(fs1, true);
            VerifyTokenFetch(fs2, false);
            // we had added its token to credentials
            VerifyTokenFetch(fs3, false);
            // has no tokens
            VerifyTokenFetch(fs4, true);
            Assert.Equal(4, credentials.NumberOfTokens());
            //fs1+fs2+fs4+multifs (fs3=0)
            NUnit.Framework.Assert.IsNotNull(credentials.GetToken(service1));
            NUnit.Framework.Assert.IsNotNull(credentials.GetToken(service2));
            NUnit.Framework.Assert.AreSame(token2, credentials.GetToken(service2));
            NUnit.Framework.Assert.IsNotNull(credentials.GetToken(multiService));
            NUnit.Framework.Assert.IsNotNull(credentials.GetToken(service4));
        }
        public virtual void TestFsWithChildTokens()
        {
            Credentials credentials = new Credentials();
            Text        service1    = new Text("singleTokenFs1");
            Text        service2    = new Text("singleTokenFs2");

            FileSystemTestHelper.MockFileSystem fs1 = CreateFileSystemForServiceName(service1
                                                                                     );
            FileSystemTestHelper.MockFileSystem fs2 = CreateFileSystemForServiceName(service2
                                                                                     );
            FileSystemTestHelper.MockFileSystem fs3     = CreateFileSystemForServiceName(null);
            FileSystemTestHelper.MockFileSystem multiFs = CreateFileSystemForServiceName(null
                                                                                         , fs1, fs2, fs3);
            multiFs.AddDelegationTokens(renewer, credentials);
            VerifyTokenFetch(multiFs, false);
            // has no tokens of own, only child tokens
            VerifyTokenFetch(fs1, true);
            VerifyTokenFetch(fs2, true);
            VerifyTokenFetch(fs3, false);
            Assert.Equal(2, credentials.NumberOfTokens());
            NUnit.Framework.Assert.IsNotNull(credentials.GetToken(service1));
            NUnit.Framework.Assert.IsNotNull(credentials.GetToken(service2));
        }