schema.cc 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this
  5. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
  6. #include <config.h>
  7. #include <string>
  8. using namespace std;
  9. namespace isc {
  10. namespace dhcp {
  11. namespace test {
  12. // Connection strings.
  13. // Database: keatest
  14. // Host: localhost
  15. // Username: keatest
  16. // Password: keatest
  17. const char* INVALID_TYPE = "type=unknown";
  18. const char* VALID_NAME = "name=keatest";
  19. const char* INVALID_NAME = "name=invalidname";
  20. const char* VALID_HOST = "host=localhost";
  21. const char* INVALID_HOST = "host=invalidhost";
  22. const char* VALID_USER = "user=keatest";
  23. const char* INVALID_USER = "user=invaliduser";
  24. const char* VALID_PASSWORD = "password=keatest";
  25. const char* INVALID_PASSWORD = "password=invalid";
  26. const char* VALID_TIMEOUT = "connect-timeout=10";
  27. const char* INVALID_TIMEOUT_1 = "connect-timeout=foo";
  28. const char* INVALID_TIMEOUT_2 = "connect-timeout=-17";
  29. const char* VALID_READONLY_DB = "readonly=true";
  30. string connectionString(const char* type, const char* name, const char* host,
  31. const char* user, const char* password, const char* timeout,
  32. const char* readonly_db = NULL) {
  33. const string space = " ";
  34. string result = "";
  35. if (type != NULL) {
  36. result += string(type);
  37. }
  38. if (name != NULL) {
  39. if (! result.empty()) {
  40. result += space;
  41. }
  42. result += string(name);
  43. }
  44. if (host != NULL) {
  45. if (! result.empty()) {
  46. result += space;
  47. }
  48. result += string(host);
  49. }
  50. if (user != NULL) {
  51. if (! result.empty()) {
  52. result += space;
  53. }
  54. result += string(user);
  55. }
  56. if (password != NULL) {
  57. if (! result.empty()) {
  58. result += space;
  59. }
  60. result += string(password);
  61. }
  62. if (timeout != NULL) {
  63. if (! result.empty()) {
  64. result += space;
  65. }
  66. result += string(timeout);
  67. }
  68. if (readonly_db != NULL) {
  69. if (! result.empty()) {
  70. result += space;
  71. }
  72. result += string(readonly_db);
  73. }
  74. return (result);
  75. }
  76. };
  77. };
  78. };