Exemplo n.º 1
0
        public NewsletterDaemon(Federation fed, string rootURL, string newslettersFrom,
            string headInsert, bool sendAsAttachments, string authenticateAs)
        {
            _federation = fed;
            _rootUrl = rootURL;
            _newslettersFrom = newslettersFrom;
            _headInsert = headInsert;
            _sendAsAttachments = sendAsAttachments;

            AuthorizationRuleWho who = AuthorizationRuleWho.Parse(authenticateAs);

            if (who.WhoType == AuthorizationRuleWhoType.GenericAnonymous)
            {
                _principal = new GenericPrincipal(new GenericIdentity(""), null);
            }
            else if (who.WhoType == AuthorizationRuleWhoType.User)
            {
                _principal = new GenericPrincipal(new GenericIdentity(who.Who), null);
            }
            else
            {
                throw new ArgumentException("Newsletters can only authenticate as 'anonymous' or as a particular user. Illegal value: " +
                    authenticateAs, "authenticateAs");
            }
        }
Exemplo n.º 2
0
		void ShowMain()
		{
			if (CheckForConfigurationFormatUpgrade())
				return;

			string config = ConfigurationSettings.AppSettings["FederationNamespaceMapFile"];
			string mappedConfig = (config == null ? null : MapPath(config));
			ConfigurationChecker checker = new ConfigurationChecker(
				config,
				mappedConfig);

			checker.Check();
			checker.WriteStoplightTo(UIResponse);

			UIResponse.WriteDivider();

			Federation aFederation = null;
			try
			{
				aFederation = new Federation(mappedConfig, Formatting.OutputFormat.HTML, new LinkMaker(""));
			}
			catch (Exception)
			{
			}

			if (aFederation != null)
				ShowFederationInfo(aFederation);
		}
Exemplo n.º 3
0
        private static void RunWithContext(string topic, int iterations, Federation federation)
        {
            using (RequestContext.Create())
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                string content = federation.GetTopicFormattedContent(new QualifiedTopicRevision(topic), null);
                stopwatch.Stop();

                Console.WriteLine("Rendered first times in {0} seconds", stopwatch.ElapsedMilliseconds / 1000.0F);

                stopwatch.Reset();
                stopwatch.Start();
                content = federation.GetTopicFormattedContent(new QualifiedTopicRevision(topic), null);
                stopwatch.Stop();

                Console.WriteLine("Rendered second time in {0} seconds", stopwatch.ElapsedMilliseconds / 1000.0F);

                stopwatch.Reset();
                stopwatch.Start();
                content = federation.GetTopicFormattedContent(new QualifiedTopicRevision(topic), null);
                stopwatch.Stop();

                Console.WriteLine("Rendered third time in {0} seconds", stopwatch.ElapsedMilliseconds / 1000.0F);
            }
        }
Exemplo n.º 4
0
 public void SetUp()
 {
     MockWikiApplication application = new MockWikiApplication(null,
         new LinkMaker("test://FileSystemStoreTests/"), OutputFormat.HTML,
         new MockTimeProvider(TimeSpan.FromSeconds(1)));
     _federation = new Federation(application);
 }
Exemplo n.º 5
0
        public void SetUp()
        {
            federation = WikiTestUtilities.SetupFederation("test://NamespaceManagerTests",
              TestContentSets.SingleEmptyNamespace);
            testApp = (IMockWikiApplication)federation.Application;

            NamespaceManager manager = federation.NamespaceManagerForNamespace("NamespaceOne");

            testApp.SetApplicationProperty("DisableNewParser", false);
            testApp.SetApplicationProperty("EnableNewParser", true);
            parser = new ParserEngine(federation);
        }
Exemplo n.º 6
0
    public void SetUp()
    {
      // Get the base URL from the config file and gen up the web service endpoint
      string baseUrl = TestUtilities.BaseUrl;
      _rssUrl = baseUrl + "rss.aspx"; 

      // Back up the wiki configuration
      _oldWikiState = TestUtilities.BackupWikiState(); 

      // Recreate the wiki each time so we start from a known state. Otherwise, tests
      // that (for example) retrieve old versions might not get what they expect.
      _federation = TestUtilities.CreateFederation("TestFederation", _testContent); 
    }
Exemplo n.º 7
0
        public void Federation_Ctor_MetadataLocation()
        {
            var options = StubFactory.CreateOptions();

            var subject = new Federation(
                "http://localhost:13428/federationMetadata",
                false,
                options);

            IdentityProvider idp;
            options.IdentityProviders
                .TryGetValue(new EntityId("http://idp.federation.example.com/metadata"), out idp)
                .Should().BeTrue();
        }
Exemplo n.º 8
0
        private static void Run(string topic, int iterations, Federation federation)
        {
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            for (int i = 0; i < iterations; ++i)
            {
                string content = federation.GetTopicFormattedContent(new QualifiedTopicRevision(topic), null);
            }
            stopwatch.Stop();

            Console.WriteLine("Rendered {0} times in {1} seconds for an average of {2}",
                iterations, stopwatch.ElapsedMilliseconds / 1000.0F,
                stopwatch.ElapsedMilliseconds / 1000.0F / (float)iterations);
        }
        public void SetUp()
        {
            _linkMaker = new LinkMaker(_baseUri);

            MockWikiApplication application = new MockWikiApplication(null,
                _linkMaker,
                OutputFormat.HTML,
                new MockTimeProvider(TimeSpan.FromSeconds(1)));

            Federation = new Federation(application);
            Federation.WikiTalkVersion = 1;

            _provider.Initialize(Federation);
        }
