Пример #1
0
        public void DifferentCases_DictionaryKeyEquality()
        {
            var Lookup = new Dictionary <HTTPCookieName, String> {
                { HTTPCookieName.Parse("abc01"), "DifferentCases_DictionaryKeyEquality()" }
            };

            Assert.IsTrue(Lookup.ContainsKey(HTTPCookieName.Parse("abc01")));
        }
Пример #2
0
        public void Combine()
        {
            var cookie1 = HTTPCookieName.Parse("abc");
            var cookie2 = HTTPCookieName.Parse("def");
            var text    = "123";

            Assert.AreEqual("abcdef", cookie1 + cookie2);
            Assert.AreEqual("abc123", cookie1 + text);
            Assert.AreEqual("123def", text + cookie2);
        }
Пример #3
0
        /// <summary>
        /// Create an instance of the Open Charging Cloud API.
        /// </summary>
        /// <param name="ServiceName">The name of the service.</param>
        /// <param name="HTTPServerName">The default HTTP servername, used whenever no HTTP Host-header had been given.</param>
        /// <param name="LocalHostname">The HTTP hostname for all URIs within this API.</param>
        /// <param name="LocalPort">A TCP port to listen on.</param>
        /// <param name="ExternalDNSName">The offical URL/DNS name of this service, e.g. for sending e-mails.</param>
        /// <param name="URLPathPrefix">A common prefix for all URLs.</param>
        ///
        /// <param name="ServerCertificateSelector">An optional delegate to select a SSL/TLS server certificate.</param>
        /// <param name="ClientCertificateValidator">An optional delegate to verify the SSL/TLS client certificate used for authentication.</param>
        /// <param name="ClientCertificateSelector">An optional delegate to select the SSL/TLS client certificate used for authentication.</param>
        /// <param name="AllowedTLSProtocols">The SSL/TLS protocol(s) allowed for this connection.</param>
        ///
        /// <param name="APIEMailAddress">An e-mail address for this API.</param>
        /// <param name="APIPassphrase">A GPG passphrase for this API.</param>
        /// <param name="APIAdminEMails">A list of admin e-mail addresses.</param>
        /// <param name="APISMTPClient">A SMTP client for sending e-mails.</param>
        ///
        /// <param name="SMSAPICredentials">The credentials for the SMS API.</param>
        /// <param name="SMSSenderName">The (default) SMS sender name.</param>
        /// <param name="APIAdminSMS">A list of admin SMS phonenumbers.</param>
        ///
        /// <param name="TelegramBotToken">The Telegram API access token of the bot.</param>
        ///
        /// <param name="CookieName">The name of the HTTP Cookie for authentication.</param>
        /// <param name="UseSecureCookies">Force the web browser to send cookies only via HTTPS.</param>
        /// <param name="Language">The main language of the API.</param>
        /// <param name="NewUserSignUpEMailCreator">A delegate for sending a sign-up e-mail to a new user.</param>
        /// <param name="NewUserWelcomeEMailCreator">A delegate for sending a welcome e-mail to a new user.</param>
        /// <param name="ResetPasswordEMailCreator">A delegate for sending a reset password e-mail to a user.</param>
        /// <param name="PasswordChangedEMailCreator">A delegate for sending a password changed e-mail to a user.</param>
        /// <param name="MinUserNameLength">The minimal user name length.</param>
        /// <param name="MinRealmLength">The minimal realm length.</param>
        /// <param name="PasswordQualityCheck">A delegate to ensure a minimal password quality.</param>
        /// <param name="SignInSessionLifetime">The sign-in session lifetime.</param>
        ///
        /// <param name="ServerThreadName">The optional name of the TCP server thread.</param>
        /// <param name="ServerThreadPriority">The optional priority of the TCP server thread.</param>
        /// <param name="ServerThreadIsBackground">Whether the TCP server thread is a background thread or not.</param>
        /// <param name="ConnectionIdBuilder">An optional delegate to build a connection identification based on IP socket information.</param>
        /// <param name="ConnectionThreadsNameBuilder">An optional delegate to set the name of the TCP connection threads.</param>
        /// <param name="ConnectionThreadsPriorityBuilder">An optional delegate to set the priority of the TCP connection threads.</param>
        /// <param name="ConnectionThreadsAreBackground">Whether the TCP connection threads are background threads or not (default: yes).</param>
        /// <param name="ConnectionTimeout">The TCP client timeout for all incoming client connections in seconds (default: 30 sec).</param>
        /// <param name="MaxClientConnections">The maximum number of concurrent TCP client connections (default: 4096).</param>
        ///
        /// <param name="SkipURLTemplates">Skip URI templates.</param>
        /// <param name="DisableNotifications">Disable external notifications.</param>
        /// <param name="DisableLogfile">Disable the log file.</param>
        /// <param name="LoggingPath">The path for all logfiles.</param>
        /// <param name="LogfileName">The name of the logfile for this API.</param>
        /// <param name="DNSClient">The DNS client of the API.</param>
        /// <param name="Autostart">Whether to start the API automatically.</param>
        public OpenChargingCloudCSOAPI(String ServiceName         = "GraphDefined Open Charging Cloud CSO API",
                                       String HTTPServerName      = "GraphDefined Open Charging Cloud CSO API",
                                       HTTPHostname?LocalHostname = null,
                                       IPPort?LocalPort           = null,
                                       String ExternalDNSName     = null,
                                       HTTPPath?URLPathPrefix     = null,
                                       String HTMLTemplate        = null,
                                       JObject APIVersionHashes   = null,

                                       ServerCertificateSelectorDelegate ServerCertificateSelector    = null,
                                       RemoteCertificateValidationCallback ClientCertificateValidator = null,
                                       LocalCertificateSelectionCallback ClientCertificateSelector    = null,
                                       SslProtocols AllowedTLSProtocols = SslProtocols.Tls12,

                                       EMailAddress APIEMailAddress    = null,
                                       String APIPassphrase            = null,
                                       EMailAddressList APIAdminEMails = null,
                                       SMTPClient APISMTPClient        = null,

                                       Credentials SMSAPICredentials         = null,
                                       String SMSSenderName                  = null,
                                       IEnumerable <PhoneNumber> APIAdminSMS = null,

                                       String TelegramBotToken = null,

                                       HTTPCookieName?CookieName = null,
                                       Boolean UseSecureCookies  = true,
                                       Languages?Language        = null,
                                       NewUserSignUpEMailCreatorDelegate NewUserSignUpEMailCreator     = null,
                                       NewUserWelcomeEMailCreatorDelegate NewUserWelcomeEMailCreator   = null,
                                       ResetPasswordEMailCreatorDelegate ResetPasswordEMailCreator     = null,
                                       PasswordChangedEMailCreatorDelegate PasswordChangedEMailCreator = null,
                                       Byte?MinLoginLength    = null,
                                       Byte?MinRealmLength    = null,
                                       Byte?MinUserNameLength = null,
                                       PasswordQualityCheckDelegate PasswordQualityCheck = null,
                                       TimeSpan?SignInSessionLifetime = null,

                                       String ServerThreadName                 = null,
                                       ThreadPriority ServerThreadPriority     = ThreadPriority.AboveNormal,
                                       Boolean ServerThreadIsBackground        = true,
                                       ConnectionIdBuilder ConnectionIdBuilder = null,
                                       ConnectionThreadsNameBuilder ConnectionThreadsNameBuilder         = null,
                                       ConnectionThreadsPriorityBuilder ConnectionThreadsPriorityBuilder = null,
                                       Boolean ConnectionThreadsAreBackground = true,
                                       TimeSpan?ConnectionTimeout             = null,
                                       UInt32 MaxClientConnections            = TCPServer.__DefaultMaxClientConnections,

                                       TimeSpan?MaintenanceEvery       = null,
                                       Boolean DisableMaintenanceTasks = false,

                                       Boolean SkipURLTemplates     = false,
                                       Boolean DisableNotifications = false,
                                       Boolean DisableLogfile       = false,
                                       String DatabaseFile          = DefaultOpenChargingCloudAPIDatabaseFile,
                                       String LoggingPath           = null,
                                       String LogfileName           = DefaultOpenChargingCloudAPILogFile,
                                       DNSClient DNSClient          = null,
                                       Boolean Autostart            = false)

            : base(ServiceName ?? "GraphDefined Open Charging Cloud CSO API",
                   HTTPServerName ?? "GraphDefined Open Charging Cloud CSO API",
                   LocalHostname,
                   LocalPort,
                   ExternalDNSName,
                   URLPathPrefix,
                   HTMLTemplate,
                   APIVersionHashes,

                   ServerCertificateSelector,
                   ClientCertificateValidator,
                   ClientCertificateSelector,
                   AllowedTLSProtocols,

                   APIEMailAddress,
                   APIPassphrase,
                   APIAdminEMails,
                   APISMTPClient,

                   SMSAPICredentials,
                   SMSSenderName ?? "Open Charging Cloud",
                   APIAdminSMS,

                   TelegramBotToken,

                   CookieName ?? HTTPCookieName.Parse("OpenChargingCloudCSOAPI"),
                   UseSecureCookies,
                   Language,
                   NewUserSignUpEMailCreator,
                   NewUserWelcomeEMailCreator,
                   ResetPasswordEMailCreator,
                   PasswordChangedEMailCreator,
                   MinLoginLength,
                   MinRealmLength,
                   MinUserNameLength,
                   PasswordQualityCheck,
                   SignInSessionLifetime,

                   ServerThreadName,
                   ServerThreadPriority,
                   ServerThreadIsBackground,
                   ConnectionIdBuilder,
                   ConnectionThreadsNameBuilder,
                   ConnectionThreadsPriorityBuilder,
                   ConnectionThreadsAreBackground,
                   ConnectionTimeout,
                   MaxClientConnections,

                   MaintenanceEvery,
                   DisableMaintenanceTasks,

                   SkipURLTemplates,
                   DisableNotifications,
                   DisableLogfile,
                   DatabaseFile ?? DefaultOpenChargingCloudCSOAPIDatabaseFile,
                   LoggingPath ?? "default",
                   LogfileName ?? DefaultOpenChargingCloudCSOAPILogFile,
                   DNSClient,
                   false)

        {
            //RegisterURLTemplates();

            if (Autostart)
            {
                Start();
            }
        }
