public void first_you_need_key_for_a_making_node()
        {
            var nodes = new Nodes(Internet, Settings.BaseUrl);

            var all = nodes.FindAll();

            Assert.That(all.Count, Is.GreaterThan(0), "Expected at least one node");
        }
Example #2
0
        public void you_can_get_the_list_of_available_making_nodes()
        {
            var nodes = new Nodes(Internet, Settings.BaseUrl);

            var all = nodes.FindAll();

            Assert.That(all.Count, Is.GreaterThan(0), "Expected at least one making node to be returned.");
        }
        public void you_can_use_simple_key_authorization()
        {
            var authPolicy = new SimpleKeyAuthorizationPolicy(Settings.SimpleKeyAuthorizationCredential);

            var theInternetWithSimpleKeyAuthorization =  new SystemInternet(authPolicy, new ConsoleLog());

            var nodes = new Nodes(theInternetWithSimpleKeyAuthorization, Settings.BaseUrl);

            Assert.That(nodes.FindAll().Count, Is.GreaterThan(0), "Expected at least one making node to be returned.");
        }
        public void if_you_supply_invalid_credentials_you_get_an_error()
        {
            var authPolicy = new SimpleKeyAuthorizationPolicy(
                new SimpleKeyAuthorizationCredential("xxx_clearly_invalid", "")
            );

            var theInternetWithSimpleKeyAuthorization =  new SystemInternet(authPolicy, new ConsoleLog());

            var nodes = new Nodes(theInternetWithSimpleKeyAuthorization, Settings.BaseUrl);

            var theError = Assert.Throws<Exception>(() => nodes.FindAll());

            Assert.That(theError.Message, Is.StringEnding("The server returned status Unauthorized (401), and error message: \"Unauthorized\""));
        }
Example #5
0
        public void you_can_use_oauth()
        {
            var authPolicy = new OAuthAuthorizationPolicy(
                new MadgexOAuthHeader(
                    new SystemClock(),
                    new SystemNonceFactory()
                ),
                Settings.Credentials
            );

            var theInternetWithOAuth =  new SystemInternet(authPolicy, new ConsoleLog());

            var nodes = new Nodes(theInternetWithOAuth, Settings.BaseUrl);

            Assert.That(nodes.FindAll().Count, Is.GreaterThan(0), "Expected at least one making node to be returned.");
        }
Example #6
0
        public void if_you_supply_invalid_credentials_you_get_an_error()
        {
            var invalidCredentials = new CredentialSet(new Credential("xxx_clearly_invalid", ""));

            var authorizationPolicy = new OAuthAuthorizationPolicy(
                new MadgexOAuthHeader(new SystemClock(), new SystemNonceFactory()),
                invalidCredentials
            );

            var theInternet = new SystemInternet(authorizationPolicy);
            var nodes = new Nodes(theInternet, Settings.BaseUrl);

            var theError = Assert.Throws<Exception>(() => nodes.FindAll());

            Assert.That(theError.Message, Is.StringEnding("The server returned status Unauthorized (401), and error message: \"Invalid OAuth Request\""));
        }
 private string FindFirstNodeKey()
 {
     var nodes = new Nodes(Internet, Settings.BaseUrl).FindAll();
     return nodes[0].Key;
 }