arel_extensions 1.3.9 → 2.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +2 -1
  3. data/.gitignore +6 -7
  4. data/.rubocop.yml +3 -67
  5. data/.travis/oracle/download.js +152 -0
  6. data/.travis/oracle/download.sh +30 -0
  7. data/.travis/oracle/download_ojdbc.js +116 -0
  8. data/.travis/oracle/install.sh +34 -0
  9. data/.travis/setup_accounts.sh +9 -0
  10. data/.travis/sqlite3/extension-functions.sh +6 -0
  11. data/.travis.yml +223 -0
  12. data/Gemfile +21 -16
  13. data/README.md +90 -282
  14. data/Rakefile +30 -48
  15. data/TODO +1 -0
  16. data/appveyor.yml +22 -60
  17. data/arel_extensions.gemspec +14 -13
  18. data/functions.html +3 -3
  19. data/gemfiles/rails3.gemfile +10 -10
  20. data/gemfiles/rails4.gemfile +29 -0
  21. data/gemfiles/rails5_0.gemfile +29 -0
  22. data/gemfiles/rails5_1_4.gemfile +14 -14
  23. data/gemfiles/rails5_2.gemfile +14 -16
  24. data/init/mssql.sql +4 -4
  25. data/init/mysql.sql +38 -38
  26. data/init/oracle.sql +0 -0
  27. data/init/postgresql.sql +21 -21
  28. data/init/sqlite.sql +0 -0
  29. data/lib/arel_extensions/attributes.rb +3 -4
  30. data/lib/arel_extensions/boolean_functions.rb +14 -53
  31. data/lib/arel_extensions/common_sql_functions.rb +17 -16
  32. data/lib/arel_extensions/comparators.rb +28 -27
  33. data/lib/arel_extensions/date_duration.rb +13 -17
  34. data/lib/arel_extensions/insert_manager.rb +15 -18
  35. data/lib/arel_extensions/math.rb +53 -55
  36. data/lib/arel_extensions/math_functions.rb +39 -46
  37. data/lib/arel_extensions/nodes/abs.rb +1 -0
  38. data/lib/arel_extensions/nodes/blank.rb +2 -1
  39. data/lib/arel_extensions/nodes/case.rb +19 -20
  40. data/lib/arel_extensions/nodes/cast.rb +8 -10
  41. data/lib/arel_extensions/nodes/ceil.rb +1 -1
  42. data/lib/arel_extensions/nodes/coalesce.rb +4 -3
  43. data/lib/arel_extensions/nodes/collate.rb +10 -9
  44. data/lib/arel_extensions/nodes/concat.rb +18 -9
  45. data/lib/arel_extensions/nodes/date_diff.rb +26 -42
  46. data/lib/arel_extensions/nodes/duration.rb +3 -0
  47. data/lib/arel_extensions/nodes/find_in_set.rb +1 -0
  48. data/lib/arel_extensions/nodes/floor.rb +1 -1
  49. data/lib/arel_extensions/nodes/format.rb +8 -35
  50. data/lib/arel_extensions/nodes/formatted_number.rb +23 -22
  51. data/lib/arel_extensions/nodes/function.rb +37 -42
  52. data/lib/arel_extensions/nodes/is_null.rb +0 -0
  53. data/lib/arel_extensions/nodes/json.rb +39 -52
  54. data/lib/arel_extensions/nodes/length.rb +0 -5
  55. data/lib/arel_extensions/nodes/levenshtein_distance.rb +1 -1
  56. data/lib/arel_extensions/nodes/locate.rb +2 -1
  57. data/lib/arel_extensions/nodes/log10.rb +2 -1
  58. data/lib/arel_extensions/nodes/matches.rb +7 -5
  59. data/lib/arel_extensions/nodes/md5.rb +1 -0
  60. data/lib/arel_extensions/nodes/power.rb +5 -5
  61. data/lib/arel_extensions/nodes/rand.rb +1 -0
  62. data/lib/arel_extensions/nodes/repeat.rb +5 -3
  63. data/lib/arel_extensions/nodes/replace.rb +8 -16
  64. data/lib/arel_extensions/nodes/round.rb +6 -5
  65. data/lib/arel_extensions/nodes/soundex.rb +15 -15
  66. data/lib/arel_extensions/nodes/std.rb +21 -18
  67. data/lib/arel_extensions/nodes/substring.rb +16 -8
  68. data/lib/arel_extensions/nodes/then.rb +1 -1
  69. data/lib/arel_extensions/nodes/trim.rb +6 -4
  70. data/lib/arel_extensions/nodes/union.rb +8 -5
  71. data/lib/arel_extensions/nodes/union_all.rb +7 -4
  72. data/lib/arel_extensions/nodes/wday.rb +4 -0
  73. data/lib/arel_extensions/nodes.rb +1 -1
  74. data/lib/arel_extensions/null_functions.rb +5 -19
  75. data/lib/arel_extensions/predications.rb +43 -44
  76. data/lib/arel_extensions/railtie.rb +5 -5
  77. data/lib/arel_extensions/set_functions.rb +7 -5
  78. data/lib/arel_extensions/string_functions.rb +29 -59
  79. data/lib/arel_extensions/tasks.rb +6 -6
  80. data/lib/arel_extensions/version.rb +1 -1
  81. data/lib/arel_extensions/visitors/ibm_db.rb +31 -24
  82. data/lib/arel_extensions/visitors/mssql.rb +180 -375
  83. data/lib/arel_extensions/visitors/mysql.rb +212 -350
  84. data/lib/arel_extensions/visitors/oracle.rb +178 -220
  85. data/lib/arel_extensions/visitors/oracle12.rb +31 -18
  86. data/lib/arel_extensions/visitors/postgresql.rb +173 -256
  87. data/lib/arel_extensions/visitors/sqlite.rb +126 -140
  88. data/lib/arel_extensions/visitors/to_sql.rb +237 -298
  89. data/lib/arel_extensions/visitors.rb +58 -82
  90. data/lib/arel_extensions.rb +31 -202
  91. data/test/database.yml +7 -15
  92. data/test/helper.rb +18 -0
  93. data/test/real_db_test.rb +116 -105
  94. data/test/support/fake_record.rb +3 -3
  95. data/test/test_comparators.rb +17 -14
  96. data/test/visitors/test_bulk_insert_oracle.rb +11 -11
  97. data/test/visitors/test_bulk_insert_sqlite.rb +13 -12
  98. data/test/visitors/test_bulk_insert_to_sql.rb +13 -11
  99. data/test/visitors/test_oracle.rb +55 -55
  100. data/test/visitors/test_to_sql.rb +226 -419
  101. data/test/with_ar/all_agnostic_test.rb +365 -709
  102. data/test/with_ar/insert_agnostic_test.rb +21 -27
  103. data/test/with_ar/test_bulk_sqlite.rb +16 -17
  104. data/test/with_ar/test_math_sqlite.rb +26 -26
  105. data/test/with_ar/test_string_mysql.rb +33 -31
  106. data/test/with_ar/test_string_sqlite.rb +34 -30
  107. metadata +34 -37
  108. data/.github/workflows/publish.yml +0 -29
  109. data/.github/workflows/release.yml +0 -30
  110. data/.github/workflows/ruby.yml +0 -345
  111. data/NEWS.md +0 -62
  112. data/bin/build +0 -15
  113. data/bin/publish +0 -8
  114. data/dev/compose.yaml +0 -29
  115. data/gemfiles/rails4_2.gemfile +0 -38
  116. data/gemfiles/rails5.gemfile +0 -29
  117. data/gemfiles/rails6.gemfile +0 -30
  118. data/gemfiles/rails6_1.gemfile +0 -30
  119. data/gemfiles/rails7.gemfile +0 -23
  120. data/gemfiles/rails7_1.gemfile +0 -22
  121. data/gemspecs/arel_extensions-v1.gemspec +0 -27
  122. data/gemspecs/arel_extensions-v2.gemspec +0 -27
  123. data/generate_gems.sh +0 -15
  124. data/lib/arel_extensions/aliases.rb +0 -14
  125. data/lib/arel_extensions/helpers.rb +0 -57
  126. data/lib/arel_extensions/nodes/aggregate_function.rb +0 -13
  127. data/lib/arel_extensions/nodes/formatted_date.rb +0 -42
  128. data/lib/arel_extensions/nodes/rollup.rb +0 -36
  129. data/lib/arel_extensions/nodes/select.rb +0 -10
  130. data/lib/arel_extensions/nodes/sum.rb +0 -7
  131. data/lib/arel_extensions/visitors/convert_format.rb +0 -37
  132. data/test/arelx_test_helper.rb +0 -67
  133. data/version_v1.rb +0 -3
  134. data/version_v2.rb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 297d1d9b84e726d164e0e001cbe2402c81f3cb1491aa15f10854e508a65d0a8b
