コード例 #1
0
        public void GivenICreateAServerSourceAs(Table table)
        {
            var address = table.Rows[0]["Address"];

            if (address == "http://tst-ci-remote.premier.local:3142")
            {
                declaredDependency = new Depends(Depends.ContainerType.CIRemote);
                address            = "http://" + declaredDependency.Container.IP + ":" + declaredDependency.Container.Port;
            }
            else if (address == "http://wolfs-den.premier.local:3142")
            {
                declaredDependency = new Depends(Depends.ContainerType.AnonymousWarewolf);
                address            = "http://" + declaredDependency.Container.IP + ":" + declaredDependency.Container.Port;
            }
            if (!address.Contains("localhost"))
            {
                var ipAddress = GetIPAddress(address);
                IsServerOnline(ipAddress);
            }
            var authenticationType = table.Rows[0]["AuthenticationType"];

            Enum.TryParse(authenticationType, true, out AuthenticationType result);

            IServerSource serverSource = new ServerSource()
            {
                Address            = address,
                AuthenticationType = result
            };

            ScenarioContext.Current.Add("serverSource", serverSource);
        }
コード例 #2
0
        public void TestConnectionService_Execute_TestInvalid_ExpectInvalid()
        {
            //------------Setup for test--------------------------
            var mock = new Mock <IConnections>();
            var connectionService = new TestConnectionService(mock.Object);
            Dev2JsonSerializer dev2JsonSerializer = new Dev2JsonSerializer();

            mock.Setup(connections => connections.CanConnectToServer(It.IsAny <Connection>()))
            .Returns(new DatabaseValidationResult()
            {
                IsValid      = false,
                ErrorMessage = "error"
            });
            var serializer = new Dev2JsonSerializer();
            //------------Execute Test---------------------------
            var           serverSource = new ServerSource();
            StringBuilder jsonResult   = connectionService.Execute(new Dictionary <string, StringBuilder>()
            {
                { "ServerSource", dev2JsonSerializer.SerializeToBuilder(serverSource) }
            }, null);
            var result = serializer.Deserialize <ExecuteMessage>(jsonResult);

            //------------Assert Results-------------------------
            Assert.IsTrue(result.HasError);
            Assert.AreEqual("error", result.Message.ToString());
        }
コード例 #3
0
        /// <summary>
        /// Enable vanity name servers for the given domain.
        /// Makes a POST request to the Vanity Name Servers resource (domains/{id_or_name}/vanity_name_servers).
        /// </summary>
        /// <remarks>
        /// You may use up to 4 external name servers (ns1 through ns4)
        /// </remarks>
        /// <param name="domain">The domain for which to set the name servers</param>
        /// <param name="server_source">ServerSource ["dnsimple" or "external"]</param>
        /// <param name="name_servers">List of name servers (up to 4) to set for the domain</param>
        public dynamic SetVanityNameServers(string domain, ServerSource server_source, params string[] name_servers)
        {
            Require.Argument("domain", domain);
            if (server_source == ServerSource.External)
            {
                Validate.IsBetween(name_servers.Length, 1, 4);
            }

            var request = new RestRequest(Method.POST)
            {
                RequestFormat = DataFormat.Json,
                Resource = "domains/{domain}/vanity_name_servers"
            };
            request.AddUrlSegment("domain", domain);

            dynamic payload = new ExpandoObject();
            payload.vanity_nameserver_configuration = new ExpandoObject();
            payload.vanity_nameserver_configuration.server_source = server_source.ToString().ToLower();
            if (server_source == ServerSource.External)
            {
                var ns = payload.vanity_nameserver_configuration as IDictionary<string, object>;
                for (var i = 0; i < name_servers.Length; i++)
                {
                    ns.Add("ns" + (i + 1), name_servers[i]);
                }
            }

            request.AddBody(payload);

            return Execute<dynamic>(request);
        }
コード例 #4
0
 public ScriptsUpdate(ServerSource serverSource)
 {
     InitializeComponent();
     //richSql.ActiveViewType = DevExpress.XtraRichEdit.RichEditViewType.Draft;
     richSql.ReplaceService <ISyntaxHighlightService>(new CustomSyntaxHighlightService(richSql.Document));
     this.serverSource = serverSource;
 }