Пример #4
0
 public void Equality()
 {
     Assert.AreEqual(HTTPCookieName.Parse("abc"), HTTPCookieName.Parse("abc"));
     Assert.IsTrue(HTTPCookieName.Parse("abc").Equals(HTTPCookieName.Parse("abc")));
 }
Пример #5
0
 public void Length()
 {
     Assert.AreEqual(3, HTTPCookieName.Parse("abc").Length);
 }
Пример #6
0
 public void Parse_Whitespace()
 {
     Assert.Throws <ArgumentNullException>(() => HTTPCookieName.Parse("   "));
 }
Пример #7
0
 public void Parse_Null()
 {
     Assert.Throws <ArgumentNullException>(() => HTTPCookieName.Parse(null));
 }
Пример #8
0
 public void Test_ToString()
 {
     Assert.AreEqual("abc", HTTPCookieName.Parse("abc").ToString());
     Assert.AreEqual("aBc", HTTPCookieName.Parse("aBc").ToString());
 }
Пример #9
0
 public void HashCodeEquality()
 {
     Assert.AreEqual(HTTPCookieName.Parse("abc").GetHashCode(), HTTPCookieName.Parse("abc").GetHashCode());
     Assert.AreNotEqual(HTTPCookieName.Parse("abc").GetHashCode(), HTTPCookieName.Parse("abc2").GetHashCode());
 }
Пример #10
0
 public void OperatorBiggerOrEquals()
 {
     Assert.IsTrue(HTTPCookieName.Parse("abc") >= HTTPCookieName.Parse("abc"));
     Assert.IsTrue(HTTPCookieName.Parse("abc2") >= HTTPCookieName.Parse("abc"));
 }
Пример #11
0
 public void OperatorBigger()
 {
     Assert.IsFalse(HTTPCookieName.Parse("abc") > HTTPCookieName.Parse("abc"));
     Assert.IsTrue(HTTPCookieName.Parse("abc2") > HTTPCookieName.Parse("abc"));
 }
Пример #12
0
 public void OperatorSmaller()
 {
     Assert.IsFalse(HTTPCookieName.Parse("abc") < HTTPCookieName.Parse("abc"));
     Assert.IsTrue(HTTPCookieName.Parse("abc") < HTTPCookieName.Parse("abc2"));
 }
Пример #13
0
 public void OperatorInequality()
 {
     Assert.IsFalse(HTTPCookieName.Parse("abc") != HTTPCookieName.Parse("abc"));
 }
Пример #14
0
 public void OperatorEquality()
 {
     Assert.IsTrue(HTTPCookieName.Parse("abc") == HTTPCookieName.Parse("abc"));
 }