4
- data.tar.gz: 23697fa470d0524218097318b9f89a0d78e029e16bdeac5e23b24b6610369f6e
3
+ metadata.gz: 66c2dbd555cb0f702ba816dfd15143d1206667a52d3e9ef531837cede739ce1b
4
+ data.tar.gz: 7bddb377ad0a827d95a9b1a6d0dbedf2a60edcacb65a7ca485b341dedeced96b
5
5
  SHA512:
6
- metadata.gz: 2e4bffd39e53121a46cf1aacc279747aae8e44119c6cdb3eba1e633e823ee2b3c13596f20139799be6a2ef619b7394aa1e0659569b63643bf08a8516777c84ac
7
- data.tar.gz: 1dc5fadc6064410bff969f77ab61b52308b0c60b2a2009868a40a6055b4194440763fd82a409c9a1b05911106b863ca1cc94066d954db0faf895caa7ce5516ed
6
+ metadata.gz: 28b4685b962e6e2d608ed3e0a482a9ee2af533d8529438223caed947e07dbc286238c510b897b0c090e4abcb968261cc660a42929a909ddd21950c375669b2df
7
+ data.tar.gz: 5cd46969679f69c1dcc67c18c8f184c17f14f269e6e4de1e4ebd1c048a0e8844d9d25ef9c44c359534346f1b9439b1ee24b08497f434f8bf9bab07d461ca2a33
data/.codeclimate.yml CHANGED
@@ -21,4 +21,5 @@ ratings:
21
21
  - "**.rb"
