embulk-output-ftp 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 174e14d80670723ddaceb63c1a1e509c1470b00b
4
- data.tar.gz: dd8e77c8aaf86c32fda61afd3fec7795ef97963a
3
+ metadata.gz: 1832391d6c6f0f5d74151a1ff9efb2eacb00f1cd
4
+ data.tar.gz: 57a38106df95458da2618516ad3a55cb4105ad4b
5
5
  SHA512:
6
- metadata.gz: ac46b66aa680cf73dc5f171d14de403d45d375201ade7a950dc5983b6ee67cfcfd6662de15260e88234fdaa494ec08482cb3d419a7d3eb94f4b653269577e291
7
- data.tar.gz: f387f775895d3f523f27ec4d8ef902e644960b98e9fdd0096705c1e7ef757e1742ec6731339418ab6086abceb7e040e97ed7c42c3994fe7a17c008ea27a47bd5
6
+ metadata.gz: 2a01f2622c0f7a27b16d7e95cab138c9cbe6dfc5b1c9289151ef2b3cb3f0e64f1c70209ff29e5a629a7e9af5cb0eb14089be2f892ca5dd86c387e6bc98e8389e
7
+ data.tar.gz: 47944e72c5e2a3a63df8ea3b9b5b1041cd19a189d37012d2a467e681d29d2feb7859195fed0855d0be04e0eb1c4d02b474ccbe5d38d247c87779a523dd4863ca
data/.travis.yml CHANGED
@@ -1,8 +1,11 @@
1
+ sudo: required
1
2
  language: java
2
-
3
3
  jdk:
4
- - oraclejdk8
5
-
4
+ - oraclejdk8
5
+ services:
6
+ - docker
7
+ before_script:
8
+ - docker-compose up -d
9
+ - docker-compose ps
6
10
  script:
7
- - ./gradlew gem
8
11
  - ./gradlew --info check jacocoTestReport
