8000 convert to gradle and elastic version 2.3.4 · Cleafy/elasticsearch-http-basic@ec45bbb · GitHub
[go: up one dir, main page]

Skip to content

Commit ec45bbb

Browse files
Patrick RypallaPatrick Rypalla
Patrick Rypalla
authored and
Patrick Rypalla
committed
convert to gradle and elastic version 2.3.4
1 parent ebf045c commit ec45bbb

File tree

9 files changed

+164
-74
lines changed

9 files changed

+164
-74
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
*.jar
33
*.zip
44
/build/
5+
/bin/
56
/target/
67
*~
78
deploy.sh
@@ -10,6 +11,7 @@ deploy.sh
1011
.classpath
1112
.metadata/
1213
.project
14+
/.gradle/
1315
.settings/
1416
data/
1517
/.local-execution-hints.log

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ There is no way to configure this on a per index basis.
2121

2222
| Http Basic Plugin | elasticsearch |
2323
|-----------------------------|------------------------------|
24-
| v1.5.1(master) | 1.5.1, 1.5.2, 1.6.0, 1.7.0 |
24+
| v2.3.4 (master) | 2.3.4
25+
| v1.5.1 | 1.5.1, 1.5.2, 1.6.0, 1.7.0 |
2526
| v1.5.0 | 1.5.0 |
2627
| v1.4.0 | 1.4.0 |
2728
| v1.3.0 | 1.3.0 |