22
22
  - "**.md"
23
23
  exclude_paths:
24
- - test/**/*
24
+ - .travis/**/*
25
+ - test/**/*
data/.gitignore CHANGED
@@ -1,10 +1,9 @@
1
- *.DS_Store
2
- *.swp
3
- .bundle
4
- Gemfile.lock
5
- config/database.yml
6
1
  coverage/*
2
+ config/database.yml
3
+ spec/support/fixtures/*database*
4
+ *.DS_Store
7
5
  debug.log
8
6
  pkg
9
- spec/support/fixtures/*database*
10
- vendor/
7
+ .bundle
8
+ *.swp
9
+ Gemfile.lock
data/.rubocop.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  AllCops:
2
2
  DisabledByDefault: true
3
3
  Exclude:
4
- - "vendor/**/*"
4
+ - "test/**/*"
5
5
 
6
6
  Layout/EndOfLine:
7
7
  Enabled: true
@@ -9,32 +9,10 @@ Layout/EndOfLine:
9
9
  Layout/ExtraSpacing:
10
10
  Enabled: true
11
11
 
12
- Layout/IndentationWidth:
13
- Enabled: true
14
-
15
- Layout/LineLength:
16
- Enabled: false
17
-
18
- Layout/SpaceAfterComma:
19
- Enabled: true
20
-
21
12
  Layout/SpaceAroundEqualsInParameterDefault:
22
13
  Enabled: true
23
14
 
24
- Layout/SpaceAroundOperators:
25
- Enabled: true
26
-
27
- Layout/SpaceInsideHashLiteralBraces:
28
- Enabled: true
29
- EnforcedStyle: no_space
30
-
31
- Layout/TrailingEmptyLines:
32
- Enabled: true
33
-
34
- Metrics/BlockLength:
35
- Enabled: false
36
-
37
- Naming/FileName:
15
+ Layout/TrailingBlankLines:
38
16
  Enabled: true
39
17
 
40
18
  Style/CollectionMethods:
@@ -55,56 +33,14 @@ Style/EmptyElse:
55
33
  Style/Encoding:
56
34
  Enabled: true
57
35
 
58
- Style/HashSyntax:
36
+ Style/FileName:
59
37
  Enabled: true
60
- EnforcedStyle: ruby19
61
38
 
62
39
  Style/MethodCallWithArgsParentheses:
63
40
  Enabled: false
64
41
 