data/CHANGELOG.md CHANGED
@@ -1,4 +1,6 @@
1
- ## 0.1.8 - 2018-07-04
1
+ ## 0.2.1 - 2018-12-14
2
+ * [maintenance] Update Embulk version v0.8.9 to v0.9.11 and refactor code for Java8 support [#21](https://github.com/embulk/embulk-output-ftp/pull/21)
3
+ ## 0.2.0 - 2018-07-04
2
4
  * [maintenance] Only support Java8 [#16](https://github.com/embulk/embulk-output-ftp/pull/16)
3
5
  * [maintenance] Use embulk-util-ftp from Bintray [#15](https://github.com/embulk/embulk-output-ftp/pull/15)
4
6
 
data/README.md CHANGED
@@ -117,32 +117,41 @@ $ ./gradlew gem # -t to watch change of files and rebuild continuously
117
117
 
118
118
  ## Test
119
119
 
120
- ```
120
+ Firstly install Docker and Docker compose then `docker-compose up -d`,
121
+ so that an FTP server will be locally launched then you can run tests with `./gradlew test`.
122
+
123
+ ```sh
124
+ $ docker-compose up -d
125
+ Creating network "embulk-output-ftp_default" with the default driver
126
+ Creating embulk-output-ftp_server ... done
127
+ Creating embulk-output-ftps_server ... done
128
+
129
+ $ docker-compose ps
130
+ Name Command State Ports
131
+ ---------------------------------------------------------------------------------------------------
132
+ embulk-output-ftp_server /usr/sbin/run-vsftpd.sh Up 20/tcp, 0.0.0.0:11021->21/tcp, 0.0.0.0:65000->65000/tcp, 0.0.0.0:65001->65001/tcp, 0.0.0.0:65002->65002/tcp, 0.0.0.0:65003->65003/tcp,
133
+ 0.0.0.0:65004->65004/tcp
134
+ embulk-output-ftps_server /usr/sbin/run-vsftpd-with- ... Up 20/tcp, 0.0.0.0:990->21/tcp, 0.0.0.0:65005->65005/tcp, 0.0.0.0:65006->65006/tcp, 0.0.0.0:65007->65007/tcp, 0.0.0.0:65008->65008/tcp
135
+
121
136
  $ ./gradlew test # -t to watch change of files and rebuild continuously
122
137
  ```
123
138
 
124
- To run unit tests, we need to configure the following environment variables.
125
-
126
- When environment variables are not set, skip some test cases.
139
+ If you want to use other FTP server to test, configure the following environment variables.
127
140
 
128
141
  ```
129
- FTP_TEST_HOST
130
- FTP_TEST_USER
131
- FTP_TEST_PASSWORD
142
+ FTP_TEST_HOST (default: localhost)
143
+ FTP_TEST_PORT (default: 11021)
144
+ FTP_TEST_SSL_PORT (default:990)
145
+ FTP_TEST_USER (default: scott)
146
+ FTP_TEST_PASSWORD (default: tigger)
132
147
  FTP_TEST_SSL_TRUSTED_CA_CERT_FILE
133
148
  FTP_TEST_SSL_TRUSTED_CA_CERT_DATA
134
149
  ```
135
150
 
136
- Following option is optional
137
- ```
138
- FTP_TEST_PORT (default:21)
139
- FTP_TEST_SSL__PORT (default:990)
140
- ```
141
-
142
151
  If you're using Mac OS X El Capitan and GUI Applications(IDE), like as follows.
143
152
  ```xml
144
153
 
145
- launchctl setenv FTP_TEST_SSL_TRUSTED_CA_CERT_FILE$ vi ~/Library/LaunchAgents/environment.plist
154
+ $ vi ~/Library/LaunchAgents/environment.plist
146
155
  <?xml version="1.0" encoding="UTF-8"?>
147
156
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
148
157
  <plist version="1.0">
data/build.gradle CHANGED
@@ -17,20 +17,20 @@ configurations {
17
17
  provided
18
18
  }
19
19
 
20
- version = "0.2.0"
20
+ version = "0.2.1"
21
21
 
22
22
  sourceCompatibility = 1.8
23
23
  targetCompatibility = 1.8
24
24
 
25
25
  dependencies {
26
- compile "org.embulk:embulk-core:0.8.9"
27
- provided "org.embulk:embulk-core:0.8.9"
26
+ compile "org.embulk:embulk-core:0.9.11"
27
+ provided "org.embulk:embulk-core:0.9.11"
28
28
  compile files("libs/ftp4j-1.7.2.jar")
29
29
  compile 'org.embulk.input.ftp:embulk-util-ftp:0.1.6'
30
30
  compile "org.bouncycastle:bcpkix-jdk15on:1.52"
31
31
  testCompile "junit:junit:4.+"
32
- testCompile "org.embulk:embulk-core:0.8.9:tests"
33
- testCompile "org.embulk:embulk-standards:0.8.9"
32
+ testCompile "org.embulk:embulk-core:0.9.11:tests"
33
+ testCompile "org.embulk:embulk-standards:0.9.11"
34
34
  }
35
35
 
36
36
  task classpath(type: Copy, dependsOn: ["jar"]) {
@@ -0,0 +1,24 @@
1
+ version: '3'
2
+ services:
3
+ ftp_server:
4
+ container_name: embulk-output-ftp_server
5
+ image: "fauria/vsftpd"
6
+ environment:
7
+ - FTP_USER=scott
8
+ - FTP_PASS=tiger
9
+ - PASV_MIN_PORT=65000
10
+ - PASV_MAX_PORT=65004
11
+ ports:
12
+ - "11021:21"
13
+ - "65000-65004:65000-65004"
14
+ ftps_server:
15
+ container_name: embulk-output-ftps_server
16
+ build: ./docker-ftps
17
+ environment:
18
+ - FTP_USER=scott
19
+ - FTP_PASS=tiger
20
+ - PASV_MIN_PORT=65005
21
+ - PASV_MAX_PORT=65008
22
+ ports:
23
+ - "990:21"
24
+ - "65005-65008:65005-65008"
@@ -0,0 +1,9 @@
1
+ FROM fauria/vsftpd
2
+
3
+ COPY ca.key.pem /etc/pki/tls/private/vsftpd.key.pem
4
+ COPY ca.cert.pem /etc/pki/tls/certs/vsftpd.cert.pem
5
+
6
+ COPY run-vsftpd-with-ssl.sh /usr/sbin/
7
+ RUN chmod +x /usr/sbin/run-vsftpd-with-ssl.sh
8
+
9
+ CMD ["/usr/sbin/run-vsftpd-with-ssl.sh"]
@@ -0,0 +1,35 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIGEzCCA/ugAwIBAgIJAPF+x8rtCyyOMA0GCSqGSIb3DQEBCwUAMIGfMQswCQYD
3
+ VQQGEwJKUDEOMAwGA1UECAwFVG9reW8xFTATBgNVBAcMDEV4YW1wbGUgVG93bjEY
4
+ MBYGA1UECgwPRXhhbXBsZSBDb21wYW55MRgwFgYDVQQLDA9FeGFtcGxlIFNlY3Rp
5
+ b24xFDASBgNVBAMMC2V4YW1wbGUuY29tMR8wHQYJKoZIhvcNAQkBFhB0ZXN0QGV4
6
+ YW1wbGUuY29tMB4XDTE4MDcxNTE2MDIyMFoXDTM4MDcxMDE2MDIyMFowgZ8xCzAJ
7
+ BgNVBAYTAkpQMQ4wDAYDVQQIDAVUb2t5bzEVMBMGA1UEBwwMRXhhbXBsZSBUb3du
8
+ MRgwFgYDVQQKDA9FeGFtcGxlIENvbXBhbnkxGDAWBgNVBAsMD0V4YW1wbGUgU2Vj
9
+ dGlvbjEUMBIG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wal+dDsujIvDKGKYcHG0
38
+ 2IFSid3+yWfKoxtyIl5VyCSGBKk6Xc0F/kbJREG1BZu5oKdPVHiHl9mzyowCipxk
39
+ FBkZJyWOGp4e51LdaPlnFHs702291wRvdzq9AIxHCwYJlX7q3hp/GvjrhpW+Uff1
40
+ T1jF5wKCAQBRYrjanlMIN5czdB9Y3eFDNmzpirpXhMcN3fegSNvOTITWjBUeo82p
41
+ I/AElEZhXV+CYLkCm63e4m7t18G61x2XKr4WyAqZQeK5Eo5cNjBojvsMtuXvwNfR
42
+ NJNrNUrn8WtHPks1wvW24KZmy0793OCqfcvcmy257eukzLZIAXpBNykVKFrH+HBh
43
+ iBlu0AxXnlxPBONvkaUf+/LP4QsFHWfMp9mmd4KjVoSmVZwN8NcL2wh169UE6Bod
44
+ Ipznrjd223F3Nt06BuhWj3f4VAEgMvmlc32vQlir0ltX054xfNtTkVxEX2plhPIE
45
+ La4Dc9W1l2NDkCeua7y2LSyqvKV8RqdRAoIBAAmFI193N7UHBWHSQIt5WeMiF6vS
46
+ u6q96xH6K75D0HQDq4gBLACMQUwCihSmwwZUmSSwVy0aoVz3fLEuqJWnVRhkjxTW
47
+ BSARYKIoP6eovJn/F1zcAEQAF682q5b/zaWijPEDor5h4uhzsRR0FyyQBXhy3/Vj
48
+ 3eU9qTERzu6BkpHqyd/PNaOZ4j7BLJD1TzaFm/mUQN2oC4OCbtBXC8aokK4zGgko
49
+ PhMO26l6QSJIUzivt42cq4YWFYyY8coUgzX7IM+c8UAsPrbIaz6tAvQCNjFPuXWF
50
+ +vhv2v21n2kyhXz38IWvLqGM8jIh1FWo7vL9JVuXzDU8XaFtQwqMoY+BcSc=
51
+ -----END RSA PRIVATE KEY-----
@@ -0,0 +1,12 @@
1
+ #!/bin/bash
2
+
3
+ echo "ssl_enable=YES" >> /etc/vsftpd/vsftpd.conf
4
+ echo "rsa_cert_file=/etc/pki/tls/certs/vsftpd.cert.pem" >> /etc/vsftpd/vsftpd.conf
5
+ echo "rsa_private_key_file=/etc/pki/tls/private/vsftpd.key.pem" >> /etc/vsftpd/vsftpd.conf
6
+ echo "ssl_sslv2=NO" >> /etc/vsftpd/vsftpd.conf
7
+ echo "ssl_sslv3=NO" >> /etc/vsftpd/vsftpd.conf
8
+ echo "ssl_tlsv1=YES" >> /etc/vsftpd/vsftpd.conf
9
+ echo "force_local_data_ssl=YES" >> /etc/vsftpd/vsftpd.conf
10
+ echo "force_local_logins_ssl=YES" >> /etc/vsftpd/vsftpd.conf
11
+
12
+ /usr/sbin/run-vsftpd.sh
@@ -1,6 +1,5 @@
1
1
  package org.embulk.output.ftp;
2
2
 
3
- import com.google.common.base.Optional;
4
3
  import com.google.common.base.Throwables;
5
4
  import it.sauronsoftware.ftp4j.FTPAbortedException;
6
5
  import it.sauronsoftware.ftp4j.FTPClient;
@@ -41,6 +40,7 @@ import java.net.ConnectException;
41
40
  import java.nio.file.Path;
42
41
  import java.nio.file.Paths;
43
42
  import java.util.List;
43
+ import java.util.Optional;
44
44
 
45
45
  public class FtpFileOutputPlugin implements FileOutputPlugin
46
46
  {
@@ -405,7 +405,7 @@ public class FtpFileOutputPlugin implements FileOutputPlugin
405
405
 
406
406
  if (task.getUser().isPresent()) {
407
407
  log.info("Logging in with user {}", task.getUser().get());
408
- client.login(task.getUser().get(), task.getPassword().or(""));
408
+ client.login(task.getUser().get(), task.getPassword().orElse(""));
409
409
  }
410
410
 
411
411
  log.info("Using passive mode");
@@ -21,7 +21,6 @@ import org.embulk.spi.Schema;
21
21
  import org.embulk.spi.TransactionalFileOutput;
22
22
  import org.embulk.standards.CsvParserPlugin;
23
23
  import org.embulk.util.ftp.SSLPlugins;
24
- import org.embulk.util.ftp.SSLPlugins.SSLPluginConfig;
25
24
 
26
25
  import org.junit.Before;
27
26
  import org.junit.BeforeClass;
@@ -30,7 +29,6 @@ import org.junit.Test;
30
29
  import org.slf4j.Logger;
31
30
 
32
31
  import static org.junit.Assert.assertEquals;
33
- import static org.junit.Assume.assumeNotNull;
34
32
 
35
33
  import java.io.BufferedInputStream;
36
34
  import java.io.BufferedReader;
@@ -44,6 +42,7 @@ import java.lang.reflect.Method;
44
42
  import java.security.GeneralSecurityException;
45
43
  import java.util.Arrays;
46
44
  import java.util.List;
45
+ import java.util.Map;
47
46
 
48
47
  public class TestFtpFileOutputPlugin
49
48
  {
@@ -67,19 +66,20 @@ public class TestFtpFileOutputPlugin
67
66
  * FTP_TEST_SSL_TRUSTED_CA_CERT_FILE
68
67
  */
69
68
  @BeforeClass
70
- public static void initializeConstant()
69
+ public static void initializeConstant() throws Exception
71
70
  {
72
- FTP_TEST_HOST = System.getenv("FTP_TEST_HOST");
73
- FTP_TEST_PORT = System.getenv("FTP_TEST_PORT") != null ? Integer.valueOf(System.getenv("FTP_TEST_PORT")) : 21;
74
- FTP_TEST_SSL_PORT = System.getenv("FTP_TEST_SSL_PORT") != null ? Integer.valueOf(System.getenv("FTP_TEST_SSL_PORT")) : 990;
75
- FTP_TEST_USER = System.getenv("FTP_TEST_USER");
76
- FTP_TEST_PASSWORD = System.getenv("FTP_TEST_PASSWORD");
77
- FTP_TEST_SSL_TRUSTED_CA_CERT_FILE = System.getenv("FTP_TEST_SSL_TRUSTED_CA_CERT_FILE");
78
- FTP_TEST_SSL_TRUSTED_CA_CERT_DATA = System.getenv("FTP_TEST_SSL_TRUSTED_CA_CERT_DATA");
79
- // skip test cases, if environment variables are not set.
80
- assumeNotNull(FTP_TEST_HOST, FTP_TEST_USER, FTP_TEST_PASSWORD, FTP_TEST_SSL_TRUSTED_CA_CERT_FILE, FTP_TEST_SSL_TRUSTED_CA_CERT_DATA);
81
-
82
- FTP_TEST_DIRECTORY = System.getenv("FTP_TEST_DIRECTORY") != null ? getDirectory(System.getenv("FTP_TEST_DIRECTORY")) : getDirectory("/unittest/");
71
+ final Map<String, String> env = System.getenv();
72
+ FTP_TEST_HOST = env.getOrDefault("FTP_TEST_HOST", "localhost");
73
+ FTP_TEST_PORT = Integer.valueOf(env.getOrDefault("FTP_TEST_PORT", "11021"));
74
+ FTP_TEST_SSL_PORT = Integer.valueOf(env.getOrDefault("FTP_TEST_SSL_PORT", "990"));
75
+ FTP_TEST_USER = env.getOrDefault("FTP_TEST_USER", "scott");
76
+ FTP_TEST_PASSWORD = env.getOrDefault("FTP_TEST_PASSWORD", "tiger");
77
+ FTP_TEST_SSL_TRUSTED_CA_CERT_FILE = env.getOrDefault("FTP_TEST_SSL_TRUSTED_CA_CERT_FILE",
78
+ "./docker-ftps/ca.cert.pem");
79
+ FTP_TEST_SSL_TRUSTED_CA_CERT_DATA = env.getOrDefault("FTP_TEST_SSL_TRUSTED_CA_CERT_DATA",
80
+ getFileContents("./docker-ftps/ca.cert.pem"));
81
+
82
+ FTP_TEST_DIRECTORY = getDirectory(env.getOrDefault("FTP_TEST_DIRECTORY", "/unittest/"));
83
83
  FTP_TEST_PATH_PREFIX = FTP_TEST_DIRECTORY + "sample_";
84
84
  LOCAL_PATH_PREFIX = Resources.getResource("sample_01.csv").getPath();
85
85
  }
@@ -287,7 +287,7 @@ public class TestFtpFileOutputPlugin
287
287
  .set("parser", parserConfig(schemaConfig()))
288
288
  .set("type", "ftp")
289
289
  .set("host", FTP_TEST_HOST)
290
- .set("port", FTP_TEST_SSL_PORT)
290
+ .set("port", FTP_TEST_PORT)
291
291
  .set("user", FTP_TEST_USER)
292
292
  .set("password", FTP_TEST_PASSWORD)
293
293
  .set("path_prefix", FTP_TEST_PATH_PREFIX)
@@ -435,4 +435,19 @@ public class TestFtpFileOutputPlugin
435
435
  }
436
436
  return bo.toByteArray();
437
437
  }
438
+
439
+ private static String getFileContents(String path) throws Exception
440
+ {
441
+ StringBuilder sb = new StringBuilder();
442
+ try (InputStream is = new FileInputStream(new File(path))) {
443
+ BufferedReader br = new BufferedReader(new InputStreamReader(is));
444
+ String line = br.readLine();
445
+
446
+ while (line != null) {
447
+ sb.append(line).append("\n");
448
+ line = br.readLine();
449
+ }
450
+ }
451
+ return sb.toString();
452
+ }
438
453
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-output-ftp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Satoshi Akama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-04 00:00:00.000000000 Z
11
+ date: 2018-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +52,11 @@ files:
52
52
  - build.gradle
53
53
  - config/checkstyle/checkstyle.xml
54
54
  - config/checkstyle/default.xml
55
+ - docker-compose.yml
56
+ - docker-ftps/Dockerfile
57
+ - docker-ftps/ca.cert.pem
58
+ - docker-ftps/ca.key.pem
59
+ - docker-ftps/run-vsftpd-with-ssl.sh
55
60
  - embulk-output-ftp.gemspec
56
61
  - gradle/wrapper/gradle-wrapper.jar
57
62
  - gradle/wrapper/gradle-wrapper.properties
@@ -67,7 +72,7 @@ files:
67
72
  - classpath/bcprov-jdk15on-1.52.jar
68
73
  - classpath/ftp4j-1.7.2.jar
69
74
  - classpath/embulk-util-ftp-0.1.6.jar
70
- - classpath/embulk-output-ftp-0.2.0.jar
75
+ - classpath/embulk-output-ftp-0.2.1.jar
71
76
  homepage: https://github.com/embulk/embulk-output-ftp
72
77
  licenses:
73
78
  - Apache 2.0