コード例 #5
0
        private void SourceConn_Load(object sender, EventArgs e)
        {
            memConnString.Text = ConnectionHelper.GetSourceConnString();
            txtLogin.Text      = "sa";

            if (cmbServer.Properties.Items.Count == 0)
            {
                if (serverSource == null)
                {
                    tblServer         = new DataTable();
                    tblServer         = SqlDataSourceEnumerator.Instance.GetDataSources();
                    serverSource      = new ServerSource();
                    serverSource.List = new string[tblServer.Rows.Count];

                    for (int i = 0; i < tblServer.Rows.Count; i++)
                    {
                        cmbServer.Properties.Items.Add(tblServer.Rows[i].ItemArray.First().ToString());
                        serverSource.List[i] = tblServer.Rows[i].ItemArray.First().ToString();
                    }
                }
                else
                {
                    for (int i = 0; i < serverSource.List.Count(); i++)
                    {
                        cmbServer.Properties.Items.Add(serverSource.List[i].ToString());
                    }
                }
            }
        }
コード例 #6
0
        public IServerSource FetchSource(Guid resourceID)
        {
            var xaml = _queryProxy.FetchResourceXaml(resourceID);

            var    connection = new Connection(xaml.ToXElement());
            string address    = null;

            if (Uri.TryCreate(connection.Address, UriKind.RelativeOrAbsolute, out Uri uri))
            {
                address = uri.Host;
            }

            var selectedServer = new ServerSource
            {
                Address            = connection.Address,
                ID                 = connection.ResourceID,
                AuthenticationType = connection.AuthenticationType,
                UserName           = connection.UserName,
                Password           = connection.Password,
                ResourcePath       = connection.GetSavePath(),
                ServerName         = address,
                Name               = connection.ResourceName
            };

            return(selectedServer);
        }
コード例 #7
0
        public void ServerSource_TestCommand()
        {
            var serverSource = new ServerSource();

            serverSource.TestCommand = TestCommand;
            Assert.AreEqual(TestCommand, serverSource.TestCommand);
        }