build.gradle

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
apply plugin: 'java'
2+
apply plugin: 'eclipse'
3+
4+
sourceCompatibility = 1.8
5+
targetCompatibility = 1.8
6+
version = '2.3.4'
7+
def pluginDescription = 'Plugin to enable HTTP basic authentication and/or Ip based authentication'
8+
def pluginClassname = 'com.asquera.elasticsearch.plugins.http.HttpBasicServerPlugin'
9+
def pluginName = 'elasticsearch-http-basic'
10+
def elasticVersion = '2.3.4'
11+
12+
jar {
13+
jar.baseName = "elasticsearch-http-basic" + version
14+
manifest {
15+
attributes 'Implementation-Title': 'elasticsearch-http-basic',
16+
'Implementation-Version': version
17+
}
18+
}
19+
20+
configurations {
21+
releaseJars {
22+
extendsFrom runtime
23+
}
24+
}
25+
26+
repositories {
27+
mavenCentral()
28+
}
29+
30+
dependencies {
31+
32+
// elastic search
33+
compile("org.elasticsearch:elasticsearch:2.3.4")
34+
compile("org.apache.lucene:lucene-core:5.5.0")
35+
compile("org.apache.lucene:lucene-analyzers-common:5.5.0")
36+
compile("org.apache.lucene:lucene-queries:5.5.0")
37+
compile("org.apache.lucene:lucene-memory:5.5.0")
38+
compile("org.apache.lucene:lucene-highlighter:5.5.0")
39+
compile("org.apache.lucene:lucene-queryparser:5.5.0")
40+
compile("org.apache.lucene:lucene-sandbox:5.5.0")
41+
compile("org.apache.lucene:lucene-suggest:5.5.0")
42+
compile("org.apache.lucene:lucene-misc:5.5.0")
43+
compile("org.apache.lucene:lucene-join:5.5.0")
44+
compile("org.apache.lucene:lucene-grouping:5.5.0")
45+
compile("org.apache.lucene:lucene-spatial:5.5.0")
46+
compile("org.apache.lucene:lucene-expressions:5.5.0")
47+
48+
// httpclient
49+
compile("org.apache.httpcomponents:httpclient:4.5.2")
50+
51+
// stuff
52+
compile("org.apache.commons:commons-lang3:3.4")
53+
compile("com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.3.4")
54+
55+
//test
56+
testCompile group: 'junit', name: 'junit', version: '4.+'
57+
testCompile(group: 'org.elasticsearch', name: 'elasticsearch', version: '2.3.4', classifier: 'tests')
58+
testCompile(group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3')
59+
testCompile(group: 'org.apache.lucene', name: 'lucene-test-framework', version: '5.5.0')
60+
61+
}
62+
63+
test {
64+
systemProperties 'property': 'value'
65+
}
66+
67+
uploadArchives {
68+
repositories {
69+
flatDir {
70+
dirs 'repos'
71+
}
72+
}
73+
}
74+
75+
task makePluginDescriptor(type: Copy) {
76+
from 'src/main/templates'
77+
into 'build/tmp/plugin'
78+
expand([
79+
'descriptor': [
80+
'name': pluginName,
81+
'classname': pluginClassname,
82+
'description': pluginDescription,
83+
'jvm': true,
84+
'site': false,
85+
'isolated': true,
86+
'version': version,
87+
'javaVersion': project.property('targetCompatibility'),
88+
'elasticsearchVersion' : elasticVersion
89+
]
90+
])
91+
}
Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,64 @@
11
package com.asquera.elasticsearch.plugins.http;
22

3+
import java.util.ArrayList;
4+
import java.util.Collection;
5+
import java.util.Collections;
6+
7+
import org.elasticsearch.common.component.LifecycleComponent;
38
import org.elasticsearch.common.inject.Inject;
49
import org.elasticsearch.common.inject.Module;
510
import org.elasticsearch.common.settings.Settings;
6-
import org.elasticsearch.plugins.AbstractPlugin;
7-
import org.elasticsearch.common.component.LifecycleComponent;
8-
import org.elasticsearch.common.settings.ImmutableSettings;
9-
10-
import java.util.Collection;
11-
12-
import static org.elasticsearch.common.collect.Lists.*;
11+
import org.elasticsearch.plugins.Plugin;
1312

1413
/**
1514
* @author Florian Gilcher (florian.gilcher@asquera.de)
1615
*/
17-
public class HttpBasicServerPlugin extends AbstractPlugin {
16+
public class HttpBasicServerPlugin extends Plugin {
1817

1918
private boolean enabledByDefault = true;
2019
private final Settings settings;
2120

22-
@Inject public HttpBasicServerPlugin(Settings settings) {
23-
this.settings = settings;
21+
@Inject
22+
public HttpBasicServerPlugin(Settings settings) {
23+
this.settings = settings;
2424
}
2525

26-
@Override public String name() {
27-
return "http-basic-server-plugin";
26+
@Override
27+
public String name() {
28+
return "http-basic-server-plugin";
2829
}
2930

30-
@Override public String description() {
31-
return "HTTP Basic Server Plugin";
31+
@Override
32+
public String description() {
33+
return "HTTP Basic Server Plugin";
3234
}
3335

34-
@Override public Collection<Class<? extends Module>> modules() {
35-
Collection<Class<? extends Module>> modules = newArrayList();
36-
if (settings.getAsBoolean("http.basic.enabled", enabledByDefault)) {
37-
modules.add(HttpBasicServerModule.class);
38-
}
39-
return modules;
36+
@Override
37+
public Collection<Module> nodeModules() {
38+
Collection<Class<? extends Module>> modules = new ArrayList<Class<? extends Module>>();
39+
if (settings.getAsBoolean("http.basic.enabled", enabledByDefault)) {
40+
modules.add(HttpBasicServerModule.class);
41+
}
42+
return Collections.<Module>singletonList(new HttpBasicServerModule(settings));
4043
}
4144

42-
@Override public Collection<Class<? extends LifecycleComponent>> services() {
43-
Collection<Class<? extends LifecycleComponent>> services = newArrayList();
44-
if (settings.getAsBoolean("http.basic.enabled", enabledByDefault)) {
45-
services.add(HttpBasicServer.class);
46-
}
47-
return services;
45+
@Override
46+
public Collection<Class<? extends LifecycleComponent>> nodeServices() {
47+
Collection<Class<? extends LifecycleComponent>> services = new ArrayList<Class<? extends LifecycleComponent>>();
48+
if (settings.getAsBoolean("http.basic.enabled", enabledByDefault)) {
49+
services.add(HttpBasicServer.class);
50+
}
51+
return services;
4852
}
4953

50-
@Override public Settings additionalSettings() {
51-
if (settings.getAsBoolean("http.basic.enabled", enabledByDefault)) {
52-
return ImmutableSettings.settingsBuilder().
53-
put("http.enabled", false).
54-
build();
55-
} else {
56-
return ImmutableSettings.Builder.EMPTY_SETTINGS;
57-
}
54+
@Override
55+
public Settings additionalSettings() {
56+
if (settings.getAsBoolean("http.basic.enabled", enabledByDefault)) {
57+
return Settings.settingsBuilder().
58+
put("http.enabled", false).
59+
build();
60+
} else {
61+
return Settings.Builder.EMPTY_SETTINGS;
62+
}
5863
}
5964
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
classname=${descriptor.classname}
2+
name=${descriptor.name}
3+
description=${descriptor.description}
4+
jvm=${descriptor.jvm}
5+
site=${descriptor.site}
6+
isolated=${descriptor.isolated}
7+
version=${descriptor.version}
8+
java.version=${descriptor.javaVersion}
9+
elasticsearch.version=${descriptor.elasticsearchVersion}

src/test/java/com/asquera/elasticsearch/plugins/http/auth/integration/DefaultConfigurationIntegrationTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020

2121
import org.elasticsearch.common.settings.Settings;
2222
import org.elasticsearch.rest.RestStatus;
23-
import org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope;
24-
import org.elasticsearch.test.ElasticsearchIntegrationTest.Scope;
23+
import org.elasticsearch.test.ESIntegTestCase;
2524
import org.elasticsearch.test.rest.client.http.HttpResponse;
2625
import org.junit.Test;
2726

@@ -30,7 +29,7 @@
3029
/**
3130
* Test a rest action that sets special response headers
3231
*/
33-
@ClusterScope(scope = Scope.SUITE, numDataNodes = 1)
32+
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, numDataNodes = 1)
3433
public class DefaultConfigurationIntegrationTest extends HttpBasicServerPluginIntegrationTest {
3534

3635
@Override

src/test/java/com/asquera/elasticsearch/plugins/http/auth/integration/DisabledWhitelistIntegrationTest.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,19 @@
1818
*/
1919
package com.asquera.elasticsearch.plugins.http.auth.integration;
2020

21+
import static org.hamcrest.Matchers.equalTo;
22+
23+
import org.apache.http.client.methods.HttpHead;
2124
import org.elasticsearch.common.settings.Settings;
22-
import org.elasticsearch.common.Base64;
2325
import org.elasticsearch.rest.RestStatus;
24-
import org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope;
25-
import org.elasticsearch.test.rest.client.http.HttpRequestBuilder;
26+
import org.elasticsearch.test.ESIntegTestCase;
2627
import org.elasticsearch.test.rest.client.http.HttpResponse;
27-
import org.apache.http.client.methods.HttpHead;
2828
import org.junit.Test;
2929

30-
import static org.elasticsearch.test.ElasticsearchIntegrationTest.Scope;
31-
import static org.hamcrest.Matchers.equalTo;
32-
3330
/**
3431
* Test a rest action that sets special response headers
3532
*/
36-
@ClusterScope(transportClientRatio = 0.0, scope = Scope.SUITE, numDataNodes = 1)
33+
@ESIntegTestCase.ClusterScope(transportClientRatio = 0.0, scope = ESIntegTestCase.Scope.SUITE, numDataNodes = 1)
3734
public class DisabledWhitelistIntegrationTest extends HttpBasicServerPluginIntegrationTest {
3835

3936
@Override

src/test/java/com/asquera/elasticsearch/plugins/http/auth/integration/HttpBasicServerPluginIntegrationTest.java

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,28 @@
1-
21
package com.asquera.elasticsearch.plugins.http.auth.integration;
32

4-
5-
import java.net.InetSocketAddress;
6-
7-
import org.apache.http.impl.client.HttpClients;
8-
import org.elasticsearch.common.transport.InetSocketTransportAddress;
3+
import com.asquera.elasticsearch.plugins.http.HttpBasicServerPlugin;
94
import org.elasticsearch.common.Base64;
10-
import org.elasticsearch.http.HttpServerTransport;
11-
import org.elasticsearch.test.ElasticsearchIntegrationTest;
5+
import org.elasticsearch.common.settings.Settings;
6+
import org.elasticsearch.test.ESIntegTestCase;
127
import org.elasticsearch.test.rest.client.http.HttpRequestBuilder;
13-
import com.asquera.elasticsearch.plugins.http.HttpBasicServerPlugin;
14-
import org.elasticsearch.common.settings.ImmutableSettings.Builder;
15-
import org.elasticsearch.common.settings.ImmutableSettings;
168

179
/**
1810
*
1911
* @author Ernesto Miguez (ernesto.miguez@asquera.de)
2012
*/
21-
22-
public class HttpBasicServerPluginIntegrationTest extends
23-
ElasticsearchIntegrationTest {
13+
public class HttpBasicServerPluginIntegrationTest extends ESIntegTestCase {
2414

2515
protected final String localhost = "127.0.0.1";
2616

27-
2817
/**
2918
*
3019
* @return a Builder with the plugin included and bind_host and publish_host
3120
* set to localhost, from where the client's request ip will be done.
3221
*/
33-
protected Builder builderWithPlugin() {
34-
return ImmutableSettings.settingsBuilder()
35-
.put("network.host", localhost)
36-
.put("plugin.types", HttpBasicServerPlugin.class.getName());
22+
protected Settings.Builder builderWithPlugin() {
23+
return Settings.builder()
24+
.put("network.host", localhost)
25+
.put("plugin.types", HttpBasicServerPlugin.class.getName());
3726
}
3827

3928
protected HttpRequestBuilder requestWithCredentials(String credentials) throws Exception {

src/test/java/com/asquera/elasticsearch/plugins/http/auth/integration/IpAuthenticationIntegrationTest.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,22 @@
1818
*/
1919
package com.asquera.elasticsearch.plugins.http.auth.integration;
2020

21+
import java.util.ArrayList;
22+
import java.util.Iterator;
23+
import java.util.List;
24+
2125
import org.elasticsearch.common.settings.Settings;
22-
import org.elasticsearch.common.Base64;
2326
import org.elasticsearch.rest.RestStatus;
24-
import org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope;
25-
import org.elasticsearch.test.rest.client.http.HttpRequestBuilder;
27+
import org.elasticsearch.test.ESIntegTestCase;
2628
import org.elasticsearch.test.rest.client.http.HttpResponse;
2729
import org.junit.Test;
2830

29-
import java.util.List;
30-
import java.util.ArrayList;
31-
import java.util.Iterator;
32-
33-
import static org.elasticsearch.test.ElasticsearchIntegrationTest.Scope;
3431
import static org.hamcrest.Matchers.equalTo;
3532

3633
/**
3734
* Test a rest action that sets special response headers
3835
*/
39-
@ClusterScope(transportClientRatio = 0.0, scope = Scope.SUITE, numDataNodes = 1)
36+
@ESIntegTestCase.ClusterScope(transportClientRatio = 0.0, scope = ESIntegTestCase.Scope.SUITE, numDataNodes = 1)
4037
public class IpAuthenticationIntegrationTest extends HttpBasicServerPluginIntegrationTest {
4138

4239
protected final String whitelistedIp = "2.2.2.2";

0 commit comments

Comments
 (0)
0