65
- Style/MethodCallWithoutArgsParentheses:
66
- Enabled: true
67
-
68
- Style/NegatedIf:
69
- Enabled: false
70
-
71
- Style/NumericLiterals:
72
- Enabled: true
73
-
74
- Style/RedundantParentheses:
75
- Enabled: true
76
-
77
- Style/RedundantRegexpCharacterClass:
78
- Enabled: true
79
-
80
- Style/RedundantReturn:
81
- Enabled: true
82
-
83
- # Even when conservative, this is unsafe.
84
- #Style/StringConcatenation:
85
- # Enabled: true
86
- # Mode: 'conservative'
87
-
88
- Style/StringLiterals:
89
- Enabled: true
90
-
91
- Style/SymbolArray:
92
- Enabled: true
93
-
94
- Style/WordArray:
95
- Enabled: true
96
-
97
- # Performance cops have been transferred to rubocop-performance gem.
98
- require: rubocop-performance
99
-
100
42
  Performance/DoubleStartEndWith:
101
43
  Enabled: true
102
44
 
103
45
  Performance/RedundantMerge:
104
46
  Enabled: true
105
-
106
- Performance/RegexpMatch:
107
- Enabled: true
108
-
109
- Performance/StringReplacement:
110
- Enabled: true
@@ -0,0 +1,152 @@
1
+ // vim: set et sw=2 ts=2:
2
+ "use strict";
3
+ var env = process.env;
4
+ var url = require('url');
5
+ var Promise = require('bluebird');
6
+ var Phantom = Promise.promisifyAll(require('node-phantom-simple'));
7
+
8
+ var login = {
9
+ begin: url.parse(env['ORACLE_LOGIN_BEGIN'] || "https://www.oracle.com/webapps/redirect/signon?nexturl=https://www.oracle.com/favicon.ico"),
10
+ end: url.parse(env['ORCALE_LOGIN_END'] || "https://www.oracle.com/favicon.ico"),
11
+ };
12
+ delete env['ORACLE_LOGIN_BEGIN'];
13
+ delete env['ORACLE_LOGIN_END'];
14
+
15
+ var credentials = Object.keys(env)
16
+ .filter(function (key) { return key.indexOf('ORACLE_LOGIN_') == 0 })
17
+ .map(function (key) { return [key.substr(13), env[key]] });
18
+
19
+ if (credentials.length <= 0) {
20
+ console.error("Missing ORACLE_LOGIN environment variables!");
21
+ process.exit(1);
22
+ }
23
+
24
+ Phantom.createAsync({ parameters: { 'ssl-protocol': 'tlsv1' } }).then(function (browser) {
25
+ browser = Promise.promisifyAll(browser, { suffix: 'Promise' });
26
+ browser.addCookie({'name': 'oraclelicense', 'value': "accept-" + env['ORACLE_COOKIE'] + "-cookie", 'domain': '.oracle.com' });
27
+
28
+ // Open a tab, configure it
29
+ return browser.createPagePromise().then(function (page) {
30
+ page = Promise.promisifyAll(page, { suffix: 'Promise' });
31
+
32
+ var received = "";
33
+ page.onNavigationRequested = function () { console.info("%s %j", (new Date()).toISOString(), arguments["0"]); };
34
+ page.onResourceError = console.error.bind(console);
35
+ page.onResourceReceived = function (response) { if (response.stage == "end") received = response.url; };
36
+ page.set('settings.loadImages', false);
37
+
38
+ return page
39
+ .setPromise('settings.userAgent', env['USER_AGENT']) // PhantomJS configures the UA per tab
40
+
41
+ // Begin login, wait for the login page
42
+ .then(function () {
43
+ return page.openPromise(login.begin.href).then(function (status) {
44
+ if (status != 'success') throw "Unable to connect to " + login.begin.host;
45
+
46
+ return new Promise(function (resolve, reject) {
47
+ var deadline = Date.now() + 6000;
48
+ var interval = 100;
49
+
50
+ var check = function () {
51
+ if (deadline < Date.now()) return reject("Timeout waiting for form");
52
+
53
+ page.evaluate(function () {
54
+ return window['jQuery'] && document.querySelectorAll('input[type=password]').length;
55
+ }, function (err, result) {
56
+ if (result) { resolve(); } else { setTimeout(check, interval); }
57
+ });
58
+ };
59
+
60
+ check();
61
+ });
62
+ })
63
+ .tapCatch(function (err) {
64
+ return page.getPromise('plainText').then(function (text) {
65
+ console.error("Unable to load login page. Last response was:\n" + text);
66
+ });
67
+ });
68
+ })
69
+
70
+ // Submit the login form
71
+ .then(function () {
72
+ return page.evaluatePromise(function (credentials) {
73
+ var $form = jQuery(document.forms[0]);
74
+ return credentials.filter(function (tuple) {
75
+ return $form.find("[name='"+tuple[0]+"']").val(tuple[1]).length == 0;
76
+ })
77
+ .map(function (tuple) { return tuple[0]; });
78
+ }, credentials)
79
+ .then(function (unapplied) {
80
+ if (unapplied.length > 0) {
81
+ console.warn("Unable to use all ORACLE_LOGIN environment variables: %j", unapplied);
82
+ }
83
+ return page.evaluatePromise(function () {
84
+ jQuery(function () { document.forms[0].submit(); });
85
+ });
86
+ });
87
+ })
88
+
89
+ // Wait for login result
90
+ .then(function () {
91
+ return new Promise(function (resolve, reject) {
92
+ var deadline = Date.now() + 6000;
93
+ var interval = 100;
94
+
95
+ var check = function () {
96
+ if (deadline < Date.now()) return reject("Timeout waiting for " + login.end.href);
97
+ if (received == login.end.href) { resolve(); } else { setTimeout(check, interval); }
98
+ };
99
+
100
+ check();
101
+ })
102
+ .tapCatch(function (err) {
103
+ return page.getPromise('plainText').then(function (text) {
104
+ console.error("Unable to load login result. Last response was:\n" + text);
105
+ });
106
+ });
107
+ })
108
+
109
+ // Export cookies for cURL
110
+ .then(function () {
111
+ return browser.getPromise('cookies').then(function (cookies) {
112
+ var data = "";
113
+ for (var i = 0; i < cookies.length; ++i) {
114
+ var cookie = cookies[i];
115
+ data += cookie.domain + "\tTRUE\t" + cookie.path + "\t"
116
+ + (cookie.secure ? "TRUE" : "FALSE") + "\t0\t"
117
+ + cookie.name + "\t" + cookie.value + "\n";
118
+ }
119
+ return Promise.promisify(require('fs').writeFile)(env['COOKIES'], data);
120
+ });
121
+ })
122
+
123
+ // Download file using cURL
124
+ .then(function () {
125
+ return browser.exitPromise().then(function () {
126
+ var cmd = ['curl', [
127
+ '--cookie', env['COOKIES'],
128
+ '--cookie-jar', env['COOKIES'],
129
+ '--location',
130
+ '--output', env['ORACLE_DOWNLOAD_FILE'],
131
+ '--user-agent', env['USER_AGENT'],
132
+ "https://edelivery.oracle.com/akam/otn/linux/" + env['ORACLE_FILE']
133
+ ]];
134
+
135
+ console.info("Executing %j", cmd);
136
+
137
+ var child_process = require('child_process');
138
+ var child = child_process.spawn.apply(child_process, cmd.concat({ stdio: [0, 1, 2] }));
139
+ child.on('exit', process.exit);
140
+ });
141
+ })
142
+ .catch(function (err) {
143
+ console.error(err);
144
+ browser.on('exit', function () { process.exit(1); });
145
+ browser.exit();
146
+ });
147
+ });
148
+ })
149
+ .catch(function (err) {
150
+ console.error(err);
151
+ process.exit(1);
152
+ });
@@ -0,0 +1,30 @@
1
+ #!/bin/sh -e
2
+ # vim: set et sw=2 ts=2:
3
+
4
+ [ -n "$ORACLE_COOKIE" ] || { echo "Missing ORACLE_COOKIE environment variable!"; exit 1; }
5
+ [ -n "$ORACLE_FILE" ] || { echo "Missing ORACLE_FILE environment variable!"; exit 1; }
6
+
7
+ ORACLE_DOWNLOAD_FILE="$(basename "$ORACLE_FILE")"
8
+
9
+ if [ -n "$ORACLE_DOWNLOAD_DIR" ]; then
10
+ mkdir -p "$ORACLE_DOWNLOAD_DIR"
11
+ ORACLE_DOWNLOAD_FILE="$(readlink -f "$ORACLE_DOWNLOAD_DIR")/$ORACLE_DOWNLOAD_FILE"
12
+ fi
13
+
14
+ if [ "${*#*--unless-exists}" != "$*" ] && [ -f "$ORACLE_DOWNLOAD_FILE" ]; then
15
+ exit 0
16
+ fi
17
+
18
+ cd "$(dirname "$(readlink -f "$0")")"
19
+
20
+ echo "PhantomJS version $(phantomjs --version)"
21
+ npm install bluebird node-phantom-simple
22
+
23
+ export ORACLE_DOWNLOAD_FILE
24
+ export COOKIES='cookies.txt'
25
+ export USER_AGENT='Mozilla/5.0'
26
+
27
+ echo > "$COOKIES"
28
+ chmod 600 "$COOKIES"
29
+
30
+ exec node download.js
@@ -0,0 +1,116 @@
1
+ // vim: set et sw=2 ts=2:
2
+ "use strict";
3
+ var env = process.env;
4
+ var Promise = require('bluebird');
5
+ var Phantom = Promise.promisifyAll(require('node-phantom-simple'));
6
+ var PhantomError = require('node-phantom-simple/headless_error');
7
+
8
+ var credentials = Object.keys(env)
9
+ .filter(function (key) { return key.indexOf('ORACLE_LOGIN_') == 0 })
10
+ .map(function (key) { return [key.substr(13), env[key]] });
11
+
12
+ if (credentials.length <= 0) {
13
+ console.error("Missing ORACLE_LOGIN environment variables!");
14
+ process.exit(1);
15
+ }
16
+
17
+ Phantom.createAsync({ parameters: { 'ssl-protocol': 'tlsv1' } }).then(function (browser) {
18
+ browser = Promise.promisifyAll(browser, { suffix: 'Promise' });
19
+
20
+ // Configure the browser, open a tab
21
+ return browser
22
+ .addCookiePromise({'name': 'oraclelicense', 'value': "accept-" + env['ORACLE_COOKIE'] + "-cookie", 'domain': '.oracle.com' })
23
+ .then(function () {
24
+ return browser.createPagePromise();
25
+ })
26
+ .then(function (page) {
27
+ page = Promise.promisifyAll(page, { suffix: 'Promise' });
28
+
29
+ // Configure the tab
30
+ page.onResourceError = console.error.bind(console);
31
+ return page
32
+ .setPromise('settings.userAgent', env['USER_AGENT']) // PhantomJS configures the UA per tab
33
+
34
+ // Request the file, wait for the login page
35
+ .then(function () {
36
+ return page.openPromise("https://edelivery.oracle.com/akam/otn/linux/" + env['ORACLE_FILE']).then(function (status) {
37
+ if (status != 'success') throw "Unable to connect to oracle.com";
38
+ return page.waitForSelectorPromise('input[type=password]', 5000);
39
+ })
40
+ .catch(PhantomError, function (err) {
41
+ return page.getPromise('plainText').then(function (text) {
42
+ console.error("Unable to load login page. Last response was:\n" + text);
43
+ throw err;
44
+ });
45
+ });
46
+ })
47
+
48
+ // Export cookies for cURL
49
+ .then(function () {
50
+ return page.getPromise('cookies').then(function (cookies) {
51
+ var data = "";
52
+ for (var i = 0; i < cookies.length; ++i) {
53
+ var cookie = cookies[i];
54
+ data += cookie.domain + "\tTRUE\t" + cookie.path + "\t"
55
+ + (cookie.secure ? "TRUE" : "FALSE") + "\t0\t"
56
+ + cookie.name + "\t" + cookie.value + "\n";
57
+ }
58
+ return Promise.promisifyAll(require('fs')).writeFileAsync(env['COOKIES'], data);
59
+ });
60
+ })
61
+
62
+ // Submit the login form using cURL
63
+ .then(function () {
64
+ return page.evaluatePromise(function () {
65
+ var $form = jQuery(document.forms[0]);
66
+ return {
67
+ action: $form.prop('action'),
68
+ data: $form.serialize()
69
+ };
70
+ })
71
+ .then(function (form) {
72
+ return browser.exitPromise().then(function () {
73
+ var unapplied = credentials.filter(function (tuple) {
74
+ var applied = false;
75
+ form.data = form.data.replace(tuple[0] + '=', function (name) {
76
+ applied = true;
77
+ return name + encodeURIComponent(tuple[1]);
78
+ });
79
+ return !applied;
80
+ })
81
+ .map(function (tuple) { return tuple[0] });
82
+
83
+ if (unapplied.length > 0) {
84
+ console.warn("Unable to use all ORACLE_LOGIN environment variables: %j", unapplied);
85
+ }
86
+
87
+ var cmd = ['curl', [
88
+ '--cookie', env['COOKIES'],
89
+ '--cookie-jar', env['COOKIES'],
90
+ '--data', '@-',
91
+ '--location',
92
+ '--output', require('path').basename('ojdbc6.jar'),
93
+ '--user-agent', env['USER_AGENT'],
94
+ env['ORACLE_OJDBC_URL']
95
+ ]];
96
+
97
+ console.info("Executing %j", cmd);
98
+
99
+ var child_process = require('child_process');
100
+ var child = child_process.spawn.apply(child_process, cmd.concat({ stdio: ['pipe', 1, 2] }));
101
+ child.on('exit', process.exit);
102
+ child.stdin.end(form.data);
103
+ });
104
+ });
105
+ })
106
+ .catch(function (err) {
107
+ console.error(err);
108
+ browser.on('exit', function () { process.exit(1); });
109
+ browser.exit();
110
+ });
111
+ });
112
+ })
113
+ .catch(function (err) {
114
+ console.error(err);
115
+ process.exit(1);
116
+ });
@@ -0,0 +1,34 @@
1
+ #!/bin/sh -e
2
+ # vim: set et sw=2 ts=2:
3
+
4
+ [ -z "$ORACLE_DOWNLOAD_DIR" ] || ORACLE_DOWNLOAD_DIR="$(readlink -f "$ORACLE_DOWNLOAD_DIR")/"
5
+ [ -n "$ORACLE_FILE" ] || { echo "Missing ORACLE_FILE environment variable!"; exit 1; }
6
+ [ -n "$ORACLE_HOME" ] || { echo "Missing ORACLE_HOME environment variable!"; exit 1; }
7
+
8
+ ORACLE_RPM="$(basename "$ORACLE_FILE" .zip)"
9
+
10
+ cd "$(dirname "$(readlink -f "$0")")"
11
+
12
+ dpkg -s bc libaio1 rpm unzip > /dev/null 2>&1 ||
13
+ ( sudo apt-get -qq update && sudo apt-get --no-install-recommends -qq install bc libaio1 rpm unzip )
14
+
15
+ df -B1 /dev/shm | awk 'END { if ($1 != "shmfs" && $1 != "tmpfs" || $2 < 2147483648) exit 1 }' ||
16
+ ( sudo rm -r /dev/shm && sudo mkdir /dev/shm && sudo mount -t tmpfs shmfs -o size=2G /dev/shm )
17
+
18
+ test -f /sbin/chkconfig ||
19
+ ( echo '#!/bin/sh' | sudo tee /sbin/chkconfig > /dev/null && sudo chmod u+x /sbin/chkconfig )
20
+
21
+ test -d /var/lock/subsys || sudo mkdir /var/lock/subsys
22
+
23
+ unzip -j "${ORACLE_DOWNLOAD_DIR}$(basename "$ORACLE_FILE")" "*/$ORACLE_RPM"
24
+ sudo rpm --install --nodeps --nopre "$ORACLE_RPM"
25
+
26
+ echo 'OS_AUTHENT_PREFIX=""' | sudo tee -a "$ORACLE_HOME/config/scripts/init.ora" > /dev/null
27
+ sudo usermod -aG dba $USER
28
+
29
+ ( echo ; echo ; echo travis ; echo travis ; echo n ) | sudo AWK='/usr/bin/awk' /etc/init.d/oracle-xe configure
30
+
31
+ "$ORACLE_HOME/bin/sqlplus" -L -S / AS SYSDBA <<SQL
32
+ CREATE USER $USER IDENTIFIED EXTERNALLY;
33
+ GRANT CONNECT, RESOURCE TO $USER;
34
+ SQL
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+
3
+ set -ev
4
+
5
+ "$ORACLE_HOME/bin/sqlplus" -L -S / AS SYSDBA <<SQL
6
+ @@test/support/alter_system_user_password.sql
7
+ @@test/support/create_oracle_enhanced_users.sql
8
+ exit
9
+ SQL
@@ -0,0 +1,6 @@
1
+ #!/bin/bash
2
+
3
+ set -ex
4
+
5
+ sudo curl -L https://sqlite.org/contrib/download/extension-functions.c?get=25 -o /tmp/extension-functions.c
6
+ sudo gcc -fPIC -lm -shared /tmp/extension-functions.c -o /usr/lib/sqlite3/extension-functions.so