Exemplo n.º 10
0
        public void SetUp()
        {
            string author = "tester-joebob";
            _lm = new LinkMaker(_bh);
            MockWikiApplication application = new MockWikiApplication(null,
                _lm,
                OutputFormat.HTML,
                new MockTimeProvider(TimeSpan.FromSeconds(1)));
            Federation = new Federation(application);

            _base = WikiTestUtilities.CreateMockStore(Federation, "FlexWiki.Base");
            _other1 = WikiTestUtilities.CreateMockStore(Federation, "FlexWiki.Other1");
            _other2 = WikiTestUtilities.CreateMockStore(Federation, "Other2");
            _other3 = WikiTestUtilities.CreateMockStore(Federation, "Other3");
            _namespaceManager5 = WikiTestUtilities.CreateMockStore(Federation, "Space5");

            WikiTestUtilities.WriteTestTopicAndNewVersion(_base, _base.DefinitionTopicName.LocalName, @"Import: FlexWiki.Other1, Other2", author);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_base, "TopicOne", @"OtherOneHello", author);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_base, "TopicTwo", @"FlexWiki.Other1.OtherOneGoodbye", author);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_base, "TopicThree", @"No.Such.Namespace.FooBar", author);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_base, "TopicFour", @".TopicOne", author);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_base, "TopicFive", @"FooBar
Role:Designer", author);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_base, "TopicSix", @".GooBar
Role:Developer", author);

            WikiTestUtilities.WriteTestTopicAndNewVersion(_other1, _other1.DefinitionTopicName.LocalName, @"Import: Other3,Other2", author);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_other1, "OtherOneHello", @"hello
Role:Developer", author);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_other1, "OtherOneGoodbye", @"goodbye", author);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_other1, "OtherOneRefThree", @"OtherThreeTest", author);

            WikiTestUtilities.WriteTestTopicAndNewVersion(_other1, "OtherOneTopicOne", @"OtherTwoHello", author);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_other1, "OtherOneTopicTwo", @"Other2.OtherTwoGoodbye", author);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_other1, "OtherOneTopicThree", @"No.Such.Namespace.FooBar", author);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_other1, "OtherOneTopicFour", @".OtherOneTopicOne", author);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_other1, "OtherOneTopicFive", @"FooBar", author);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_other1, "OtherOneTopicSix", @".GooBar", author);

            WikiTestUtilities.WriteTestTopicAndNewVersion(_other2, "OtherTwoHello", @"hello", author);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_other2, "OtherTwoGoodbye", @"goodbye", author);

            WikiTestUtilities.WriteTestTopicAndNewVersion(_other3, "OtherThreeTest", @"yo", author);



            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager5, "AbsRef", @"Other2.OtherTwoHello", author);

        }
Exemplo n.º 11
0
		void ShowFederationInfo(Federation aFederation)
		{
			LinkMaker lm = new LinkMaker(RootUrl(Request));

			UIResponse.WritePara(UIResponse.Bold("General Federation Information"));
			UIResponse.WriteStartKVTable();
			UIResponse.WriteKVRow("Created", HTMLWriter.Escape(aFederation.Created.ToString()));
			UIResponse.WriteKVRow("Default Namespace", HTMLWriter.Escape(aFederation.DefaultNamespace.ToString()));
			UIResponse.WriteEndKVTable();

			UIResponse.WriteDivider();

			UIResponse.WritePara(UIResponse.Bold("Namespace Information"));

			UITable namespacesTable = new UITable();
			namespacesTable.AddColumn(new UIColumn("Namespace"));
			namespacesTable.AddColumn(new UIColumn("Title"));
			namespacesTable.AddColumn(new UIColumn("Imports"));

			UIResponse.WriteStartTable(namespacesTable);
			foreach (ContentBase each in aFederation.ContentBases)
			{
				UIResponse.WriteStartRow();

				string ns = each.Namespace;
				UIResponse.WriteCell(
					UIResponse.Bold(
						UIResponse.Link(lm.LinkToTopic(new AbsoluteTopicName(each.HomePage, each.Namespace), false), 
							UIResponse.Escape(each.Namespace))));

				UIResponse.WriteCell(HTMLWriter.Escape(each.Title));

				string imports = "";
				foreach (string e in each.ImportedNamespaces)
				{
					if (imports != "")
						imports += ", ";
					imports += e;
				}

				UIResponse.WriteCell(HTMLWriter.Escape(imports));

				UIResponse.WriteEndRow();

			}
			UIResponse.WriteEndTable();
		}
Exemplo n.º 12
0
        public void SetUp()
        {
            /* Set up a mock configuration with the following permissions: 
             * 
             * Wiki-wide: 
             * Alice: read, write, administer
             * Bob: read
             * 
             * NamespaceOne: 
             * Alice: read
             * 
             * NamespaceTwo
             * Bob: read, write, administer
             */
            MockWikiApplication application = new MockWikiApplication(
                null,
                null,
                OutputFormat.HTML,
                new MockTimeProvider(TimeSpan.FromSeconds(1))); 

            _federation = new Federation(application);

            MockAuthorizationConfigurationProvider configProvider = new MockAuthorizationConfigurationProvider();
            configProvider.AddWikiPermission("Alice", Permission.Read);
            configProvider.AddWikiPermission("Alice", Permission.Edit);
            configProvider.AddWikiPermission("Alice", Permission.Administer);
            configProvider.AddWikiPermission("Bob", Permission.Read);
            configProvider.AddWikiPermission("WikiReaders", Permission.Read);
            configProvider.AddWikiPermission("WikiEditors", Permission.Edit);
            configProvider.AddWikiPermission("WikiAdmins", Permission.Administer);

            configProvider.AddNamespacePermission("Alice", "NamespaceOne", Permission.Read);

            configProvider.AddNamespacePermission("Bob", "NamespaceTwo", Permission.Read);
            configProvider.AddNamespacePermission("Bob", "NamespaceTwo", Permission.Edit);
            configProvider.AddNamespacePermission("Bob", "NamespaceTwo", Permission.Administer);

            configProvider.AddNamespacePermission("NS4Readers", "NamespaceFour", Permission.Read);
            configProvider.AddNamespacePermission("NS4Editors", "NamespaceFour", Permission.Edit);
            configProvider.AddNamespacePermission("NS4Admins", "NamespaceFour", Permission.Administer);

            configProvider.AddNamespacePermission("*", "NamespaceFive", Permission.Read);
            configProvider.AddNamespacePermission("?", "NamespaceFive", Permission.Edit);

            _federation.AuthorizationConfigurationProvider = configProvider;
        }
