[FIX] adapt licensing rest tests to new spec-api name

Original commit: elastic/x-pack-elasticsearch@c307c2afda
This commit is contained in:
Areek Zillur 2016-07-11 18:27:05 -04:00
parent 9556ee1e76
commit 149df1fd44
3 changed files with 4 additions and 35 deletions

View File

@ -74,5 +74,5 @@ teardown:
- match: { acknowledged: true }
- do:
license.get: {}
xpack.license.get: {}
catch: missing

View File

@ -8,33 +8,15 @@ package org.elasticsearch.xpack.test.rest;
import com.carrotsearch.randomizedtesting.annotations.Name;
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.license.plugin.TestUtils;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.elasticsearch.test.rest.RestTestCandidate;
import org.elasticsearch.test.rest.client.RestTestResponse;
import org.elasticsearch.test.rest.parser.RestTestParseException;
import org.elasticsearch.xpack.security.authc.esnative.ReservedRealm;
import org.elasticsearch.xpack.security.authc.support.SecuredString;
import org.elasticsearch.xpack.security.authz.store.ReservedRolesStore;
import org.junit.After;
import org.junit.Before;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
import static org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
public abstract class XPackRestTestCase extends ESRestTestCase {
@ -50,19 +32,6 @@ public abstract class XPackRestTestCase extends ESRestTestCase {
return ESRestTestCase.createParameters(0, 1);
}
@Before
public void installLicense() throws Exception {
final XContentBuilder builder = XContentFactory.jsonBuilder();
TestUtils.generateSignedLicense("trial", TimeValue.timeValueHours(2)).toXContent(builder, ToXContent.EMPTY_PARAMS);
final BytesReference bytes = builder.bytes();
try (XContentParser parser = XContentFactory.xContent(bytes).createParser(bytes)) {
final List<Map<String, Object>> bodies = singletonList(singletonMap("license",
parser.map()));
getAdminExecutionContext().callApi("license.post", singletonMap("acknowledge", "true"),
bodies, singletonMap("Authorization", BASIC_AUTH_VALUE));
}
}
@Override
protected Settings restClientSettings() {
return Settings.builder()

View File

@ -7,7 +7,7 @@
wait_for_status: yellow
- do:
license.delete: {}
xpack.license.delete: {}
- match: { acknowledged: true }
# we don't have a license now
@ -30,7 +30,7 @@
# - is_false: features.monitoring.available TODO fix once licensing is fixed
- do:
license.post:
xpack.license.post:
body: >
{
"license": {
@ -49,7 +49,7 @@
- match: { license_status: "valid" }
- do:
license.get: {}
xpack.license.get: {}
- match: { license.uid: "893361dc-9749-4997-93cb-802e3dofh7aa" }
- match: { license.type: "internal" }
- match: { license.status: "active" }