コード例 #8
0
        public void ServerSourceNetworkTest()
        {
            // .NET 3.5 allows Schannel to use SSL 3 and TLS 1.0 by default. Instead of hacking user computer's registry, extend it in runtime.
            // System.Net.SecurityProtocolType lacks appropriate constants prior to .NET 4.5.
            ServicePointManager.SecurityProtocol = (SecurityProtocolType)0x0C00;
            var source = new ResourceRef()
            {
                Uri        = new Uri("https://disco.eduvpn.org/v2/server_list.json"),
                PublicKeys = new MinisignPublicKeyDictionary()
            };

            source.PublicKeys.Add("RWRtBSX1alxyGX+Xn3LuZnWUT0w//B6EmTJvgaAxBMYzlQeI+jdrO6KF");

            // Load list of servers.
            var server_source_json = Xml.Response.Get(source);
            var server_source_ia   = new ServerSource();

            server_source_ia.LoadJSON(server_source_json.Value);

            // Load all servers APIs.
            Parallel.ForEach(server_source_ia.ServerList.Values, srv =>
            {
                var uri_builder   = new UriBuilder(srv.Base);
                uri_builder.Path += "info.json";
                try
                {
                    new Models.InstanceEndpoints().LoadJSON(Xml.Response.Get(uri_builder.Uri).Value);
                }
                catch (AggregateException ex)
                {
                    if (ex.InnerException is WebException ex_web && (ex_web.Status == WebExceptionStatus.ConnectFailure || ex_web.Status == WebExceptionStatus.SecureChannelFailure || ex_web.Status == WebExceptionStatus.Timeout))
                    {
                        // Ignore connection failure WebException(s), as some servers are not publicly available or have other issues.
                    }
コード例 #9
0
        public void ServerSourceTest()
        {
            const string server_source_json = @"{
  ""server_list"": [
    {
                ""server_type"": ""institute_access"",
      ""base_url"": ""https://sunset.nuonet.fr/"",
      ""display_name"": ""CNOUS"",
      ""support_contact"": [
        ""mailto:[email protected]""
      ]
    },
    {
                ""server_type"": ""secure_internet"",
      ""base_url"": ""https://eduvpn.rash.al/"",
      ""country_code"": ""AL"",
      ""support_contact"": [
        ""mailto:[email protected]""
      ]
    }
  ]
}";
            var          server_source_ia   = new ServerSource();

            server_source_ia.LoadJSON(server_source_json);

            var srv = server_source_ia.ServerList[new Uri("https://sunset.nuonet.fr/")];

            Assert.AreEqual(InstanceSourceType.InstituteAccess, srv.Type, "Server type incorrect");
        }
コード例 #10
0
        /// <summary>
        /// Enable vanity name servers for the given domain.
        /// Makes a POST request to the Vanity Name Servers resource (domains/{id_or_name}/vanity_name_servers).
        /// </summary>
        /// <remarks>
        /// You may use up to 4 external name servers (ns1 through ns4)
        /// </remarks>
        /// <param name="domain">The domain for which to set the name servers</param>
        /// <param name="server_source">ServerSource ["dnsimple" or "external"]</param>
        /// <param name="name_servers">List of name servers (up to 4) to set for the domain</param>
        public dynamic SetVanityNameServers(string domain, ServerSource server_source, params string[] name_servers)
        {
            Require.Argument(nameof(domain), domain);
            if (server_source == ServerSource.External)
            {
                Validate.IsBetween(name_servers.Length, 1, 4);
            }

            var request = new RestRequest(Method.POST)
            {
                RequestFormat = DataFormat.Json,
                Resource      = "domains/{domain}/vanity_name_servers"
            };

            request.AddUrlSegment("domain", domain);

            dynamic payload = new ExpandoObject();

            payload.vanity_nameserver_configuration = new ExpandoObject();
            payload.vanity_nameserver_configuration.server_source = server_source.ToString().ToLower();
            if (server_source == ServerSource.External)
            {
                var ns = payload.vanity_nameserver_configuration as IDictionary <string, object>;
                for (var i = 0; i < name_servers.Length; i++)
                {
                    ns.Add("ns" + (i + 1), name_servers[i]);
                }
            }

            request.AddBody(payload);

            return(Execute <dynamic>(request));
        }
コード例 #11
0
        public void ServerSource_ID()
        {
            var testID       = Guid.NewGuid();
            var serverSource = new ServerSource();

            serverSource.ID = testID;

            Assert.AreEqual(testID, serverSource.ID);
        }
コード例 #12
0
        public void ServerSource_ResourcePath()
        {
            var resourcePath = "ResourcePath";
            var serverSource = new ServerSource();

            serverSource.ResourcePath = resourcePath;

            Assert.AreEqual(resourcePath, serverSource.ResourcePath);
        }
コード例 #13
0
 public SourceConn(ref ServerSource serverSource)
 {
     InitializeComponent();
     this.serverSource = serverSource;
     btnOdustani.Appearance.BackColor  = Color.RosyBrown;
     btnOdustani.Appearance.BackColor2 = Color.LightCoral;
     btnOdustani.Appearance.ForeColor  = Color.Maroon;
     btnOdustani.Text = "Zatvori";
 }
コード例 #14
0
        public void ServerSource_UserName()
        {
            var testUserName = "******";
            var serverSource = new ServerSource();

            serverSource.UserName = testUserName;

            Assert.AreEqual(testUserName, serverSource.UserName);
        }
コード例 #15
0
        public void ServerSource_TestMessage()
        {
            var testMessage  = "TestMessage";
            var serverSource = new ServerSource();

            serverSource.TestMessage = testMessage;

            Assert.AreEqual(testMessage, serverSource.TestMessage);
        }
コード例 #16
0
        public void ServerSource_Password()
        {
            var testPassword = "******";
            var serverSource = new ServerSource();

            serverSource.Password = testPassword;

            Assert.AreEqual(testPassword, serverSource.Password);
        }
コード例 #17
0
        public void ServerSource_AuthenticationType()
        {
            var expectedAuthenticationType = AuthenticationType.User;
            var serverSource = new ServerSource();

            serverSource.AuthenticationType = expectedAuthenticationType;

            Assert.AreEqual(expectedAuthenticationType, serverSource.AuthenticationType);
        }
コード例 #18
0
        public void ServerSource_Address()
        {
            var testAddress  = "https://ddkksfsw:3143";
            var serverSource = new ServerSource();

            serverSource.Address = testAddress;

            Assert.AreEqual(testAddress, serverSource.Address);
        }
コード例 #19
0
        public void ServerSource_Equals_OtherIsNull_ReturnFalse()
        {
            //---------------Set up test pack-------------------
            var serverSource = new ServerSource
            {
            };

            //---------------Assert Precondition----------------
            Assert.IsFalse(serverSource.Equals(null), "Equals operator can't compare to null.");
        }
コード例 #20
0
        public void Connect(ServerSource server = ServerSource.Test)
        {
            _Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            _Socket.Connect("livedata.americascup.com", (int)server);

            _Stream = new NetworkStream(_Socket, System.IO.FileAccess.Read);

            Action<byte[]> fillbuffer = b =>
            {
                int total = 0, read = 0;
                while ((read = _Stream.Read(b, total, b.Length - total)) > 0)
                {
                    total += read;
                }
            };

            Action receive = null;
            receive = new Action(() =>
             {
                 var header = new byte[15];
                 fillbuffer(header);

                 var c = BitConverter.ToUInt16(header, 13);
                 var body = new byte[c];
                 fillbuffer(body);

                 var crc = new byte[4];
                 fillbuffer(crc);

            #if DEBUG
                 if (header[0] != 0x47 || header[1] != 0x83)
                     Debug.WriteLine("Invalid message header");

                 uint cm = BitConverter.ToUInt32(crc, 0);
                 uint c1 = Crc32.Compute(header.Concat(body).ToArray());

                 if (c1 != cm)
                 {
                     Debug.WriteLine(string.Format("CRC check failed: {1} in message vs. {0} calculated", c1, cm));
                     string sheader = string.Join(" ", header.Select(b => b.ToString("X2")));
                     string sbody = string.Join(" ", body.Select(b => b.ToString("X2")));
                     string scrc = string.Join(" ", crc.Select(b => b.ToString("X2")));
                     Debug.Write(string.Format("Header: {0}\nBody: {1}\nCRC: {2}\n", sheader, sbody, scrc));
                 }
            #endif
                 Task.Factory.StartNew(() =>
                 {
                     if (OnMessage != null) OnMessage(header, body, crc);
                     Task.Factory.StartNew(receive);
                 });
             });

            Task.Factory.StartNew(receive);
        }
コード例 #21
0
        public void ServerSource_IServerSource_Equals_ReturnFalse_OtherIsNull()
        {
            //---------------Set up test pack-------------------
            IServerSource serverSource = new ServerSource
            {
                Address            = "http://test.com",
                AuthenticationType = AuthenticationType.Public,
                UserName           = "******",
                Password           = "******",
                Name = "nameTest"
            };

            //---------------Assert Precondition----------------
            Assert.IsFalse(serverSource.Equals(null));
        }
コード例 #22
0
        public void GivenICreateAServerSourceAs(Table table)
        {
            var address            = table.Rows[0]["Address"];
            var authenticationType = table.Rows[0]["AuthenticationType"];

            Enum.TryParse(authenticationType, true, out AuthenticationType result);

            IServerSource serverSource = new ServerSource()
            {
                Address            = address,
                AuthenticationType = result
            };

            ScenarioContext.Current.Add("serverSource", serverSource);
        }
コード例 #23
0
        public void GivenICreateAServerSourceAs(Table table)
        {
            var address = table.Rows[0]["Address"];

            if (!address.Contains("localhost"))
            {
                var ipAddress = GetIPAddress(address);
                IsServerOnline(ipAddress);
            }
            var authenticationType = table.Rows[0]["AuthenticationType"];

            Enum.TryParse(authenticationType, true, out AuthenticationType result);

            IServerSource serverSource = new ServerSource()
            {
                Address            = address,
                AuthenticationType = result
            };

            ScenarioContext.Current.Add("serverSource", serverSource);
        }
コード例 #24
0
        public void ServerSource_IServerSource_Equals_ReturnTrue()
        {
            //---------------Set up test pack-------------------
            IServerSource serverSource = new ServerSource
            {
                Address            = "http://test.com",
                AuthenticationType = AuthenticationType.User,
                UserName           = "******",
                Password           = "******",
                Name = "nameTest"
            };
            IServerSource otherServerSource = new ServerSource
            {
                Address            = "http://test.com",
                AuthenticationType = AuthenticationType.User,
                UserName           = "******",
                Password           = "******",
                Name = "nameTest"
            };

            //---------------Assert Precondition----------------
            Assert.IsTrue(serverSource.Equals(otherServerSource));
        }
コード例 #25
0
        public void ServerSource_Equals_ReturnFalse_AddressNotEqual()
        {
            //---------------Set up test pack-------------------
            var serverSource = new ServerSource
            {
                Address            = "http://test.com",
                AuthenticationType = AuthenticationType.Public,
                UserName           = "******",
                Password           = "******",
                Name = "nameTest"
            };
            var otherServerSource = new ServerSource
            {
                Address            = "http://test-wrong.com",
                AuthenticationType = AuthenticationType.User,
                UserName           = "******",
                Password           = "******",
                Name = "nameTest"
            };

            //---------------Assert Precondition----------------
            Assert.IsFalse(serverSource.Equals(otherServerSource));
        }
コード例 #26
0
 public DestinationConn(ref ServerSource serverSource)
 {
     InitializeComponent();
     this.serverSource = serverSource;
 }