Exemplo n.º 13
0
		[SetUp] public void Init()
		{
			string author = "tester-joebob";
			_lm = new LinkMaker(_bh);
			TheFederation = new Federation(OutputFormat.HTML, _lm);

			_base = CreateStore("FlexWiki.Base");
			_other1 = CreateStore("FlexWiki.Other1");
			_other2 = CreateStore("Other2");
			_other3 = CreateStore("Other3");
			_cb5 = CreateStore("Space5");

			WriteTestTopicAndNewVersion(_base, _base.DefinitionTopicName.Name, @"Import: FlexWiki.Other1, Other2", author);
			WriteTestTopicAndNewVersion(_base, "TopicOne", @"OtherOneHello", author);
			WriteTestTopicAndNewVersion(_base, "TopicTwo", @"FlexWiki.Other1.OtherOneGoodbye", author);
			WriteTestTopicAndNewVersion(_base, "TopicThree", @"No.Such.Namespace.FooBar", author);
			WriteTestTopicAndNewVersion(_base, "TopicFour", @".TopicOne", author);
			WriteTestTopicAndNewVersion(_base, "TopicFive", @"FooBar
Role:Designer", author);
			WriteTestTopicAndNewVersion(_base, "TopicSix", @".GooBar
Role:Developer", author);

			WriteTestTopicAndNewVersion(_other1, _other1.DefinitionTopicName.Name, @"Import: Other3,Other2", author);
			WriteTestTopicAndNewVersion(_other1, "OtherOneHello", @"hello
Role:Developer", author);
			WriteTestTopicAndNewVersion(_other1, "OtherOneGoodbye", @"goodbye", author);
			WriteTestTopicAndNewVersion(_other1, "OtherOneRefThree", @"OtherThreeTest", author);

			WriteTestTopicAndNewVersion(_other1, "OtherOneTopicOne", @"OtherTwoHello", author);
			WriteTestTopicAndNewVersion(_other1, "OtherOneTopicTwo", @"Other2.OtherTwoGoodbye", author);
			WriteTestTopicAndNewVersion(_other1, "OtherOneTopicThree", @"No.Such.Namespace.FooBar", author);
			WriteTestTopicAndNewVersion(_other1, "OtherOneTopicFour", @".OtherOneTopicOne", author);
			WriteTestTopicAndNewVersion(_other1, "OtherOneTopicFive", @"FooBar", author);
			WriteTestTopicAndNewVersion(_other1, "OtherOneTopicSix", @".GooBar", author);

			WriteTestTopicAndNewVersion(_other2, "OtherTwoHello", @"hello", author);
			WriteTestTopicAndNewVersion(_other2, "OtherTwoGoodbye", @"goodbye", author);

			WriteTestTopicAndNewVersion(_other3, "OtherThreeTest", @"yo", author);

			

			WriteTestTopicAndNewVersion(_cb5, "AbsRef", @"Other2.OtherTwoHello", author);

		}
Exemplo n.º 14
0
        public void SetUp()
        {
            _lm = new LinkMaker(_base);
            Federation = new Federation(OutputFormat.HTML, _lm);
            Federation.WikiTalkVersion = 1;
            string ns = "FlexWiki";
            string ns2 = "FlexWiki2";

            _contentStoreManager = WikiTestUtilities.CreateMockStore(Federation, ns);
            _contentStoreManager2 = WikiTestUtilities.CreateMockStore(Federation, ns2);

            WikiTestUtilities.WriteTestTopicAndNewVersion(_contentStoreManager, _contentStoreManager.DefinitionTopicName.Name, "Import: FlexWiki2", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_contentStoreManager, "HomePage", "This is a simple topic RefOne plus PluralWords reference to wiki://PresentIncluder wiki://TestLibrary/foo.gif", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_contentStoreManager2, "AbsentIncluder", "{{NoSuchTopic}}", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_contentStoreManager2, "PresentIncluder", "{{IncludePresent}}", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_contentStoreManager2, "IncludePresent", "hey! this is ReferencedFromIncludePresent", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_contentStoreManager2, "TestLibrary", "URI: whatever", _user);
        }
Exemplo n.º 15
0
		[SetUp] public void Init()
		{
			_lm = new LinkMaker(_base);
			TheFederation = new Federation(OutputFormat.HTML, _lm);
			TheFederation.WikiTalkVersion = 1;
			string ns = "FlexWiki";
			string ns2 = "FlexWiki2";

			_cb = CreateStore(ns);
			_cb2 = CreateStore(ns2);

			WriteTestTopicAndNewVersion(_cb, _cb.DefinitionTopicName.Name, "Import: FlexWiki2", user);
			WriteTestTopicAndNewVersion(_cb, "HomePage", "This is a simple topic RefOne plus PluralWords reference to wiki://PresentIncluder wiki://TestLibrary/foo.gif", user);
			WriteTestTopicAndNewVersion(_cb2, "AbsentIncluder", "{{NoSuchTopic}}", user);
			WriteTestTopicAndNewVersion(_cb2, "PresentIncluder", "{{IncludePresent}}", user);
			WriteTestTopicAndNewVersion(_cb2, "IncludePresent", "hey! this is ReferencedFromIncludePresent", user);
			WriteTestTopicAndNewVersion(_cb2, "TestLibrary", "URI: whatever", user);
		}
        public void Init()
        {
            MockWikiApplication application = new MockWikiApplication(null,
                new LinkMaker("http://boobar"), OutputFormat.HTML,
                new MockTimeProvider(TimeSpan.FromSeconds(1)));
            Federation = new Federation(application);
            _base = WikiTestUtilities.CreateMockStore(Federation, "FlexWiki.Projects.Wiki");
            _imp1 = WikiTestUtilities.CreateMockStore(Federation, "FlexWiki.Projects.Wiki1");
            _imp2 = WikiTestUtilities.CreateMockStore(Federation, "FlexWiki.Projects.Wiki2");

            string author = "tester-joebob";
            WikiTestUtilities.WriteTestTopicAndNewVersion(
                _base,
                _base.DefinitionTopicName.LocalName,
                @"
            Description: Test description
            Import: FlexWiki.Projects.Wiki1, FlexWiki.Projects.Wiki2", author);
        }
Exemplo n.º 17
0
        public void SetUp()
        {
            FederationConfiguration configuration = new FederationConfiguration();
            // Grant everyone full control so we don't have security issues for the test.
            configuration.AuthorizationRules.Add(new WikiAuthorizationRule(
                new AuthorizationRule(new AuthorizationRuleWho(AuthorizationRuleWhoType.GenericAll), AuthorizationRulePolarity.Allow,
                    AuthorizationRuleScope.Wiki, SecurableAction.ManageNamespace, 0)));
            MockWikiApplication application = new MockWikiApplication(
                configuration,
                new LinkMaker("http://boobar"), OutputFormat.HTML,
                new MockTimeProvider(TimeSpan.FromSeconds(1)));
            Federation = new Federation(application);
            _base = WikiTestUtilities.CreateMockStore(Federation, "FlexWiki.Projects.Wiki");
            _imp1 = WikiTestUtilities.CreateMockStore(Federation, "FlexWiki.Projects.Wiki1");
            _imp2 = WikiTestUtilities.CreateMockStore(Federation, "FlexWiki.Projects.Wiki2");

            string author = "tester-joebob";
            WikiTestUtilities.WriteTestTopicAndNewVersion(
                _base,
                _base.DefinitionTopicName.LocalName,
            @"
            Description: Test description
            Import: FlexWiki.Projects.Wiki1",
                author);

            WikiTestUtilities.WriteTestTopicAndNewVersion(
                _imp1,
                _imp1.DefinitionTopicName.LocalName,
            @"
            Description: Test1 description
            Import: FlexWiki.Projects.Wiki2",
                author);

            WikiTestUtilities.WriteTestTopicAndNewVersion(
                _imp2,
                _imp2.DefinitionTopicName.LocalName,
            @"
            Description: Test1 description
            Import: FlexWiki.Projects.Wiki",
                author);
        }
Exemplo n.º 18
0
		[SetUp] public void Init()
		{
			TheFederation = new Federation(OutputFormat.HTML, new LinkMaker("/federationtests/"));
			string author = "tester-joebob";

			_base = CreateStore("FlexWiki.Base"); 

			WriteTestTopicAndNewVersion(_base, "TopicOne", @"Hello there", author);
			WriteTestTopicAndNewVersion(_base, "Versioned", "v1", "tester-bob");
			WriteTestTopicAndNewVersion(_base, "Versioned", "v2", "tester-sally");
			WriteTestTopicAndNewVersion(_base, "TopicTwo", @"Something about TopicOne and more!", author);
			WriteTestTopicAndNewVersion(_base, "Props", @"First: one
Second: two
Third:[ lots
and

lots
]
more stuff
", author);
		}
Exemplo n.º 19
0
        static void Main(string[] args)
        {
            string configPath = Path.Combine(Environment.CurrentDirectory, args[0]);
            string topic = args[1];
            int iterations = 1;
            if (args.Length > 2)
            {
                iterations = int.Parse(args[2]);
            }

            FederationConfiguration federationConfiguration = LoadFederationConfiguration(configPath);
            Console.WriteLine("Loaded configuration");

            RenderDriverApplication application = new RenderDriverApplication(federationConfiguration,
                new LinkMaker("http://localhost/wiki"));
            Federation federation = new Federation(application);
            Console.WriteLine("Created federation");

            Warmup(topic, federation);
            Run(topic, iterations, federation);
            RunWithContext(topic, iterations, federation);
        }
Exemplo n.º 20
0
        internal static Federation SetupFederation(string siteUrl, TestContentSet content, MockSetupOptions options, 
            FederationConfiguration federationConfiguration)
        {
            LinkMaker linkMaker = new LinkMaker(siteUrl);
            MockWikiApplication application = new MockWikiApplication(
                federationConfiguration, 
                linkMaker, 
                OutputFormat.HTML, 
                new MockTimeProvider(TimeSpan.FromSeconds(1)));
            Federation federation = new Federation(application);

            foreach (TestNamespace ns in content.Namespaces)
            {
                NamespaceManager storeManager = CreateMockStore(federation, ns.Name, options, ns.Parameters);

                foreach (TestTopic topic in ns.Topics)
                {
                    WriteTestTopicAndNewVersion(storeManager, topic.Name, topic.Content, topic.Author);
                }
            }

            return federation;

        }
Exemplo n.º 21
0
        public void Init()
        {
            TheFederation = new Federation(OutputFormat.HTML, new LinkMaker("/morecontentbasetests/"));
            _base = CreateStore("FlexWiki.Projects.Wiki");
            _imp1 = CreateStore("FlexWiki.Projects.Wiki1");
            _imp2 = CreateStore("FlexWiki.Projects.Wiki2");

            string author = "tester-joebob";
            WriteTestTopicAndNewVersion(_base, _base.DefinitionTopicName.Name, @"
            Description: Test description
            Import: FlexWiki.Projects.Wiki1, FlexWiki.Projects.Wiki2", author);
        }
Exemplo n.º 22
0
        public void Init()
        {
            string author = "tester-joebob";
            _lm = new LinkMaker("/contentbasetests/");

            TheFederation = new Federation(OutputFormat.HTML, _lm);

            _base = CreateStore("FlexWiki.Base");

            WriteTestTopicAndNewVersion(_base, "TopicOne", @"Hello there", author);
            System.Threading.Thread.Sleep(100); // need the newer one to be newer enough!
            WriteTestTopicAndNewVersion(_base, "TopicOne", @"Hello a", author);
            System.Threading.Thread.Sleep(100); // need the newer one to be newer enough!
            WriteTestTopicAndNewVersion(_base, "TopicOne", @"Hello b", author);
            System.Threading.Thread.Sleep(100); // need the newer one to be newer enough!
            WriteTestTopicAndNewVersion(_base, "TopicOne", @"Hello c", author);

            WriteTestTopicAndNewVersion(_base, "Versioned", "v1", "tester-bob");
            WriteTestTopicAndNewVersion(_base, "Versioned", "v2", "tester-sally");

            WriteTestTopicAndNewVersion(_base, "TopicTwo", @"Something about TopicOne and more!", author);
            WriteTestTopicAndNewVersion(_base, "Props", @"First: one
            Second: two
            Third:[ lots
            and

            lots
            ]
            more stuff
            ", author);
            WriteTestTopicAndNewVersion(_base, "TopicOlder", @"write first", author);
            WriteTestTopicAndNewVersion(_base, "ExternalWikis", @"@wiki1=dozo$$$
            @wiki2=fat$$$", author);
            System.Threading.Thread.Sleep(100); // need the newer one to be newer enough!

            // THIS ONE (TopicNewer) MUST BE WRITTEN LAST!!!!
            WriteTestTopicAndNewVersion(_base, "TopicNewer", @"write last", author);
        }
Exemplo n.º 23
0
 public SqlQueryJobInstaller(Federation federation)
     : base(federation.Context)
 {
     this.federation = federation;
 }
Exemplo n.º 24
0
        public void Federation_ScheduledReloadOfMetadata()
        {
            MetadataRefreshScheduler.minInterval = new TimeSpan(0, 0, 0, 0, 1);

            var subject = new Federation(
                "http://localhost:13428/federationMetadataVeryShortCacheDuration",
                false,
                StubFactory.CreateOptions());

            var initialValidUntil = subject.MetadataValidUntil;

            SpinWaiter.WhileEqual(() => subject.MetadataValidUntil, () => initialValidUntil);
        }
Exemplo n.º 25
0
        public void Federation_ReloadOfMetadata_RetriesAfterFailedInitialLoad()
        {
            MetadataRefreshScheduler.minInterval = new TimeSpan(0, 0, 0, 0, 1);

            StubServer.IdpAndFederationShortCacheDurationAvailable = false;

            var options = StubFactory.CreateOptions();

            var subject = new Federation(
                "http://localhost:13428/federationMetadataVeryShortCacheDuration",
                false,
                options);

            subject.MetadataValidUntil.Should().Be(DateTime.MinValue);

            StubServer.IdpAndFederationShortCacheDurationAvailable = true;

            SpinWaiter.WhileEqual(() => subject.MetadataValidUntil, () => DateTime.MinValue);

            IdentityProvider idp;
            options.IdentityProviders.TryGetValue(new EntityId("http://idp1.federation.example.com/metadata"), out idp)
                .Should().BeTrue();
        }
Exemplo n.º 26
0
        public void Federation_ReloadOfMetadata_RemovesAllIdpsIfMetadataIsNoLongerValid()
        {
            MetadataRefreshScheduler.minInterval = new TimeSpan(0, 0, 0, 0, 1);

            var options = StubFactory.CreateOptions();

            var subject = new Federation(
                "http://localhost:13428/federationMetadataVeryShortCacheDuration",
                false,
                options);

            IdentityProvider idp;
            options.IdentityProviders.TryGetValue(new EntityId("http://idp1.federation.example.com/metadata"), out idp)
                .Should().BeTrue();

            StubServer.IdpAndFederationShortCacheDurationAvailable = false;

            SpinWaiter.WhileNotEqual(() => subject.MetadataValidUntil, () => DateTime.MinValue);

            options.IdentityProviders.TryGetValue(new EntityId("http://idp1.federation.example.com/metadata"), out idp)
                .Should().BeFalse("idp should be removed if metadata is no longer valid");
        }
Exemplo n.º 27
0
        public void Federation_ReloadOfMetadata_KeepsOldDataUntilMetadataBecomesInvalid()
        {
            MetadataRefreshScheduler.minInterval = new TimeSpan(0, 0, 0, 0, 5);

            var options = StubFactory.CreateOptions();

            var subject = new Federation(
                "http://localhost:13428/federationMetadataShortCacheDuration",
                false,
                options);

            IdentityProvider idp;
            options.IdentityProviders.TryGetValue(new EntityId("http://idp1.federation.example.com/metadata"), out idp)
                .Should().BeTrue("idp should be loaded initially");

            var initialValidUntil = subject.MetadataValidUntil;

            StubServer.IdpAndFederationShortCacheDurationAvailable = false;

            // Wait until a failed load has occured.
            SpinWaiter.While(() => subject.LastMetadataLoadException == null,
                "Timeout passed without a failed metadata reload.");

            subject.MetadataValidUntil.Should().NotBe(DateTime.MinValue);

            options.IdentityProviders.TryGetValue(new EntityId("http://idp1.federation.example.com/metadata"), out idp)
                .Should().BeTrue("idp shouldn't be removed while metadata is still valid.");

            SpinWaiter.While(() => subject.MetadataValidUntil != DateTime.MinValue,
                "Timeout passed without metadata becoming invalid.");

            options.IdentityProviders.TryGetValue(new EntityId("http://idp1.federation.example.com/metadata"), out idp)
                .Should().BeFalse("idp should be removed if metadata is no longer valid");

            StubServer.IdpAndFederationShortCacheDurationAvailable = true;

            SpinWaiter.While(() => subject.MetadataValidUntil == DateTime.MinValue,
                "Timeout passed without metadata being successfully reloaded");

            options.IdentityProviders.TryGetValue(new EntityId("http://idp1.federation.example.com/metadata"), out idp)
                .Should().BeTrue("idp should be readded when metadata is refreshed.");
        }
Exemplo n.º 28
0
        public void Federation_ReloadOfMetadata_AddsNewIdpAndRemovesOld()
        {
            MetadataRefreshScheduler.minInterval = new TimeSpan(0, 0, 0, 0, 1);

            var options = StubFactory.CreateOptions();

            var subject = new Federation(
                "http://localhost:13428/federationMetadataVeryShortCacheDuration",
                false,
                options);

            IdentityProvider idp;
            options.IdentityProviders.TryGetValue(new EntityId("http://idp1.federation.example.com/metadata"), out idp)
                .Should().BeTrue("idp1 should be loaded initially");
            options.IdentityProviders.TryGetValue(new EntityId("http://idp2.federation.example.com/metadata"), out idp)
                .Should().BeTrue("idp2 should be loaded initially");
            options.IdentityProviders.TryGetValue(new EntityId("http://idp3.federation.example.com/metadata"), out idp)
                .Should().BeFalse("idp3 shouldn't be loaded initially");

            StubServer.FederationVeryShortCacheDurationSecondAlternativeEnabled = true;
            var initialValidUntil = subject.MetadataValidUntil;
            SpinWaiter.WhileEqual(() => subject.MetadataValidUntil, () => initialValidUntil);

            options.IdentityProviders.TryGetValue(new EntityId("http://idp1.federation.example.com/metadata"), out idp)
                .Should().BeTrue("idp1 should still be present after reload");
            options.IdentityProviders.TryGetValue(new EntityId("http://idp2.federation.example.com/metadata"), out idp)
                .Should().BeFalse("idp2 should be removed after reload");
            options.IdentityProviders.TryGetValue(new EntityId("http://idp3.federation.example.com/metadata"), out idp)
                .Should().BeTrue("idp3 should be loaded after reload");
        }
Exemplo n.º 29
0
        public void Federation_MetadataValidUntil_Loaded()
        {
            var subject = new Federation(
                "http://localhost:13428/federationMetadata",
                false,
                StubFactory.CreateOptions());

            subject.MetadataValidUntil.Should().Be(new DateTime(2100, 01, 01, 14, 43, 15));
        }
Exemplo n.º 30
0
        public void Federation_MetadataValidUntil_CalculatedFromCacheDuration()
        {
            var subject = new Federation(
                "http://localhost:13428/federationMetadataVeryShortCacheDuration",
                false,
                StubFactory.CreateOptions());

            subject.MetadataValidUntil.Should().BeCloseTo(DateTime.UtcNow);
        }
 public static void addFederation(Federation oFederation)
 {
     MySoapServer.MySoapServer SWaddFederation = new MySoapServer.MySoapServer();
     String Response = SWaddFederation.addFederation(oFederation.FederationID.ToString(), oFederation.FederationName, oFederation.FederatedNumber.ToString());
     //Console.ReadKey();
 }
Exemplo n.º 32
0
        public FederatedPegSettings(NodeSettings nodeSettings, CounterChainNetworkWrapper counterChainNetworkWrapper)
        {
            Guard.NotNull(nodeSettings, nameof(nodeSettings));

            TextFileConfiguration configReader = nodeSettings.ConfigReader;

            this.IsMainChain = configReader.GetOrDefault("mainchain", false);
            if (!this.IsMainChain && !configReader.GetOrDefault("sidechain", false))
            {
                throw new ConfigurationException("Either -mainchain or -sidechain must be specified");
            }

            string redeemScriptRaw = configReader.GetOrDefault <string>(RedeemScriptParam, null);

            Console.WriteLine(redeemScriptRaw);

            PayToMultiSigTemplateParameters para = null;

            if (!string.IsNullOrEmpty(redeemScriptRaw))
            {
                var redeemScript = new Script(redeemScriptRaw);
                para = PayToMultiSigTemplate.Instance.ExtractScriptPubKeyParameters(redeemScript) ??
                       PayToFederationTemplate.Instance.ExtractScriptPubKeyParameters(redeemScript, nodeSettings.Network);
            }

            if (para == null)
            {
                string pubKeys = configReader.GetOrDefault <string>(FederationKeysParam, null);
                if (string.IsNullOrEmpty(pubKeys))
                {
                    throw new ConfigurationException($"Either -{RedeemScriptParam} or -{FederationKeysParam} must be specified.");
                }

                para.PubKeys        = pubKeys.Split(",").Select(s => new PubKey(s.Trim())).ToArray();
                para.SignatureCount = (pubKeys.Length + 1) / 2;
            }

            para.SignatureCount = configReader.GetOrDefault(FederationQuorumParam, para.SignatureCount);

            IFederation federation;

            federation = new Federation(para.PubKeys, para.SignatureCount);
            nodeSettings.Network.Federations.RegisterFederation(federation);
            counterChainNetworkWrapper.CounterChainNetwork.Federations.RegisterFederation(federation);

            this.MultiSigRedeemScript = federation.MultisigScript;
            this.MultiSigAddress      = this.MultiSigRedeemScript.Hash.GetAddress(nodeSettings.Network);
            this.MultiSigM            = para.SignatureCount;
            this.MultiSigN            = para.PubKeys.Length;
            this.FederationPublicKeys = para.PubKeys;

            this.PublicKey = configReader.GetOrDefault <string>(PublicKeyParam, null);

            if (this.FederationPublicKeys.All(p => p != new PubKey(this.PublicKey)))
            {
                throw new ConfigurationException("Please make sure the public key passed as parameter was used to generate the multisig redeem script.");
            }

            // Federation IPs - These are required to receive and sign withdrawal transactions.
            string federationIpsRaw = configReader.GetOrDefault <string>(FederationIpsParam, null);

            if (federationIpsRaw == null)
            {
                throw new ConfigurationException("Federation IPs must be specified.");
            }

            IEnumerable <IPEndPoint> endPoints = federationIpsRaw.Split(',').Select(a => a.ToIPEndPoint(nodeSettings.Network.DefaultPort));

            this.FederationNodeIpEndPoints = new HashSet <IPEndPoint>(endPoints, new IPEndPointComparer());
            this.FederationNodeIpAddresses = new HashSet <IPAddress>(endPoints.Select(x => x.Address), new IPAddressComparer());

            // These values are only configurable for tests at the moment. Fed members on live networks shouldn't play with them.
            this.CounterChainDepositStartBlock = configReader.GetOrDefault(CounterChainDepositBlock, 1);

            this.SmallDepositThresholdAmount  = Money.Coins(configReader.GetOrDefault(ThresholdAmountSmallDepositParam, 50));
            this.NormalDepositThresholdAmount = Money.Coins(configReader.GetOrDefault(ThresholdAmountNormalDepositParam, 1000));

            this.MinimumConfirmationsSmallDeposits        = configReader.GetOrDefault(MinimumConfirmationsSmallDepositsParam, 25);
            this.MinimumConfirmationsNormalDeposits       = configReader.GetOrDefault(MinimumConfirmationsNormalDepositsParam, 80);
            this.MinimumConfirmationsLargeDeposits        = (int)nodeSettings.Network.Consensus.MaxReorgLength + 1;
            this.MinimumConfirmationsDistributionDeposits = (int)nodeSettings.Network.Consensus.MaxReorgLength + 1;
            this.MinimumConfirmationsConversionDeposits   = (int)nodeSettings.Network.Consensus.MaxReorgLength + 1;

            this.MaximumPartialTransactionThreshold = configReader.GetOrDefault(MaximumPartialTransactionsParam, CrossChainTransferStore.MaximumPartialTransactions);
            this.WalletSyncFromHeight = configReader.GetOrDefault(WalletSyncFromHeightParam, 0);
        }
Exemplo n.º 33
0
        public void SetUp()
        {
            _lm = new LinkMaker(c_siteUrl);
            FederationConfiguration configuration = new FederationConfiguration();
            AuthorizationRule rule = new AuthorizationRule(new AuthorizationRuleWho(AuthorizationRuleWhoType.GenericAll, null),
                AuthorizationRulePolarity.Allow, AuthorizationRuleScope.Wiki, SecurableAction.ManageNamespace, 0);
            configuration.AuthorizationRules.Add(new WikiAuthorizationRule(rule));
            MockWikiApplication application = new MockWikiApplication(
                configuration,
                _lm,
                OutputFormat.HTML,
                new MockTimeProvider(TimeSpan.FromSeconds(1)));

            Federation = new Federation(application);
            Federation.WikiTalkVersion = 1;

            _namespaceManager = WikiTestUtilities.CreateMockStore(Federation, "FlexWiki");
            //_namespaceManager.Title  = "Friendly Title";

            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "_ContentBaseDefinition", "Title: Friendly Title", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "HomePage", "Home is where the heart is", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "BigPolicy", "This is ", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "BigDog", "This is ", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "BigAddress", "This is ", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "BigBox", "This is ", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "IncludeOne", "inc1", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "IncludeTwo", "!inc2", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "IncludeThree", "!!inc3", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "IncludeFour", "!inc4", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "IncludeNest", @"		{{IncludeNest1}}
            {{IncludeNest2}}", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "TopicWithColor", "Color: Yellow", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "IncludeNest1", "!hey there", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "IncludeNest2", "!black dog", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "IncludeNestURI", @"wiki://IncludeNest1 wiki://IncludeNest2 ", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "ResourceReference", @"URI: http://www.google.com/$$$", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "FlexWiki", "flex ", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "InlineTestTopic", @"aaa @@""foo""@@ zzz", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "OneMinuteWiki", "one ", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "TestIncludesBehaviors", "@@ProductName@@ somthing @@Now@@ then @@Now@@", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "_Underscore", "Underscore", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "TopicWithBehaviorProperties", @"
            Face: {""hello"".Length}
            one
            FaceWithArg: {arg | arg.Length }
            FaceSpanningLines:{ arg |

            arg.Length

            }

            ", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "TestTopicWithBehaviorProperties", @"
            len=@@topics.TopicWithBehaviorProperties.Face@@
            lenWith=@@topics.TopicWithBehaviorProperties.FaceWithArg(""superb"")@@
            lenSpanning=@@topics.TopicWithBehaviorProperties.FaceSpanningLines(""parsing is wonderful"")@@
            ", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "TestTopicWithBehaviorProperty",
            @"lenSpanning=@@topics.TopicWithBehaviorProperties.FaceSpanningLines(""parsing is wonderful"")@@", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "TopicWithInclude", "{{TopicOneNoRead}}", _user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "TopicOneNoRead",
            @"DenyRead: all
            PropertyOne: ValueOne
            PropertyTwo: Value Two
            PropertyOne: List, of, values", _user);

            _externals = new ExternalReferencesMap();
        }
Exemplo n.º 34
0
        //[Test]
        public void GetFederation()
        {
            Federation fed = new Federation();

            Namespace dm = new Namespace
            {
                Id          = 1,
                Prefix      = "dm",
                Uri         = "http://dm.rdlfacade.org/data#",
                Description = "Data Model",
                IsWriteable = false
            };

            Namespace rdl = new Namespace
            {
                Id          = 2,
                Prefix      = "rdl",
                Uri         = "http://rdl.rdlfacade.org/data#",
                Description = "RDL Classes",
                IsWriteable = true,
                IdGenerator = 1
            };

            Namespace tpl = new Namespace
            {
                Id          = 3,
                Prefix      = "tpl",
                Uri         = "http://tpl.rdlfacade.org/data#",
                Description = "RDL Templates",
                IsWriteable = false
            };
            Namespace owl = new Namespace
            {
                Id          = 4,
                Prefix      = "owl",
                Uri         = "http://www.w3.org/2002/07/owl#",
                Description = "w3 owl",
                IsWriteable = false
            };

            Namespace owl2xml = new Namespace
            {
                Id          = 5,
                Prefix      = "owl2xml",
                Uri         = "http://www.w3.org/2006/12/owl2-xml#",
                Description = "w3 owl2 xml",
                IsWriteable = false
            };

            Namespace p8 = new Namespace
            {
                Id          = 6,
                Prefix      = "p8",
                Uri         = "http://standards.tc184-sc4.org/iso/15926/-8/template-model#",
                Description = "ISO15926 Part 8 Classes",
                IsWriteable = false
            };

            Namespace p8dm = new Namespace
            {
                Id          = 7,
                Prefix      = "p8dm",
                Uri         = "http://standards.tc184-sc4.org/iso/15926/-8/data-model#",
                Description = "ISO15926 Part 8 Data Model",
                IsWriteable = false
            };

            Namespace templates = new Namespace
            {
                Id          = 8,
                Prefix      = "templates",
                Uri         = "http://standards.tc184-sc4.org/iso/15926/-8/templates#",
                Description = "ISO15926 Part 8 Templates",
                IsWriteable = false
            };


            Namespace jorddm = new Namespace
            {
                Id          = 9,
                Prefix      = "jorddm",
                Uri         = "http://rds.posccaesar.org/2008/02/OWL/ISO-15926-2_2003#",
                Description = "JORD Data Model",
                IsWriteable = false,
                IdGenerator = 1
            };

            Namespace jordrdl = new Namespace
            {
                Id          = 10,
                Prefix      = "jordrdl",
                Uri         = "http://posccaesar.org/rdl/",
                Description = "JORD RDL CLasses",
                IsWriteable = false
            };

            Namespace jordtpl = new Namespace
            {
                Id          = 11,
                Prefix      = "jordtpl",
                Uri         = "http://posccaesar.org/tpl/",
                Description = "JORD RDL Templates",
                IsWriteable = false
            };

            Repository repo1 = new Repository {
                Id             = 1,
                Name           = "My Private Sandbox",
                RepositoryType = RepositoryType.Part8,
                Uri            = "http://localhost:54321/sandbox/query",
                UpdateUri      = "http://localhost:54321/sandbox/update",
                IsReadOnly     = false,
                Description    = "Development Sandbox"
            };



            IDGenerator idg1 = new IDGenerator
            {
                Id          = 1,
                Name        = "ids-adi.org",
                Description = "IDS-ADI ID Generator",
                Uri         = "https://secure.ids-adi.org/registry"
            };

            Repository repo2 = new Repository
            {
                Id             = 2,
                Name           = "iRING Sandbox",
                RepositoryType = RepositoryType.Camelot,
                Uri            = "http://www.iringsandbox.org/repositories/sandbox/query",
                IsReadOnly     = true,
                Description    = "iRING Sandbox",
            };

            Repository repo3 = new Repository
            {
                Id             = 3,
                Name           = "ReferenceData",
                RepositoryType = RepositoryType.RDSWIP,
                Uri            = "http://rdl.rdlfacade.org/data",
                IsReadOnly     = true,
                Description    = "RDS/WIP Part 4 Reference Data Library"
            };

            Repository repo4 = new Repository
            {
                Id             = 4,
                Name           = "Proto and Initial",
                RepositoryType = RepositoryType.Camelot,
                Uri            = "http://www.iringsandbox.org/repositories/tempInitSet/query",
                IsReadOnly     = true,
                Description    = "RDS/Proto and P7 Initial Set Templates"
            };

            Repository repo5 = new Repository
            {
                Id             = 5,
                Name           = "JORD",
                RepositoryType = RepositoryType.JORD,
                Uri            = "http://posccaesar.org/endpoint/sparql",
                IsReadOnly     = true,
                Description    = "JORD Endpoint"
            };


            fed.IDGenerators.Add(idg1);
            fed.Namespaces.Add(owl);
            fed.Namespaces.Add(owl2xml);
            fed.Namespaces.Add(p8dm);
            fed.Namespaces.Add(p8);
            fed.Namespaces.Add(templates);
            fed.Namespaces.Add(rdl);
            fed.Namespaces.Add(tpl);
            fed.Namespaces.Add(dm);
            fed.Namespaces.Add(jorddm);
            fed.Namespaces.Add(jordrdl);
            fed.Namespaces.Add(jordtpl);

            fed.Repositories.Add(repo1);
            fed.Repositories.Add(repo2);
            fed.Repositories.Add(repo3);
            fed.Repositories.Add(repo4);
            fed.Repositories.Add(repo5);

            Utility.Write <Federation>(fed, "E:\\iring-tools\\branches\\2.4.x\\Tests\\NUnit.Tests\\App_Data\\Federation_Default.xml", true);
        }