From dee1bd1825610ca0b49044b481721470113482df Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Tue, 4 Apr 2017 11:04:37 -0400 Subject: [PATCH] Respond to rename random ASCII helper methods This commit is response to the renaming of the random ASCII helper methods in ESTestCase. The name of this method was changed because these methods only produce random strings generated from [a-zA-Z], not from all ASCII characters. Relates elastic/x-pack-elasticsearch#942 Original commit: elastic/x-pack-elasticsearch@a6085964d3d65d2eb86c1676ad825ea031c241d2 --- .../license/licensor/TestUtils.java | 2 +- .../integration/ClearRealmsCacheTests.java | 2 +- .../integration/ClearRolesCacheTests.java | 2 +- .../integration/KibanaUserRoleIntegTests.java | 2 +- .../integration/ScrollIdSigningTests.java | 4 +- .../license/LicenseUtilsTests.java | 2 +- .../license/PutLicenseResponseTests.java | 4 +- .../org/elasticsearch/license/TestUtils.java | 4 +- .../test/SettingsFilterTests.java | 8 +- .../action/TransportXPackInfoActionTests.java | 8 +- .../xpack/common/http/HttpClientTests.java | 16 +-- .../http/HttpConnectionTimeoutTests.java | 7 +- .../common/http/HttpRequestTemplateTests.java | 4 +- .../xpack/common/http/HttpRequestTests.java | 16 +-- .../http/SizeLimitInputStreamTests.java | 2 +- .../ml/action/CloseJobActionRequestTests.java | 2 +- .../CreateFilterActionRequestTests.java | 4 +- .../ml/action/DeleteDatafeedRequestTests.java | 2 +- .../ml/action/DeleteJobRequestTests.java | 2 +- .../action/GetBucketActionRequestTests.java | 6 +- .../action/GetBucketActionResponseTests.java | 6 +- .../ml/action/GetCategoriesRequestTests.java | 4 +- .../ml/action/GetCategoriesResponseTests.java | 2 +- .../GetDatafeedStatsActionRequestTests.java | 2 +- .../GetDatafeedStatsActionResponseTests.java | 4 +- .../GetDatafeedsActionRequestTests.java | 2 +- .../GetDatafeedsActionResponseTests.java | 2 +- .../action/GetFiltersActionRequestTests.java | 2 +- .../action/GetFiltersActionResponseTests.java | 2 +- .../GetInfluencersActionRequestTests.java | 8 +- .../GetInfluencersActionResponseTests.java | 4 +- .../action/GetJobStatsActionRequestTests.java | 2 +- .../GetJobStatsActionResponseTests.java | 4 +- .../ml/action/GetJobsActionRequestTests.java | 2 +- .../GetModelSnapshotsActionRequestTests.java | 10 +- .../action/GetRecordsActionRequestTests.java | 10 +- .../action/GetRecordsActionResponseTests.java | 2 +- .../ml/action/OpenJobActionRequestTests.java | 2 +- .../ml/action/PostDataActionRequestTests.java | 10 +- .../ml/action/PostDataFlushRequestTests.java | 8 +- .../PreviewDatafeedActionRequestTests.java | 2 +- .../action/PutDatafeedActionRequestTests.java | 6 +- .../PutDatafeedActionResponseTests.java | 6 +- ...RevertModelSnapshotActionRequestTests.java | 2 +- .../StartDatafeedActionRequestTests.java | 2 +- .../StopDatafeedActionRequestTests.java | 2 +- .../action/UpdateJobActionRequestTests.java | 2 +- ...UpdateModelSnapshotActionRequestTests.java | 6 +- .../UpdateProcessActionRequestTests.java | 6 +- .../ValidateDetectorActionRequestTests.java | 2 +- .../xpack/ml/action/util/QueryPageTests.java | 4 +- .../ml/datafeed/DatafeedConfigTests.java | 12 +- .../ml/datafeed/DatafeedUpdateTests.java | 8 +- .../AggregationDataExtractorTests.java | 2 +- .../scroll/ScrollDataExtractorTests.java | 2 +- .../AutodetectResultProcessorIT.java | 12 +- .../ml/job/config/AnalysisConfigTests.java | 2 +- .../xpack/ml/job/config/ConditionTests.java | 7 +- .../ml/job/config/DataDescriptionTests.java | 6 +- .../ml/job/config/DetectionRuleTests.java | 4 +- .../xpack/ml/job/config/DetectorTests.java | 10 +- .../xpack/ml/job/config/JobBuilderTests.java | 10 +- .../xpack/ml/job/config/JobTests.java | 8 +- .../xpack/ml/job/config/JobUpdateTests.java | 18 +-- .../xpack/ml/job/config/MlFilterTests.java | 6 +- .../ml/job/config/ModelPlotConfigTests.java | 2 +- .../ml/job/config/RuleConditionTests.java | 8 +- .../output/FlushAcknowledgementTests.java | 2 +- .../autodetect/state/DataCountsTests.java | 16 +-- .../autodetect/state/ModelSizeStatsTests.java | 2 +- .../autodetect/state/ModelSnapshotTests.java | 6 +- .../autodetect/state/QuantilesTests.java | 4 +- .../ml/job/results/AnomalyCauseTests.java | 24 ++-- .../ml/job/results/AnomalyRecordTests.java | 22 +-- .../ml/job/results/AutodetectResultTests.java | 8 +- .../ml/job/results/BucketInfluencerTests.java | 8 +- .../xpack/ml/job/results/BucketTests.java | 6 +- .../job/results/CategoryDefinitionTests.java | 10 +- .../xpack/ml/job/results/InfluenceTests.java | 4 +- .../xpack/ml/job/results/InfluencerTests.java | 4 +- .../xpack/ml/job/results/ModelPlotTests.java | 14 +- .../ml/job/results/PartitionScoreTests.java | 2 +- .../PerPartitionMaxProbabilitiesTests.java | 4 +- .../ml/notifications/AuditMessageTests.java | 4 +- .../monitoring/MonitoredSystemTests.java | 2 +- .../monitoring/MonitoringFeatureSetTests.java | 2 +- .../MonitoringSettingsIntegTests.java | 2 +- .../action/MonitoringBulkDocTests.java | 14 +- .../action/MonitoringBulkRequestTests.java | 31 ++--- .../action/MonitoringBulkResponseTests.java | 8 +- .../TransportMonitoringBulkActionTests.java | 3 +- .../AbstractIndicesCleanerTestCase.java | 4 +- .../exporter/MonitoringDocTests.java | 4 +- .../HttpExportBulkResponseListenerTests.java | 2 +- .../exporter/http/HttpExporterIT.java | 4 +- .../exporter/http/HttpHostBuilderTests.java | 2 +- .../resolver/DataResolverTests.java | 4 +- .../resolver/TimestampedResolverTests.java | 4 +- .../bulk/MonitoringBulkDataResolverTests.java | 8 +- ...onitoringBulkTimestampedResolverTests.java | 4 +- .../cluster/ClusterInfoResolverTests.java | 4 +- .../ClusterStateNodeResolverTests.java | 4 +- .../cluster/ClusterStateResolverTests.java | 2 +- .../cluster/ClusterStatsResolverTests.java | 2 +- .../resolver/cluster/ClusterStatsTests.java | 2 +- .../indices/IndexRecoveryResolverTests.java | 2 +- .../indices/IndexStatsResolverTests.java | 2 +- .../indices/IndicesStatsResolverTests.java | 2 +- .../node/DiscoveryNodeResolverTests.java | 4 +- .../resolver/node/NodeStatsResolverTests.java | 2 +- .../resolver/shards/ShardsResolverTests.java | 4 +- .../notification/email/AccountTests.java | 8 +- .../notification/email/ProfileTests.java | 2 +- .../EmailAttachmentParsersTests.java | 3 +- .../HttpEmailAttachementParserTests.java | 2 +- .../ReportingAttachmentParserTests.java | 10 +- .../hipchat/HipChatAccountsTests.java | 4 +- .../hipchat/HipChatMessageTests.java | 28 ++-- .../hipchat/HipChatServiceTests.java | 10 +- .../hipchat/IntegrationAccountTests.java | 12 +- .../hipchat/UserAccountTests.java | 4 +- .../notification/hipchat/V1AccountTests.java | 6 +- .../notification/jira/JiraAccountTests.java | 14 +- .../notification/jira/JiraIssueTests.java | 4 +- .../pagerduty/IncidentEventDefaultsTests.java | 36 ++--- .../pagerduty/PagerDutyAccountsTests.java | 2 +- .../slack/SlackAccountsTests.java | 2 +- .../message/SlackMessageDefaultsTests.java | 34 ++--- .../slack/message/SlackMessageTests.java | 130 +++++++++--------- .../PersistentTasksClusterServiceTests.java | 14 +- .../PersistentTasksCustomMetaDataTests.java | 14 +- .../StartPersistentActionRequestTests.java | 8 +- .../UpdatePersistentTaskRequestTests.java | 2 +- .../xpack/security/SecuritySettingsTests.java | 4 +- .../action/SecurityActionMapperTests.java | 10 +- .../user/TransportGetUsersActionTests.java | 2 +- .../TransportHasPrivilegesActionTests.java | 2 +- .../xpack/security/audit/AuditUtilTests.java | 2 +- .../index/IndexAuditTrailMutedTests.java | 22 +-- .../security/authc/RealmSettingsTests.java | 40 +++--- .../esnative/ESNativeMigrateToolTests.java | 4 +- .../authc/esnative/NativeRealmIntegTests.java | 4 +- .../authc/esnative/NativeUsersStoreTests.java | 2 +- .../authc/esnative/ReservedRealmTests.java | 4 +- .../authc/file/FileUserPasswdStoreTests.java | 2 +- .../authc/file/FileUserRolesStoreTests.java | 2 +- .../ldap/support/LdapLoadBalancingTests.java | 2 +- .../ldap/support/SessionFactoryTests.java | 2 +- .../security/authc/support/BCryptTests.java | 2 +- .../CachingUsernamePasswordRealmTests.java | 2 +- .../authc/support/DnRoleMapperTests.java | 2 +- .../security/authc/support/HasherTests.java | 2 +- .../authz/AuthorizationServiceTests.java | 16 +-- .../authz/AuthorizationUtilsTests.java | 4 +- .../IndicesAccessControlTests.java | 2 +- .../accesscontrol/IndicesPermissionTests.java | 16 +-- .../FieldPermissionsCacheTests.java | 14 +- .../authz/permission/PermissionTests.java | 2 +- .../authz/store/CompositeRolesStoreTests.java | 2 +- .../authz/store/NativeRolesStoreTests.java | 2 +- .../authz/store/ReservedRolesStoreTests.java | 46 +++---- .../security/crypto/CryptoServiceTests.java | 26 ++-- .../crypto/tool/SystemKeyToolTests.java | 4 +- .../security/support/SecurityFilesTests.java | 4 +- .../security/support/ValidationTests.java | 2 +- .../security/test/SecurityTestUtils.java | 2 +- .../xpack/security/user/UserTests.java | 10 +- .../xpack/ssl/CertificateToolTests.java | 6 +- .../xpack/ssl/GeneratedKeyConfigTests.java | 2 +- .../ssl/SSLConfigurationSettingsTests.java | 4 +- .../xpack/ssl/SSLConfigurationTests.java | 16 +-- .../actions/email/EmailActionTests.java | 26 ++-- .../actions/hipchat/HipChatActionTests.java | 10 +- .../actions/index/IndexActionTests.java | 6 +- .../jira/ExecutableJiraActionTests.java | 8 +- .../watcher/actions/jira/JiraActionTests.java | 12 +- .../actions/logging/LoggingActionTests.java | 22 +-- .../pagerduty/PagerDutyActionTests.java | 16 +-- .../slack/ExecutableSlackActionTests.java | 2 +- .../actions/slack/SlackActionTests.java | 12 +- .../actions/webhook/WebhookActionTests.java | 12 +- .../chain/ExecutableChainInputTests.java | 2 +- .../watcher/input/http/HttpInputTests.java | 10 +- .../action/RestExecuteWatchActionTests.java | 2 +- .../watcher/support/WatcherUtilsTests.java | 8 +- .../put/PutWatchSerializationTests.java | 8 +- .../trigger/schedule/ScheduleTestCase.java | 2 +- .../xpack/watcher/watch/WatchTests.java | 6 +- .../example/realm/CustomRealmIT.java | 2 +- 189 files changed, 703 insertions(+), 716 deletions(-) diff --git a/license-tools/src/test/java/org/elasticsearch/license/licensor/TestUtils.java b/license-tools/src/test/java/org/elasticsearch/license/licensor/TestUtils.java index 1d5ac00f38d..3353fa4761e 100644 --- a/license-tools/src/test/java/org/elasticsearch/license/licensor/TestUtils.java +++ b/license-tools/src/test/java/org/elasticsearch/license/licensor/TestUtils.java @@ -176,7 +176,7 @@ public class TestUtils { .maxNodes(5); if (version == License.VERSION_START) { builder.subscriptionType(randomFrom("dev", "gold", "platinum", "silver")); - builder.feature(ESTestCase.randomAsciiOfLength(10)); + builder.feature(ESTestCase.randomAlphaOfLength(10)); } LicenseSigner signer = new LicenseSigner(priKeyPath, pubKeyPath); return signer.sign(builder.build()); diff --git a/plugin/src/test/java/org/elasticsearch/integration/ClearRealmsCacheTests.java b/plugin/src/test/java/org/elasticsearch/integration/ClearRealmsCacheTests.java index b1f12d9e05f..79cfc5b02c0 100644 --- a/plugin/src/test/java/org/elasticsearch/integration/ClearRealmsCacheTests.java +++ b/plugin/src/test/java/org/elasticsearch/integration/ClearRealmsCacheTests.java @@ -51,7 +51,7 @@ public class ClearRealmsCacheTests extends SecurityIntegTestCase { public static void init() throws Exception { usernames = new String[randomIntBetween(5, 10)]; for (int i = 0; i < usernames.length; i++) { - usernames[i] = randomAsciiOfLength(6) + "_" + i; + usernames[i] = randomAlphaOfLength(6) + "_" + i; } } diff --git a/plugin/src/test/java/org/elasticsearch/integration/ClearRolesCacheTests.java b/plugin/src/test/java/org/elasticsearch/integration/ClearRolesCacheTests.java index 3abb394f216..099c4368740 100644 --- a/plugin/src/test/java/org/elasticsearch/integration/ClearRolesCacheTests.java +++ b/plugin/src/test/java/org/elasticsearch/integration/ClearRolesCacheTests.java @@ -41,7 +41,7 @@ public class ClearRolesCacheTests extends NativeRealmIntegTestCase { public static void init() throws Exception { roles = new String[randomIntBetween(5, 10)]; for (int i = 0; i < roles.length; i++) { - roles[i] = randomAsciiOfLength(6) + "_" + i; + roles[i] = randomAlphaOfLength(6) + "_" + i; } } diff --git a/plugin/src/test/java/org/elasticsearch/integration/KibanaUserRoleIntegTests.java b/plugin/src/test/java/org/elasticsearch/integration/KibanaUserRoleIntegTests.java index d7766561de8..54af84c507b 100644 --- a/plugin/src/test/java/org/elasticsearch/integration/KibanaUserRoleIntegTests.java +++ b/plugin/src/test/java/org/elasticsearch/integration/KibanaUserRoleIntegTests.java @@ -173,7 +173,7 @@ public class KibanaUserRoleIntegTests extends SecurityIntegTestCase { } public void testCreateIndexDeleteInKibanaIndex() throws Exception { - final String index = randomBoolean()? ".kibana" : ".kibana-" + randomAsciiOfLengthBetween(1, 10).toLowerCase(Locale.ENGLISH); + final String index = randomBoolean()? ".kibana" : ".kibana-" + randomAlphaOfLengthBetween(1, 10).toLowerCase(Locale.ENGLISH); if (randomBoolean()) { CreateIndexResponse createIndexResponse = client().filterWithHeader(singletonMap("Authorization", diff --git a/plugin/src/test/java/org/elasticsearch/integration/ScrollIdSigningTests.java b/plugin/src/test/java/org/elasticsearch/integration/ScrollIdSigningTests.java index 7e34ee20ce2..92154ea197d 100644 --- a/plugin/src/test/java/org/elasticsearch/integration/ScrollIdSigningTests.java +++ b/plugin/src/test/java/org/elasticsearch/integration/ScrollIdSigningTests.java @@ -61,7 +61,7 @@ public class ScrollIdSigningTests extends SecurityIntegTestCase { .setSize(randomIntBetween(1, 10)).get(); String scrollId = response.getScrollId(); String tamperedScrollId = randomBoolean() ? scrollId.substring(randomIntBetween(1, 10)) : - scrollId + randomAsciiOfLength(randomIntBetween(3, 10)); + scrollId + randomAlphaOfLength(randomIntBetween(3, 10)); try { assertThrowsAuthorizationException(client().prepareSearchScroll(tamperedScrollId).setScroll(TimeValue.timeValueMinutes(2))::get, @@ -83,7 +83,7 @@ public class ScrollIdSigningTests extends SecurityIntegTestCase { .setSize(5).get(); String scrollId = response.getScrollId(); String tamperedScrollId = randomBoolean() ? scrollId.substring(randomIntBetween(1, 10)) : - scrollId + randomAsciiOfLength(randomIntBetween(3, 10)); + scrollId + randomAlphaOfLength(randomIntBetween(3, 10)); try { assertThrowsAuthorizationException(client().prepareClearScroll().addScrollId(tamperedScrollId)::get, diff --git a/plugin/src/test/java/org/elasticsearch/license/LicenseUtilsTests.java b/plugin/src/test/java/org/elasticsearch/license/LicenseUtilsTests.java index c8c1d7ba8d7..26ed6f5e446 100644 --- a/plugin/src/test/java/org/elasticsearch/license/LicenseUtilsTests.java +++ b/plugin/src/test/java/org/elasticsearch/license/LicenseUtilsTests.java @@ -17,7 +17,7 @@ import static org.hamcrest.Matchers.hasSize; public class LicenseUtilsTests extends ESTestCase { public void testNewExpirationException() { - for (String feature : Arrays.asList("feature", randomAsciiOfLength(5), null, "")) { + for (String feature : Arrays.asList("feature", randomAlphaOfLength(5), null, "")) { ElasticsearchSecurityException exception = LicenseUtils.newComplianceException(feature); assertNotNull(exception); assertThat(exception.getMetadataKeys(), contains(LicenseUtils.EXPIRED_FEATURE_METADATA)); diff --git a/plugin/src/test/java/org/elasticsearch/license/PutLicenseResponseTests.java b/plugin/src/test/java/org/elasticsearch/license/PutLicenseResponseTests.java index 6e01cf2ca09..e2abdc9a845 100644 --- a/plugin/src/test/java/org/elasticsearch/license/PutLicenseResponseTests.java +++ b/plugin/src/test/java/org/elasticsearch/license/PutLicenseResponseTests.java @@ -88,11 +88,11 @@ public class PutLicenseResponseTests extends ESTestCase { Map ackMessages = new HashMap<>(); for (int i = 0; i < nFeatures; i++) { - String feature = randomAsciiOfLengthBetween(9, 15); + String feature = randomAlphaOfLengthBetween(9, 15); int nMessages = randomIntBetween(1, 5); String[] messages = new String[nMessages]; for (int j = 0; j < nMessages; j++) { - messages[j] = randomAsciiOfLengthBetween(10, 30); + messages[j] = randomAlphaOfLengthBetween(10, 30); } ackMessages.put(feature, messages); } diff --git a/plugin/src/test/java/org/elasticsearch/license/TestUtils.java b/plugin/src/test/java/org/elasticsearch/license/TestUtils.java index cb4a7b80c50..5e8f48c8588 100644 --- a/plugin/src/test/java/org/elasticsearch/license/TestUtils.java +++ b/plugin/src/test/java/org/elasticsearch/license/TestUtils.java @@ -32,7 +32,7 @@ import java.util.concurrent.atomic.AtomicReference; import static com.carrotsearch.randomizedtesting.RandomizedTest.randomBoolean; import static com.carrotsearch.randomizedtesting.RandomizedTest.randomInt; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; -import static org.elasticsearch.test.ESTestCase.randomAsciiOfLength; +import static org.elasticsearch.test.ESTestCase.randomAlphaOfLength; import static org.elasticsearch.test.ESTestCase.randomFrom; import static org.elasticsearch.test.ESTestCase.randomIntBetween; import static org.hamcrest.core.IsEqual.equalTo; @@ -257,7 +257,7 @@ public class TestUtils { .maxNodes(5); if (version == License.VERSION_START) { builder.subscriptionType((type != null) ? type : randomFrom("dev", "gold", "platinum", "silver")); - builder.feature(randomAsciiOfLength(10)); + builder.feature(randomAlphaOfLength(10)); } LicenseSigner signer = new LicenseSigner(getTestPriKeyPath(), getTestPubKeyPath()); return signer.sign(builder.build()); diff --git a/plugin/src/test/java/org/elasticsearch/test/SettingsFilterTests.java b/plugin/src/test/java/org/elasticsearch/test/SettingsFilterTests.java index 69b060f7aed..4124b128f16 100644 --- a/plugin/src/test/java/org/elasticsearch/test/SettingsFilterTests.java +++ b/plugin/src/test/java/org/elasticsearch/test/SettingsFilterTests.java @@ -39,8 +39,8 @@ public class SettingsFilterTests extends ESTestCase { configureUnfilteredSetting("xpack.security.authc.realms.ldap1.enabled", "false"); configureUnfilteredSetting("xpack.security.authc.realms.ldap1.url", "ldap://host.domain"); configureFilteredSetting("xpack.security.authc.realms.ldap1.hostname_verification", randomBooleanSetting()); - configureFilteredSetting("xpack.security.authc.realms.ldap1.bind_dn", randomAsciiOfLength(5)); - configureFilteredSetting("xpack.security.authc.realms.ldap1.bind_password", randomAsciiOfLength(5)); + configureFilteredSetting("xpack.security.authc.realms.ldap1.bind_dn", randomAlphaOfLength(5)); + configureFilteredSetting("xpack.security.authc.realms.ldap1.bind_password", randomAlphaOfLength(5)); // active directory filtering configureUnfilteredSetting("xpack.security.authc.realms.ad1.type", "active_directory"); @@ -64,7 +64,7 @@ public class SettingsFilterTests extends ESTestCase { configureFilteredSetting("xpack.ssl.keystore.password", "testnode"); configureFilteredSetting("xpack.ssl.keystore.algorithm", KeyManagerFactory.getDefaultAlgorithm()); configureFilteredSetting("xpack.ssl.keystore.key_password", "testnode"); - configureFilteredSetting("xpack.ssl.truststore.password", randomAsciiOfLength(5)); + configureFilteredSetting("xpack.ssl.truststore.password", randomAlphaOfLength(5)); configureFilteredSetting("xpack.ssl.truststore.algorithm", TrustManagerFactory.getDefaultAlgorithm()); // client profile @@ -79,7 +79,7 @@ public class SettingsFilterTests extends ESTestCase { configureFilteredSetting("transport.profiles.client.xpack.security.ssl.keystore.algorithm", KeyManagerFactory.getDefaultAlgorithm()); configureFilteredSetting("transport.profiles.client.xpack.security.ssl.keystore.key_password", "testnode"); - configureFilteredSetting("transport.profiles.client.xpack.security.ssl.truststore.password", randomAsciiOfLength(5)); + configureFilteredSetting("transport.profiles.client.xpack.security.ssl.truststore.password", randomAlphaOfLength(5)); configureFilteredSetting("transport.profiles.client.xpack.security.ssl.truststore.algorithm", TrustManagerFactory.getDefaultAlgorithm()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/action/TransportXPackInfoActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/action/TransportXPackInfoActionTests.java index 97bfd7c76e9..c7e13b6449f 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/action/TransportXPackInfoActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/action/TransportXPackInfoActionTests.java @@ -45,8 +45,8 @@ public class TransportXPackInfoActionTests extends ESTestCase { int featureSetCount = randomIntBetween(0, 5); for (int i = 0; i < featureSetCount; i++) { XPackFeatureSet fs = mock(XPackFeatureSet.class); - when(fs.name()).thenReturn(randomAsciiOfLength(5)); - when(fs.description()).thenReturn(randomAsciiOfLength(10)); + when(fs.name()).thenReturn(randomAlphaOfLength(5)); + when(fs.description()).thenReturn(randomAlphaOfLength(10)); when(fs.available()).thenReturn(randomBoolean()); when(fs.enabled()).thenReturn(randomBoolean()); featureSets.add(fs); @@ -62,11 +62,11 @@ public class TransportXPackInfoActionTests extends ESTestCase { when(license.expiryDate()).thenReturn(expiryDate); License.Status status = randomFrom(License.Status.values()); when(license.status()).thenReturn(status); - String type = randomAsciiOfLength(10); + String type = randomAlphaOfLength(10); when(license.type()).thenReturn(type); License.OperationMode mode = randomFrom(License.OperationMode.values()); when(license.operationMode()).thenReturn(mode); - String uid = randomAsciiOfLength(30); + String uid = randomAlphaOfLength(30); when(license.uid()).thenReturn(uid); when(licenseService.getLicense()).thenReturn(license); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/common/http/HttpClientTests.java b/plugin/src/test/java/org/elasticsearch/xpack/common/http/HttpClientTests.java index 22c83490aaf..e8e987c70e6 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/common/http/HttpClientTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/common/http/HttpClientTests.java @@ -76,24 +76,24 @@ public class HttpClientTests extends ESTestCase { public void testBasics() throws Exception { int responseCode = randomIntBetween(200, 203); - String body = randomAsciiOfLengthBetween(2, 8096); + String body = randomAlphaOfLengthBetween(2, 8096); webServer.enqueue(new MockResponse().setResponseCode(responseCode).setBody(body)); HttpRequest.Builder requestBuilder = HttpRequest.builder("localhost", webServer.getPort()) .method(HttpMethod.POST) - .path("/" + randomAsciiOfLength(5)); + .path("/" + randomAlphaOfLength(5)); - String paramKey = randomAsciiOfLength(3); - String paramValue = randomAsciiOfLength(3); + String paramKey = randomAlphaOfLength(3); + String paramValue = randomAlphaOfLength(3); requestBuilder.setParam(paramKey, paramValue); // Certain headers keys like via and host are illegal and the jdk http client ignores those, so lets // prepend all keys with `_`, so we don't run into a failure because randomly a restricted header was used: - String headerKey = "_" + randomAsciiOfLength(3); - String headerValue = randomAsciiOfLength(3); + String headerKey = "_" + randomAlphaOfLength(3); + String headerValue = randomAlphaOfLength(3); requestBuilder.setHeader(headerKey, headerValue); - requestBuilder.body(randomAsciiOfLength(5)); + requestBuilder.body(randomAlphaOfLength(5)); HttpRequest request = requestBuilder.build(); HttpResponse response = httpClient.execute(request); @@ -434,7 +434,7 @@ public class HttpClientTests extends ESTestCase { public void testMaxHttpResponseSize() throws Exception { int randomBytesLength = scaledRandomIntBetween(2, 100); - String data = randomAsciiOfLength(randomBytesLength); + String data = randomAlphaOfLength(randomBytesLength); webServer.enqueue(new MockResponse().setResponseCode(200).setBody(data)); Settings settings = Settings.builder() diff --git a/plugin/src/test/java/org/elasticsearch/xpack/common/http/HttpConnectionTimeoutTests.java b/plugin/src/test/java/org/elasticsearch/xpack/common/http/HttpConnectionTimeoutTests.java index 6a473df76b4..99760464c20 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/common/http/HttpConnectionTimeoutTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/common/http/HttpConnectionTimeoutTests.java @@ -6,7 +6,6 @@ package org.elasticsearch.xpack.common.http; import org.apache.http.conn.ConnectTimeoutException; -import org.elasticsearch.ElasticsearchTimeoutException; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.env.Environment; @@ -31,7 +30,7 @@ public class HttpConnectionTimeoutTests extends ESTestCase { HttpRequest request = HttpRequest.builder(UNROUTABLE_IP, 12345) .method(HttpMethod.POST) - .path("/" + randomAsciiOfLength(5)) + .path("/" + randomAlphaOfLength(5)) .build(); long start = System.nanoTime(); @@ -57,7 +56,7 @@ public class HttpConnectionTimeoutTests extends ESTestCase { HttpRequest request = HttpRequest.builder(UNROUTABLE_IP, 12345) .method(HttpMethod.POST) - .path("/" + randomAsciiOfLength(5)) + .path("/" + randomAlphaOfLength(5)) .build(); long start = System.nanoTime(); @@ -84,7 +83,7 @@ public class HttpConnectionTimeoutTests extends ESTestCase { HttpRequest request = HttpRequest.builder(UNROUTABLE_IP, 12345) .connectionTimeout(TimeValue.timeValueSeconds(5)) .method(HttpMethod.POST) - .path("/" + randomAsciiOfLength(5)) + .path("/" + randomAlphaOfLength(5)) .build(); long start = System.nanoTime(); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/common/http/HttpRequestTemplateTests.java b/plugin/src/test/java/org/elasticsearch/xpack/common/http/HttpRequestTemplateTests.java index a4df949e194..860ff54231a 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/common/http/HttpRequestTemplateTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/common/http/HttpRequestTemplateTests.java @@ -78,7 +78,7 @@ public class HttpRequestTemplateTests extends ESTestCase { HttpRequestTemplate.Builder builder = HttpRequestTemplate.builder("_host", 1234); builder.path("/path"); builder.method(randomFrom(HttpMethod.values())); - String proxyHost = randomAsciiOfLength(10); + String proxyHost = randomAlphaOfLength(10); int proxyPort = randomIntBetween(1, 65534); builder.proxy(new HttpProxy(proxyHost, proxyPort)); HttpRequestTemplate template = builder.build(); @@ -129,7 +129,7 @@ public class HttpRequestTemplateTests extends ESTestCase { } boolean enableProxy = randomBoolean(); if (enableProxy) { - builder.proxy(new HttpProxy(randomAsciiOfLength(10), randomIntBetween(1, 65534))); + builder.proxy(new HttpProxy(randomAlphaOfLength(10), randomIntBetween(1, 65534))); } HttpRequestTemplate template = builder.build(); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/common/http/HttpRequestTests.java b/plugin/src/test/java/org/elasticsearch/xpack/common/http/HttpRequestTests.java index e1a5f512749..94ab306f632 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/common/http/HttpRequestTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/common/http/HttpRequestTests.java @@ -79,7 +79,7 @@ public class HttpRequestTests extends ESTestCase { if (randomBoolean()) { builder.scheme(randomFrom(Scheme.values())); if (usually()) { - builder.path(randomAsciiOfLength(50)); + builder.path(randomAlphaOfLength(50)); } } } @@ -87,22 +87,22 @@ public class HttpRequestTests extends ESTestCase { builder.method(randomFrom(HttpMethod.values())); } if (randomBoolean()) { - builder.setParam(randomAsciiOfLength(10), randomAsciiOfLength(10)); + builder.setParam(randomAlphaOfLength(10), randomAlphaOfLength(10)); if (randomBoolean()) { - builder.setParam(randomAsciiOfLength(10), randomAsciiOfLength(10)); + builder.setParam(randomAlphaOfLength(10), randomAlphaOfLength(10)); } } if (randomBoolean()) { - builder.setHeader(randomAsciiOfLength(10), randomAsciiOfLength(10)); + builder.setHeader(randomAlphaOfLength(10), randomAlphaOfLength(10)); if (randomBoolean()) { - builder.setHeader(randomAsciiOfLength(10), randomAsciiOfLength(10)); + builder.setHeader(randomAlphaOfLength(10), randomAlphaOfLength(10)); } } if (randomBoolean()) { - builder.auth(new BasicAuth(randomAsciiOfLength(10), randomAsciiOfLength(20).toCharArray())); + builder.auth(new BasicAuth(randomAlphaOfLength(10), randomAlphaOfLength(20).toCharArray())); } if (randomBoolean()) { - builder.body(randomAsciiOfLength(200)); + builder.body(randomAlphaOfLength(200)); } if (randomBoolean()) { builder.connectionTimeout(TimeValue.parseTimeValue(randomTimeValue(), "my.setting")); @@ -111,7 +111,7 @@ public class HttpRequestTests extends ESTestCase { builder.readTimeout(TimeValue.parseTimeValue(randomTimeValue(), "my.setting")); } if (randomBoolean()) { - builder.proxy(new HttpProxy(randomAsciiOfLength(10), randomIntBetween(1024, 65000))); + builder.proxy(new HttpProxy(randomAlphaOfLength(10), randomIntBetween(1024, 65000))); } final HttpRequest httpRequest = builder.build(); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/common/http/SizeLimitInputStreamTests.java b/plugin/src/test/java/org/elasticsearch/xpack/common/http/SizeLimitInputStreamTests.java index 5cad3fc3fa1..66ef5f35361 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/common/http/SizeLimitInputStreamTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/common/http/SizeLimitInputStreamTests.java @@ -39,7 +39,7 @@ public class SizeLimitInputStreamTests extends ESTestCase { } private void test(int inputStreamLength, int maxAllowedSize) throws IOException { - String data = randomAsciiOfLength(inputStreamLength); + String data = randomAlphaOfLength(inputStreamLength); ByteSizeValue byteSizeValue = new ByteSizeValue(maxAllowedSize, ByteSizeUnit.BYTES); SizeLimitInputStream is = new SizeLimitInputStream(byteSizeValue, new ByteArrayInputStream(data.getBytes(UTF_8))); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/CloseJobActionRequestTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/CloseJobActionRequestTests.java index d2d72bcb28c..321d1c27907 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/CloseJobActionRequestTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/CloseJobActionRequestTests.java @@ -32,7 +32,7 @@ public class CloseJobActionRequestTests extends AbstractStreamableXContentTestCa @Override protected Request createTestInstance() { - Request request = new Request(randomAsciiOfLengthBetween(1, 20)); + Request request = new Request(randomAlphaOfLengthBetween(1, 20)); if (randomBoolean()) { request.setCloseTimeout(TimeValue.timeValueMillis(randomNonNegativeLong())); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/CreateFilterActionRequestTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/CreateFilterActionRequestTests.java index 6ba252ddf83..4dc20dd9b53 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/CreateFilterActionRequestTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/CreateFilterActionRequestTests.java @@ -20,9 +20,9 @@ public class CreateFilterActionRequestTests extends AbstractStreamableXContentTe int size = randomInt(10); List items = new ArrayList<>(size); for (int i = 0; i < size; i++) { - items.add(randomAsciiOfLengthBetween(1, 20)); + items.add(randomAlphaOfLengthBetween(1, 20)); } - MlFilter filter = new MlFilter(randomAsciiOfLengthBetween(1, 20), items); + MlFilter filter = new MlFilter(randomAlphaOfLengthBetween(1, 20), items); return new PutFilterAction.Request(filter); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/DeleteDatafeedRequestTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/DeleteDatafeedRequestTests.java index 0f1b24b0b9c..6ea4dbb5966 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/DeleteDatafeedRequestTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/DeleteDatafeedRequestTests.java @@ -12,7 +12,7 @@ public class DeleteDatafeedRequestTests extends AbstractStreamableTestCase { @Override protected Request createTestInstance() { - return new Request(randomAsciiOfLengthBetween(1, 20)); + return new Request(randomAlphaOfLengthBetween(1, 20)); } @Override diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetBucketActionRequestTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetBucketActionRequestTests.java index cff53d3080c..d9bc4e2a4c6 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetBucketActionRequestTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetBucketActionRequestTests.java @@ -14,13 +14,13 @@ public class GetBucketActionRequestTests extends AbstractStreamableXContentTestC @Override protected Request createTestInstance() { - GetBucketsAction.Request request = new GetBucketsAction.Request(randomAsciiOfLengthBetween(1, 20)); + GetBucketsAction.Request request = new GetBucketsAction.Request(randomAlphaOfLengthBetween(1, 20)); if (randomBoolean()) { request.setTimestamp(String.valueOf(randomLong())); } else { if (randomBoolean()) { - request.setPartitionValue(randomAsciiOfLengthBetween(1, 20)); + request.setPartitionValue(randomAlphaOfLengthBetween(1, 20)); } if (randomBoolean()) { request.setStart(String.valueOf(randomLong())); @@ -35,7 +35,7 @@ public class GetBucketActionRequestTests extends AbstractStreamableXContentTestC request.setAnomalyScore(randomDouble()); } if (randomBoolean()) { - request.setPartitionValue(randomAsciiOfLengthBetween(1, 20)); + request.setPartitionValue(randomAlphaOfLengthBetween(1, 20)); } if (randomBoolean()) { int from = randomInt(PageParams.MAX_FROM_SIZE_SUM); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetBucketActionResponseTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetBucketActionResponseTests.java index d8fd9e5b386..f0ff377aee9 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetBucketActionResponseTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetBucketActionResponseTests.java @@ -41,7 +41,7 @@ public class GetBucketActionResponseTests extends AbstractStreamableTestCase partitionScores = new ArrayList<>(size); for (int i = 0; i < size; i++) { - partitionScores.add(new PartitionScore(randomAsciiOfLengthBetween(1, 20), randomAsciiOfLengthBetween(1, 20), + partitionScores.add(new PartitionScore(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20), randomDouble(), randomDouble(), randomDouble())); } bucket.setPartitionScores(partitionScores); @@ -71,7 +71,7 @@ public class GetBucketActionResponseTests extends AbstractStreamableTestCase perPartitionMaxProbability = new HashMap<>(size); for (int i = 0; i < size; i++) { - perPartitionMaxProbability.put(randomAsciiOfLengthBetween(1, 20), randomDouble()); + perPartitionMaxProbability.put(randomAlphaOfLengthBetween(1, 20), randomDouble()); } bucket.setPerPartitionMaxProbability(perPartitionMaxProbability); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetCategoriesRequestTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetCategoriesRequestTests.java index ce7c870b3c3..d842b60178d 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetCategoriesRequestTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetCategoriesRequestTests.java @@ -13,10 +13,10 @@ public class GetCategoriesRequestTests extends AbstractStreamableXContentTestCas @Override protected GetCategoriesAction.Request createTestInstance() { - String jobId = randomAsciiOfLength(10); + String jobId = randomAlphaOfLength(10); GetCategoriesAction.Request request = new GetCategoriesAction.Request(jobId); if (randomBoolean()) { - request.setCategoryId(randomAsciiOfLength(10)); + request.setCategoryId(randomAlphaOfLength(10)); } else { int from = randomInt(PageParams.MAX_FROM_SIZE_SUM); int maxSize = PageParams.MAX_FROM_SIZE_SUM - from; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetCategoriesResponseTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetCategoriesResponseTests.java index c3fa85ce8b0..2d0e9a66242 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetCategoriesResponseTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetCategoriesResponseTests.java @@ -15,7 +15,7 @@ public class GetCategoriesResponseTests extends AbstractStreamableTestCase queryPage = new QueryPage<>(Collections.singletonList(definition), 1L, CategoryDefinition.RESULTS_FIELD); return new GetCategoriesAction.Response(queryPage); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedStatsActionRequestTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedStatsActionRequestTests.java index bb1b612bcbf..d74757f870a 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedStatsActionRequestTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedStatsActionRequestTests.java @@ -13,7 +13,7 @@ public class GetDatafeedStatsActionRequestTests extends AbstractStreamableTestCa @Override protected Request createTestInstance() { - return new Request(randomBoolean() ? Job.ALL : randomAsciiOfLengthBetween(1, 20)); + return new Request(randomBoolean() ? Job.ALL : randomAlphaOfLengthBetween(1, 20)); } @Override diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedStatsActionResponseTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedStatsActionResponseTests.java index 2535ec49653..810e4e7ee52 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedStatsActionResponseTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedStatsActionResponseTests.java @@ -27,7 +27,7 @@ public class GetDatafeedStatsActionResponseTests extends AbstractStreamableTestC int listSize = randomInt(10); List datafeedStatsList = new ArrayList<>(listSize); for (int j = 0; j < listSize; j++) { - String datafeedId = randomAsciiOfLength(10); + String datafeedId = randomAlphaOfLength(10); DatafeedState datafeedState = randomFrom(DatafeedState.values()); DiscoveryNode node = null; @@ -36,7 +36,7 @@ public class GetDatafeedStatsActionResponseTests extends AbstractStreamableTestC } String explanation = null; if (randomBoolean()) { - explanation = randomAsciiOfLength(3); + explanation = randomAlphaOfLength(3); } Response.DatafeedStats datafeedStats = new Response.DatafeedStats(datafeedId, datafeedState, node, explanation); datafeedStatsList.add(datafeedStats); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedsActionRequestTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedsActionRequestTests.java index add0a9e9115..3c535175e00 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedsActionRequestTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedsActionRequestTests.java @@ -13,7 +13,7 @@ public class GetDatafeedsActionRequestTests extends AbstractStreamableTestCase datafeedList = new ArrayList<>(listSize); for (int j = 0; j < listSize; j++) { - datafeedList.add(DatafeedConfigTests.createRandomizedDatafeedConfig(randomAsciiOfLength(10))); + datafeedList.add(DatafeedConfigTests.createRandomizedDatafeedConfig(randomAlphaOfLength(10))); } return new Response(new QueryPage<>(datafeedList, datafeedList.size(), DatafeedConfig.RESULTS_FIELD)); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetFiltersActionRequestTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetFiltersActionRequestTests.java index 28bfa96178f..3c29c7d0ed7 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetFiltersActionRequestTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetFiltersActionRequestTests.java @@ -16,7 +16,7 @@ public class GetFiltersActionRequestTests extends AbstractStreamableTestCase result; MlFilter doc = new MlFilter( - randomAsciiOfLengthBetween(1, 20), Collections.singletonList(randomAsciiOfLengthBetween(1, 20))); + randomAlphaOfLengthBetween(1, 20), Collections.singletonList(randomAlphaOfLengthBetween(1, 20))); result = new QueryPage<>(Collections.singletonList(doc), 1, MlFilter.RESULTS_FIELD); return new Response(result); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetInfluencersActionRequestTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetInfluencersActionRequestTests.java index 22dd4476fb7..1ab12ba055a 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetInfluencersActionRequestTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetInfluencersActionRequestTests.java @@ -19,13 +19,13 @@ public class GetInfluencersActionRequestTests extends AbstractStreamableXContent @Override protected Request createTestInstance() { - Request request = new Request(randomAsciiOfLengthBetween(1, 20)); + Request request = new Request(randomAlphaOfLengthBetween(1, 20)); if (randomBoolean()) { - String start = randomBoolean() ? randomAsciiOfLengthBetween(1, 20) : String.valueOf(randomNonNegativeLong()); + String start = randomBoolean() ? randomAlphaOfLengthBetween(1, 20) : String.valueOf(randomNonNegativeLong()); request.setStart(start); } if (randomBoolean()) { - String end = randomBoolean() ? randomAsciiOfLengthBetween(1, 20) : String.valueOf(randomNonNegativeLong()); + String end = randomBoolean() ? randomAlphaOfLengthBetween(1, 20) : String.valueOf(randomNonNegativeLong()); request.setEnd(end); } if (randomBoolean()) { @@ -35,7 +35,7 @@ public class GetInfluencersActionRequestTests extends AbstractStreamableXContent request.setIncludeInterim(randomBoolean()); } if (randomBoolean()) { - request.setSort(randomAsciiOfLengthBetween(1, 20)); + request.setSort(randomAlphaOfLengthBetween(1, 20)); } if (randomBoolean()) { request.setDecending(randomBoolean()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetInfluencersActionResponseTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetInfluencersActionResponseTests.java index 29230e3409f..9cbbc920c4a 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetInfluencersActionResponseTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetInfluencersActionResponseTests.java @@ -21,8 +21,8 @@ public class GetInfluencersActionResponseTests extends AbstractStreamableTestCas int listSize = randomInt(10); List hits = new ArrayList<>(listSize); for (int j = 0; j < listSize; j++) { - Influencer influencer = new Influencer(randomAsciiOfLengthBetween(1, 20), randomAsciiOfLengthBetween(1, 20), - randomAsciiOfLengthBetween(1, 20), new Date(randomNonNegativeLong()), randomNonNegativeLong(), j + 1); + Influencer influencer = new Influencer(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20), + randomAlphaOfLengthBetween(1, 20), new Date(randomNonNegativeLong()), randomNonNegativeLong(), j + 1); influencer.setInfluencerScore(randomDouble()); influencer.setInitialInfluencerScore(randomDouble()); influencer.setProbability(randomDouble()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetJobStatsActionRequestTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetJobStatsActionRequestTests.java index 19fdc305606..f08bc326f53 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetJobStatsActionRequestTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetJobStatsActionRequestTests.java @@ -13,7 +13,7 @@ public class GetJobStatsActionRequestTests extends AbstractStreamableTestCase jobStatsList = new ArrayList<>(listSize); for (int j = 0; j < listSize; j++) { - String jobId = randomAsciiOfLength(10); + String jobId = randomAlphaOfLength(10); DataCounts dataCounts = new DataCountsTests().createTestInstance(); @@ -50,7 +50,7 @@ public class GetJobStatsActionResponseTests extends AbstractStreamableTestCase hits = new ArrayList<>(listSize); - String jobId = randomAsciiOfLengthBetween(1, 20); + String jobId = randomAlphaOfLengthBetween(1, 20); for (int j = 0; j < listSize; j++) { AnomalyRecord record = new AnomalyRecord(jobId, new Date(), 600, j + 1); hits.add(record); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/OpenJobActionRequestTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/OpenJobActionRequestTests.java index 414f2373e2f..affb27757ee 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/OpenJobActionRequestTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/OpenJobActionRequestTests.java @@ -14,7 +14,7 @@ public class OpenJobActionRequestTests extends AbstractStreamableXContentTestCas @Override protected Request createTestInstance() { - Request request = new Request(randomAsciiOfLengthBetween(1, 20)); + Request request = new Request(randomAlphaOfLengthBetween(1, 20)); if (randomBoolean()) { request.setTimeout(TimeValue.timeValueMillis(randomNonNegativeLong())); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PostDataActionRequestTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PostDataActionRequestTests.java index aa58a04eb41..886904f412a 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PostDataActionRequestTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PostDataActionRequestTests.java @@ -14,17 +14,17 @@ import org.elasticsearch.xpack.ml.support.AbstractStreamableTestCase; public class PostDataActionRequestTests extends AbstractStreamableTestCase { @Override protected PostDataAction.Request createTestInstance() { - PostDataAction.Request request = new PostDataAction.Request(randomAsciiOfLengthBetween(1, 20)); + PostDataAction.Request request = new PostDataAction.Request(randomAlphaOfLengthBetween(1, 20)); if (randomBoolean()) { - request.setResetStart(randomAsciiOfLengthBetween(1, 20)); + request.setResetStart(randomAlphaOfLengthBetween(1, 20)); } if (randomBoolean()) { - request.setResetEnd(randomAsciiOfLengthBetween(1, 20)); + request.setResetEnd(randomAlphaOfLengthBetween(1, 20)); } if (randomBoolean()) { request.setDataDescription(new DataDescription(randomFrom(DataFormat.values()), - randomAsciiOfLengthBetween(1, 20), randomAsciiOfLengthBetween(1, 20), - randomAsciiOfLength(1).charAt(0), randomAsciiOfLength(1).charAt(0))); + randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20), + randomAlphaOfLength(1).charAt(0), randomAlphaOfLength(1).charAt(0))); } if (randomBoolean()) { request.setContent(new BytesArray(new byte[0]), randomFrom(XContentType.values())); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PostDataFlushRequestTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PostDataFlushRequestTests.java index a7a55702e09..7858acab119 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PostDataFlushRequestTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PostDataFlushRequestTests.java @@ -12,16 +12,16 @@ public class PostDataFlushRequestTests extends AbstractStreamableTestCase updates = null; if (randomBoolean()) { int detectorUpdateCount = randomIntBetween(0, 5); for (int i = 0; i < detectorUpdateCount; i++) { - new JobUpdate.DetectorUpdate(randomInt(), randomAsciiOfLength(10), null); + new JobUpdate.DetectorUpdate(randomInt(), randomAlphaOfLength(10), null); } } - return new UpdateProcessAction.Request(randomAsciiOfLength(10), config, updates); + return new UpdateProcessAction.Request(randomAlphaOfLength(10), config, updates); } @Override diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/ValidateDetectorActionRequestTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/ValidateDetectorActionRequestTests.java index 95ad22d5698..c34f1ef5aa7 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/ValidateDetectorActionRequestTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/ValidateDetectorActionRequestTests.java @@ -18,7 +18,7 @@ public class ValidateDetectorActionRequestTests extends AbstractStreamableXConte if (randomBoolean()) { detector = new Detector.Builder(randomFrom(Detector.COUNT_WITHOUT_FIELD_FUNCTIONS), null); } else { - detector = new Detector.Builder(randomFrom(Detector.FIELD_NAME_FUNCTIONS), randomAsciiOfLengthBetween(1, 20)); + detector = new Detector.Builder(randomFrom(Detector.FIELD_NAME_FUNCTIONS), randomAlphaOfLengthBetween(1, 20)); } return new Request(detector.build()); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/util/QueryPageTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/util/QueryPageTests.java index 19102c3fa99..528818bd772 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/util/QueryPageTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/util/QueryPageTests.java @@ -20,8 +20,8 @@ public class QueryPageTests extends AbstractWireSerializingTestCase hits = new ArrayList<>(); for (int i = 0; i < hitCount; i++) { - hits.add(new Influencer(randomAsciiOfLengthBetween(1, 20), randomAsciiOfLengthBetween(1, 20), - randomAsciiOfLengthBetween(1, 20), new Date(), randomNonNegativeLong(), i + 1)); + hits.add(new Influencer(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20), + randomAlphaOfLengthBetween(1, 20), new Date(), randomNonNegativeLong(), i + 1)); } return new QueryPage<>(hits, hitCount, new ParseField("test")); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedConfigTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedConfigTests.java index 31fb135e3b8..edcec740638 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedConfigTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedConfigTests.java @@ -36,7 +36,7 @@ public class DatafeedConfigTests extends AbstractSerializingTestCase scriptFields = new ArrayList<>(scriptsSize); for (int scriptIndex = 0; scriptIndex < scriptsSize; scriptIndex++) { - scriptFields.add(new SearchSourceBuilder.ScriptField(randomAsciiOfLength(10), new Script(randomAsciiOfLength(10)), + scriptFields.add(new SearchSourceBuilder.ScriptField(randomAlphaOfLength(10), new Script(randomAlphaOfLength(10)), randomBoolean())); } builder.setScriptFields(scriptFields); @@ -93,7 +93,7 @@ public class DatafeedConfigTests extends AbstractSerializingTestCase list = new ArrayList<>(); for (int i = 0; i < size; i++) { - list.add(randomAsciiOfLength(10)); + list.add(randomAlphaOfLength(10)); } return list; } @@ -191,8 +191,8 @@ public class DatafeedConfigTests extends AbstractSerializingTestCase datafeed.build()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedUpdateTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedUpdateTests.java index 49c77e8d4d7..5cec14358de 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedUpdateTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedUpdateTests.java @@ -32,7 +32,7 @@ public class DatafeedUpdateTests extends AbstractSerializingTestCase scriptFields = new ArrayList<>(scriptsSize); for (int scriptIndex = 0; scriptIndex < scriptsSize; scriptIndex++) { - scriptFields.add(new SearchSourceBuilder.ScriptField(randomAsciiOfLength(10), new Script(randomAsciiOfLength(10)), + scriptFields.add(new SearchSourceBuilder.ScriptField(randomAlphaOfLength(10), new Script(randomAlphaOfLength(10)), randomBoolean())); } builder.setScriptFields(scriptFields); @@ -63,7 +63,7 @@ public class DatafeedUpdateTests extends AbstractSerializingTestCase timestamps, List field1Values, List field2Values) { SearchResponse searchResponse = mock(SearchResponse.class); when(searchResponse.status()).thenReturn(RestStatus.OK); - when(searchResponse.getScrollId()).thenReturn(randomAsciiOfLength(1000)); + when(searchResponse.getScrollId()).thenReturn(randomAlphaOfLength(1000)); List hits = new ArrayList<>(); for (int i = 0; i < timestamps.size(); i++) { SearchHit hit = new SearchHit(randomInt()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectResultProcessorIT.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectResultProcessorIT.java index 5eab63fbb1c..b19962c7307 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectResultProcessorIT.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectResultProcessorIT.java @@ -263,7 +263,7 @@ public class AutodetectResultProcessorIT extends ESSingleNodeTestCase { for (int i=0; i { public void testSetValues() { @@ -49,7 +44,7 @@ public class ConditionTests extends AbstractSerializingTestCase { condition = new Condition(op, Double.toString(randomDouble())); break; case MATCH: - condition = new Condition(op, randomAsciiOfLengthBetween(1, 20)); + condition = new Condition(op, randomAlphaOfLengthBetween(1, 20)); break; default: throw new AssertionError("Unknown operator selected: " + op); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/DataDescriptionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/DataDescriptionTests.java index 2337bd82fe6..a4514494b52 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/DataDescriptionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/DataDescriptionTests.java @@ -240,7 +240,7 @@ public class DataDescriptionTests extends AbstractSerializingTestCase ruleConditions = new ArrayList<>(size); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/DetectorTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/DetectorTests.java index 590cf1efcc0..fc0800acfe8 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/DetectorTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/DetectorTests.java @@ -136,18 +136,18 @@ public class DetectorTests extends AbstractSerializingTestCase { } else { Set functions = new HashSet<>(Detector.FIELD_NAME_FUNCTIONS); functions.removeAll(Detector.Builder.FUNCTIONS_WITHOUT_RULE_SUPPORT); - detector = new Detector.Builder(function = randomFrom(functions), randomAsciiOfLengthBetween(1, 20)); + detector = new Detector.Builder(function = randomFrom(functions), randomAlphaOfLengthBetween(1, 20)); } if (randomBoolean()) { - detector.setDetectorDescription(randomAsciiOfLengthBetween(1, 20)); + detector.setDetectorDescription(randomAlphaOfLengthBetween(1, 20)); } String fieldName = null; if (randomBoolean()) { - detector.setPartitionFieldName(fieldName = randomAsciiOfLengthBetween(1, 20)); + detector.setPartitionFieldName(fieldName = randomAlphaOfLengthBetween(1, 20)); } else if (randomBoolean() && Detector.NO_OVER_FIELD_NAME_FUNCTIONS.contains(function) == false) { - detector.setOverFieldName(fieldName = randomAsciiOfLengthBetween(1, 20)); + detector.setOverFieldName(fieldName = randomAlphaOfLengthBetween(1, 20)); } else if (randomBoolean() && Detector.NO_BY_FIELD_NAME_FUNCTIONS.contains(function) == false) { - detector.setByFieldName(fieldName = randomAsciiOfLengthBetween(1, 20)); + detector.setByFieldName(fieldName = randomAlphaOfLengthBetween(1, 20)); } if (randomBoolean()) { detector.setExcludeFrequent(randomFrom(Detector.ExcludeFrequent.values())); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobBuilderTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobBuilderTests.java index 3b37013f2d0..25212804f4f 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobBuilderTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobBuilderTests.java @@ -23,7 +23,7 @@ public class JobBuilderTests extends AbstractSerializingTestCase { builder.setId(randomValidJobId()); } if (randomBoolean()) { - builder.setDescription(randomAsciiOfLength(10)); + builder.setDescription(randomAlphaOfLength(10)); } if (randomBoolean()) { builder.setCreateTime(new Date(randomNonNegativeLong())); @@ -48,7 +48,7 @@ public class JobBuilderTests extends AbstractSerializingTestCase { } if (randomBoolean()) { builder.setModelPlotConfig(new ModelPlotConfig(randomBoolean(), - randomAsciiOfLength(10))); + randomAlphaOfLength(10))); } if (randomBoolean()) { builder.setRenormalizationWindowDays(randomNonNegativeLong()); @@ -63,11 +63,11 @@ public class JobBuilderTests extends AbstractSerializingTestCase { builder.setResultsRetentionDays(randomNonNegativeLong()); } if (randomBoolean()) { - builder.setCustomSettings(Collections.singletonMap(randomAsciiOfLength(10), - randomAsciiOfLength(10))); + builder.setCustomSettings(Collections.singletonMap(randomAlphaOfLength(10), + randomAlphaOfLength(10))); } if (randomBoolean()) { - builder.setModelSnapshotId(randomAsciiOfLength(10)); + builder.setModelSnapshotId(randomAlphaOfLength(10)); } if (randomBoolean()) { builder.setResultsIndexName(randomValidJobId()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobTests.java index 5c7071c1bad..cc082900fc6 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobTests.java @@ -382,7 +382,7 @@ public class JobTests extends AbstractSerializingTestCase { String jobId = randomValidJobId(); Job.Builder builder = new Job.Builder(jobId); if (randomBoolean()) { - builder.setDescription(randomAsciiOfLength(10)); + builder.setDescription(randomAlphaOfLength(10)); } builder.setCreateTime(new Date(randomNonNegativeLong())); if (randomBoolean()) { @@ -399,7 +399,7 @@ public class JobTests extends AbstractSerializingTestCase { builder.setDataDescription(dataDescription); } if (randomBoolean()) { - builder.setModelPlotConfig(new ModelPlotConfig(randomBoolean(), randomAsciiOfLength(10))); + builder.setModelPlotConfig(new ModelPlotConfig(randomBoolean(), randomAlphaOfLength(10))); } if (randomBoolean()) { builder.setRenormalizationWindowDays(randomNonNegativeLong()); @@ -414,10 +414,10 @@ public class JobTests extends AbstractSerializingTestCase { builder.setResultsRetentionDays(randomNonNegativeLong()); } if (randomBoolean()) { - builder.setCustomSettings(Collections.singletonMap(randomAsciiOfLength(10), randomAsciiOfLength(10))); + builder.setCustomSettings(Collections.singletonMap(randomAlphaOfLength(10), randomAlphaOfLength(10))); } if (randomBoolean()) { - builder.setModelSnapshotId(randomAsciiOfLength(10)); + builder.setModelSnapshotId(randomAlphaOfLength(10)); } if (randomBoolean()) { builder.setResultsIndexName(randomValidJobId()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobUpdateTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobUpdateTests.java index 3ddf5b513ca..0635fe58d8f 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobUpdateTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobUpdateTests.java @@ -23,9 +23,9 @@ public class JobUpdateTests extends AbstractSerializingTestCase { @Override protected JobUpdate createTestInstance() { - JobUpdate.Builder update = new JobUpdate.Builder(randomAsciiOfLength(4)); + JobUpdate.Builder update = new JobUpdate.Builder(randomAlphaOfLength(4)); if (randomBoolean()) { - update.setDescription(randomAsciiOfLength(20)); + update.setDescription(randomAlphaOfLength(20)); } if (randomBoolean()) { List detectorUpdates = null; @@ -34,7 +34,7 @@ public class JobUpdateTests extends AbstractSerializingTestCase { for (int i = 0; i < size; i++) { String detectorDescription = null; if (randomBoolean()) { - detectorDescription = randomAsciiOfLength(12); + detectorDescription = randomAlphaOfLength(12); } List detectionRules = null; if (randomBoolean()) { @@ -48,7 +48,7 @@ public class JobUpdateTests extends AbstractSerializingTestCase { update.setDetectorUpdates(detectorUpdates); } if (randomBoolean()) { - update.setModelPlotConfig(new ModelPlotConfig(randomBoolean(), randomAsciiOfLength(10))); + update.setModelPlotConfig(new ModelPlotConfig(randomBoolean(), randomAlphaOfLength(10))); } if (randomBoolean()) { update.setAnalysisLimits(new AnalysisLimits(randomNonNegativeLong(), randomNonNegativeLong())); @@ -69,10 +69,10 @@ public class JobUpdateTests extends AbstractSerializingTestCase { update.setCategorizationFilters(Arrays.asList(generateRandomStringArray(10, 10, false))); } if (randomBoolean()) { - update.setCustomSettings(Collections.singletonMap(randomAsciiOfLength(10), randomAsciiOfLength(10))); + update.setCustomSettings(Collections.singletonMap(randomAlphaOfLength(10), randomAlphaOfLength(10))); } if (randomBoolean()) { - update.setModelSnapshotId(randomAsciiOfLength(10)); + update.setModelSnapshotId(randomAlphaOfLength(10)); } return update.build(); @@ -99,10 +99,10 @@ public class JobUpdateTests extends AbstractSerializingTestCase { new RuleCondition(RuleConditionType.NUMERICAL_ACTUAL, null, null, new Condition(Operator.GT, "5"), null)))); detectorUpdates.add(new JobUpdate.DetectorUpdate(1, "description-2", detectionRules2)); - ModelPlotConfig modelPlotConfig = new ModelPlotConfig(randomBoolean(), randomAsciiOfLength(10)); + ModelPlotConfig modelPlotConfig = new ModelPlotConfig(randomBoolean(), randomAlphaOfLength(10)); AnalysisLimits analysisLimits = new AnalysisLimits(randomNonNegativeLong(), randomNonNegativeLong()); List categorizationFilters = Arrays.asList(generateRandomStringArray(10, 10, false)); - Map customSettings = Collections.singletonMap(randomAsciiOfLength(10), randomAsciiOfLength(10)); + Map customSettings = Collections.singletonMap(randomAlphaOfLength(10), randomAlphaOfLength(10)); JobUpdate.Builder updateBuilder = new JobUpdate.Builder("foo"); updateBuilder.setDescription("updated_description"); @@ -115,7 +115,7 @@ public class JobUpdateTests extends AbstractSerializingTestCase { updateBuilder.setRenormalizationWindowDays(randomNonNegativeLong()); updateBuilder.setCategorizationFilters(categorizationFilters); updateBuilder.setCustomSettings(customSettings); - updateBuilder.setModelSnapshotId(randomAsciiOfLength(10)); + updateBuilder.setModelSnapshotId(randomAlphaOfLength(10)); JobUpdate update = updateBuilder.build(); Job.Builder jobBuilder = new Job.Builder("foo"); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/MlFilterTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/MlFilterTests.java index 62b7f0ec080..eb53e99b93b 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/MlFilterTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/MlFilterTests.java @@ -20,9 +20,9 @@ public class MlFilterTests extends AbstractSerializingTestCase { int size = randomInt(10); List items = new ArrayList<>(size); for (int i = 0; i < size; i++) { - items.add(randomAsciiOfLengthBetween(1, 20)); + items.add(randomAlphaOfLengthBetween(1, 20)); } - return new MlFilter(randomAsciiOfLengthBetween(1, 20), items); + return new MlFilter(randomAlphaOfLengthBetween(1, 20), items); } @Override @@ -42,7 +42,7 @@ public class MlFilterTests extends AbstractSerializingTestCase { public void testNullItems() { NullPointerException ex = - expectThrows(NullPointerException.class, () -> new MlFilter(randomAsciiOfLengthBetween(1, 20), null)); + expectThrows(NullPointerException.class, () -> new MlFilter(randomAlphaOfLengthBetween(1, 20), null)); assertEquals(MlFilter.ITEMS.getPreferredName() + " must not be null", ex.getMessage()); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/ModelPlotConfigTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/ModelPlotConfigTests.java index 8e91717a8d9..b046b9f831b 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/ModelPlotConfigTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/ModelPlotConfigTests.java @@ -21,7 +21,7 @@ public class ModelPlotConfigTests extends AbstractSerializingTestCase { @Override public DataCounts createTestInstance() { - return new DataCounts(randomAsciiOfLength(10), randomIntBetween(1, 1_000_000), + return new DataCounts(randomAlphaOfLength(10), randomIntBetween(1, 1_000_000), randomIntBetween(1, 1_000_000), randomIntBetween(1, 1_000_000), randomIntBetween(1, 1_000_000), randomIntBetween(1, 1_000_000), randomIntBetween(1, 1_000_000), randomIntBetween(1, 1_000_000), randomIntBetween(1, 1_000_000), randomIntBetween(1, 1_000_000), randomIntBetween(1, 1_000_000), @@ -59,7 +59,7 @@ public class DataCountsTests extends AbstractSerializingTestCase { } public void testCountCreatedZero() throws Exception { - DataCounts counts = new DataCounts(randomAsciiOfLength(16)); + DataCounts counts = new DataCounts(randomAlphaOfLength(16)); assertAllFieldsEqualZero(counts); } @@ -72,7 +72,7 @@ public class DataCountsTests extends AbstractSerializingTestCase { } public void testIncrements() { - DataCounts counts = new DataCounts(randomAsciiOfLength(16)); + DataCounts counts = new DataCounts(randomAlphaOfLength(16)); counts.incrementInputBytes(15); assertEquals(15, counts.getInputBytes()); @@ -91,7 +91,7 @@ public class DataCountsTests extends AbstractSerializingTestCase { } public void testGetInputRecordCount() { - DataCounts counts = new DataCounts(randomAsciiOfLength(16)); + DataCounts counts = new DataCounts(randomAlphaOfLength(16)); counts.incrementProcessedRecordCount(5); assertEquals(5, counts.getInputRecordCount()); @@ -103,13 +103,13 @@ public class DataCountsTests extends AbstractSerializingTestCase { } public void testCalcProcessedFieldCount() { - DataCounts counts = new DataCounts(randomAsciiOfLength(16), 10L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, new Date(), new Date(), + DataCounts counts = new DataCounts(randomAlphaOfLength(16), 10L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, new Date(), new Date(), new Date(), new Date(), new Date()); counts.calcProcessedFieldCount(3); assertEquals(30, counts.getProcessedFieldCount()); - counts = new DataCounts(randomAsciiOfLength(16), 10L, 0L, 0L, 0L, 0L, 5L, 0L, 0L, 0L, 0L, new Date(), new Date(), + counts = new DataCounts(randomAlphaOfLength(16), 10L, 0L, 0L, 0L, 0L, 5L, 0L, 0L, 0L, 0L, new Date(), new Date(), new Date(), new Date(), new Date()); counts.calcProcessedFieldCount(3); assertEquals(25, counts.getProcessedFieldCount()); @@ -117,7 +117,7 @@ public class DataCountsTests extends AbstractSerializingTestCase { public void testEquals() { DataCounts counts1 = new DataCounts( - randomAsciiOfLength(16), 10L, 5000L, 2000L, 300L, 6L, 15L, 0L, 0L, 0L, 0L, new Date(), new Date(1435000000L), + randomAlphaOfLength(16), 10L, 5000L, 2000L, 300L, 6L, 15L, 0L, 0L, 0L, 0L, new Date(), new Date(1435000000L), new Date(), new Date(), new Date()); DataCounts counts2 = new DataCounts(counts1); @@ -127,7 +127,7 @@ public class DataCountsTests extends AbstractSerializingTestCase { } public void testSetEarliestRecordTimestamp_doesnotOverwrite() { - DataCounts counts = new DataCounts(randomAsciiOfLength(12)); + DataCounts counts = new DataCounts(randomAlphaOfLength(12)); counts.setEarliestRecordTimeStamp(new Date(100L)); expectThrows(IllegalStateException.class, () -> counts.setEarliestRecordTimeStamp(new Date(200L))); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/ModelSizeStatsTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/ModelSizeStatsTests.java index 1e45d00c7bb..b968fe4ba13 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/ModelSizeStatsTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/ModelSizeStatsTests.java @@ -77,7 +77,7 @@ public class ModelSizeStatsTests extends AbstractSerializingTestCase { } public static Quantiles createRandomized() { - return new Quantiles(randomAsciiOfLengthBetween(1, 20), + return new Quantiles(randomAlphaOfLengthBetween(1, 20), new Date(TimeValue.parseTimeValue(randomTimeValue(), "test").millis()), - randomAsciiOfLengthBetween(0, 1000)); + randomAlphaOfLengthBetween(0, 1000)); } @Override diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/AnomalyCauseTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/AnomalyCauseTests.java index a2cc4831577..6f22de14b6c 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/AnomalyCauseTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/AnomalyCauseTests.java @@ -34,34 +34,34 @@ public class AnomalyCauseTests extends AbstractSerializingTestCase anomalyCause.setTypical(typical); } if (randomBoolean()) { - anomalyCause.setByFieldName(randomAsciiOfLengthBetween(1, 20)); + anomalyCause.setByFieldName(randomAlphaOfLengthBetween(1, 20)); } if (randomBoolean()) { - anomalyCause.setByFieldValue(randomAsciiOfLengthBetween(1, 20)); + anomalyCause.setByFieldValue(randomAlphaOfLengthBetween(1, 20)); } if (randomBoolean()) { - anomalyCause.setCorrelatedByFieldValue(randomAsciiOfLengthBetween(1, 20)); + anomalyCause.setCorrelatedByFieldValue(randomAlphaOfLengthBetween(1, 20)); } if (randomBoolean()) { - anomalyCause.setOverFieldName(randomAsciiOfLengthBetween(1, 20)); + anomalyCause.setOverFieldName(randomAlphaOfLengthBetween(1, 20)); } if (randomBoolean()) { - anomalyCause.setOverFieldValue(randomAsciiOfLengthBetween(1, 20)); + anomalyCause.setOverFieldValue(randomAlphaOfLengthBetween(1, 20)); } if (randomBoolean()) { - anomalyCause.setPartitionFieldName(randomAsciiOfLengthBetween(1, 20)); + anomalyCause.setPartitionFieldName(randomAlphaOfLengthBetween(1, 20)); } if (randomBoolean()) { - anomalyCause.setPartitionFieldValue(randomAsciiOfLengthBetween(1, 20)); + anomalyCause.setPartitionFieldValue(randomAlphaOfLengthBetween(1, 20)); } if (randomBoolean()) { - anomalyCause.setFunction(randomAsciiOfLengthBetween(1, 20)); + anomalyCause.setFunction(randomAlphaOfLengthBetween(1, 20)); } if (randomBoolean()) { - anomalyCause.setFunctionDescription(randomAsciiOfLengthBetween(1, 20)); + anomalyCause.setFunctionDescription(randomAlphaOfLengthBetween(1, 20)); } if (randomBoolean()) { - anomalyCause.setFieldName(randomAsciiOfLengthBetween(1, 20)); + anomalyCause.setFieldName(randomAlphaOfLengthBetween(1, 20)); } if (randomBoolean()) { anomalyCause.setProbability(randomDouble()); @@ -73,9 +73,9 @@ public class AnomalyCauseTests extends AbstractSerializingTestCase int fieldValuesSize = randomInt(10); List fieldValues = new ArrayList<>(fieldValuesSize); for (int j = 0; j < fieldValuesSize; j++) { - fieldValues.add(randomAsciiOfLengthBetween(1, 20)); + fieldValues.add(randomAlphaOfLengthBetween(1, 20)); } - influencers.add(new Influence(randomAsciiOfLengthBetween(1, 20), fieldValues)); + influencers.add(new Influence(randomAlphaOfLengthBetween(1, 20), fieldValues)); } anomalyCause.setInfluencers(influencers); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/AnomalyRecordTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/AnomalyRecordTests.java index 183f16eb29f..6fb8d35f88b 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/AnomalyRecordTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/AnomalyRecordTests.java @@ -35,30 +35,30 @@ public class AnomalyRecordTests extends AbstractSerializingTestCase influences = new ArrayList<>(); for (int i=0; i(size); for (int i = 0; i < size; i++) { - Influencer influencer = new Influencer(jobId, randomAsciiOfLength(10), randomAsciiOfLength(10), + Influencer influencer = new Influencer(jobId, randomAlphaOfLength(10), randomAlphaOfLength(10), new Date(randomLong()), randomNonNegativeLong(), i + 1); influencer.setProbability(randomDoubleBetween(0.0, 1.0, true)); influencers.add(influencer); @@ -75,13 +75,13 @@ public class AutodetectResultTests extends AbstractSerializingTestCase { for (int i = 0; i < size; i++) { BucketInfluencer bucketInfluencer = new BucketInfluencer(jobId, new Date(), 600, i + 1); bucketInfluencer.setAnomalyScore(randomDouble()); - bucketInfluencer.setInfluencerFieldName(randomAsciiOfLengthBetween(1, 20)); + bucketInfluencer.setInfluencerFieldName(randomAlphaOfLengthBetween(1, 20)); bucketInfluencer.setInitialAnomalyScore(randomDouble()); bucketInfluencer.setProbability(randomDouble()); bucketInfluencer.setRawAnomalyScore(randomDouble()); @@ -56,7 +56,7 @@ public class BucketTests extends AbstractSerializingTestCase { int size = randomInt(10); List partitionScores = new ArrayList<>(size); for (int i = 0; i < size; i++) { - partitionScores.add(new PartitionScore(randomAsciiOfLengthBetween(1, 20), randomAsciiOfLengthBetween(1, 20), randomDouble(), + partitionScores.add(new PartitionScore(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20), randomDouble(), randomDouble(), randomDouble())); } bucket.setPartitionScores(partitionScores); @@ -65,7 +65,7 @@ public class BucketTests extends AbstractSerializingTestCase { int size = randomInt(10); Map perPartitionMaxProbability = new HashMap<>(size); for (int i = 0; i < size; i++) { - perPartitionMaxProbability.put(randomAsciiOfLengthBetween(1, 20), randomDouble()); + perPartitionMaxProbability.put(randomAlphaOfLengthBetween(1, 20), randomDouble()); } bucket.setPerPartitionMaxProbability(perPartitionMaxProbability); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/CategoryDefinitionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/CategoryDefinitionTests.java index 426f3ded352..2c15c9645f7 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/CategoryDefinitionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/CategoryDefinitionTests.java @@ -16,8 +16,8 @@ public class CategoryDefinitionTests extends AbstractSerializingTestCase { int size = randomInt(10); List fieldValues = new ArrayList<>(size); for (int i = 0; i < size; i++) { - fieldValues.add(randomAsciiOfLengthBetween(1, 20)); + fieldValues.add(randomAlphaOfLengthBetween(1, 20)); } - return new Influence(randomAsciiOfLengthBetween(1, 30), fieldValues); + return new Influence(randomAlphaOfLengthBetween(1, 30), fieldValues); } @Override diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/InfluencerTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/InfluencerTests.java index bc34d0f0b96..8f34caebc36 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/InfluencerTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/InfluencerTests.java @@ -17,7 +17,7 @@ import java.util.Date; public class InfluencerTests extends AbstractSerializingTestCase { public Influencer createTestInstance(String jobId) { - Influencer influencer = new Influencer(jobId, randomAsciiOfLengthBetween(1, 20), randomAsciiOfLengthBetween(1, 20), + Influencer influencer = new Influencer(jobId, randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20), new Date(randomNonNegativeLong()), randomNonNegativeLong(), randomIntBetween(1, 1000)); influencer.setInterim(randomBoolean()); influencer.setInfluencerScore(randomDouble()); @@ -27,7 +27,7 @@ public class InfluencerTests extends AbstractSerializingTestCase { } @Override protected Influencer createTestInstance() { - return createTestInstance(randomAsciiOfLengthBetween(1, 20)); + return createTestInstance(randomAlphaOfLengthBetween(1, 20)); } @Override diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/ModelPlotTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/ModelPlotTests.java index 6828854a584..9924c0ae5b3 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/ModelPlotTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/ModelPlotTests.java @@ -21,19 +21,19 @@ public class ModelPlotTests extends AbstractSerializingTestCase { public ModelPlot createTestInstance(String jobId) { ModelPlot modelPlot = new ModelPlot(jobId); if (randomBoolean()) { - modelPlot.setByFieldName(randomAsciiOfLengthBetween(1, 20)); + modelPlot.setByFieldName(randomAlphaOfLengthBetween(1, 20)); } if (randomBoolean()) { - modelPlot.setByFieldValue(randomAsciiOfLengthBetween(1, 20)); + modelPlot.setByFieldValue(randomAlphaOfLengthBetween(1, 20)); } if (randomBoolean()) { - modelPlot.setPartitionFieldName(randomAsciiOfLengthBetween(1, 20)); + modelPlot.setPartitionFieldName(randomAlphaOfLengthBetween(1, 20)); } if (randomBoolean()) { - modelPlot.setPartitionFieldValue(randomAsciiOfLengthBetween(1, 20)); + modelPlot.setPartitionFieldValue(randomAlphaOfLengthBetween(1, 20)); } if (randomBoolean()) { - modelPlot.setModelFeature(randomAsciiOfLengthBetween(1, 20)); + modelPlot.setModelFeature(randomAlphaOfLengthBetween(1, 20)); } if (randomBoolean()) { modelPlot.setModelLower(randomDouble()); @@ -64,13 +64,13 @@ public class ModelPlotTests extends AbstractSerializingTestCase { } public void testEquals_GivenSameObject() { - ModelPlot modelPlot = new ModelPlot(randomAsciiOfLength(15)); + ModelPlot modelPlot = new ModelPlot(randomAlphaOfLength(15)); assertTrue(modelPlot.equals(modelPlot)); } public void testEquals_GivenObjectOfDifferentClass() { - ModelPlot modelPlot = new ModelPlot(randomAsciiOfLength(15)); + ModelPlot modelPlot = new ModelPlot(randomAlphaOfLength(15)); assertFalse(modelPlot.equals("a string")); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/PartitionScoreTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/PartitionScoreTests.java index f866da7e65e..f110af23959 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/PartitionScoreTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/PartitionScoreTests.java @@ -13,7 +13,7 @@ public class PartitionScoreTests extends AbstractSerializingTestCase pps = new ArrayList<>(); for (int i=0; i @Override protected AuditMessage createTestInstance() { - return new AuditMessage(randomAsciiOfLengthBetween(1, 20), randomAsciiOfLengthBetween(1, 200), - randomFrom(Level.values()), randomAsciiOfLengthBetween(1, 20)); + return new AuditMessage(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 200), + randomFrom(Level.values()), randomAlphaOfLengthBetween(1, 20)); } @Override diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoredSystemTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoredSystemTests.java index ba808291350..287f461fee5 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoredSystemTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoredSystemTests.java @@ -33,7 +33,7 @@ public class MonitoredSystemTests extends ESTestCase { } public void testFromUnknownSystem() { - final String unknownSystem = randomAsciiOfLengthBetween(3, 4); + final String unknownSystem = randomAlphaOfLengthBetween(3, 4); IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> { MonitoredSystem.fromSystem(unknownSystem); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringFeatureSetTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringFeatureSetTests.java index 7999fad14c4..a88152556a3 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringFeatureSetTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringFeatureSetTests.java @@ -85,7 +85,7 @@ public class MonitoringFeatureSetTests extends ESTestCase { } } int xCount = randomIntBetween(0, 5); - String xType = randomAsciiOfLength(10); + String xType = randomAlphaOfLength(10); for (int i = 0; i < xCount; i++) { Exporter exporter = mockExporter(xType, true); exporterList.add(exporter); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringSettingsIntegTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringSettingsIntegTests.java index d22d64e1df2..b9cc77db500 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringSettingsIntegTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringSettingsIntegTests.java @@ -165,7 +165,7 @@ public class MonitoringSettingsIntegTests extends MonitoringIntegTestCase { String[] items = new String[size]; for (int i = 0; i < size; i++) { - items[i] = randomAsciiOfLength(5); + items[i] = randomAlphaOfLength(5); } return items; } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkDocTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkDocTests.java index 776e83190bf..06a5ee219a5 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkDocTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkDocTests.java @@ -84,8 +84,8 @@ public class MonitoringBulkDocTests extends ESTestCase { String monitoringVersion = randomVersion(random()).toString(); MonitoringIndex index = randomBoolean() ? randomFrom(MonitoringIndex.values()) : null; String type = randomFrom("type1", "type2", "type3"); - String id = randomBoolean() ? randomAsciiOfLength(3) : null; - String clusterUUID = randomBoolean() ? randomAsciiOfLength(5) : null; + String id = randomBoolean() ? randomAlphaOfLength(3) : null; + String clusterUUID = randomBoolean() ? randomAlphaOfLength(5) : null; long timestamp = randomBoolean() ? randomNonNegativeLong() : 0L; MonitoringDoc.Node sourceNode = randomBoolean() ? newRandomSourceNode() : null; BytesReference source = new BytesArray("{\"key\" : \"value\"}"); @@ -104,13 +104,13 @@ public class MonitoringBulkDocTests extends ESTestCase { Map attributes = null; if (frequently()) { - uuid = randomAsciiOfLength(5); - name = randomAsciiOfLength(5); + uuid = randomAlphaOfLength(5); + name = randomAlphaOfLength(5); } if (randomBoolean()) { - ip = randomAsciiOfLength(5); - transportAddress = randomAsciiOfLength(5); - host = randomAsciiOfLength(3); + ip = randomAlphaOfLength(5); + transportAddress = randomAlphaOfLength(5); + host = randomAlphaOfLength(3); } if (rarely()) { int nbAttributes = randomIntBetween(0, 5); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java index 0817ef3364f..2d6b11d2117 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java @@ -13,7 +13,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.xpack.monitoring.exporter.MonitoringDoc; import org.hamcrest.Matcher; import java.io.IOException; @@ -63,32 +62,32 @@ public class MonitoringBulkRequestTests extends ESTestCase { MonitoringBulkRequest request = new MonitoringBulkRequest(); // Doc0 is complete - MonitoringBulkDoc doc0 = new MonitoringBulkDoc(randomAsciiOfLength(2), - randomAsciiOfLength(2), MonitoringIndex.TIMESTAMPED, randomAsciiOfLength(5), + MonitoringBulkDoc doc0 = new MonitoringBulkDoc(randomAlphaOfLength(2), + randomAlphaOfLength(2), MonitoringIndex.TIMESTAMPED, randomAlphaOfLength(5), null, SOURCE, XContentType.JSON); request.add(doc0); // Doc1 has no type - MonitoringBulkDoc doc1 = new MonitoringBulkDoc(randomAsciiOfLength(2), - randomAsciiOfLength(2), MonitoringIndex.TIMESTAMPED, null, + MonitoringBulkDoc doc1 = new MonitoringBulkDoc(randomAlphaOfLength(2), + randomAlphaOfLength(2), MonitoringIndex.TIMESTAMPED, null, null, SOURCE, XContentType.JSON); request.add(doc1); // Doc2 has no source - MonitoringBulkDoc doc2 = new MonitoringBulkDoc(randomAsciiOfLength(2), - randomAsciiOfLength(2), MonitoringIndex.TIMESTAMPED, randomAsciiOfLength(5), + MonitoringBulkDoc doc2 = new MonitoringBulkDoc(randomAlphaOfLength(2), + randomAlphaOfLength(2), MonitoringIndex.TIMESTAMPED, randomAlphaOfLength(5), null, BytesArray.EMPTY, XContentType.JSON); request.add(doc2); // Doc3 has no version - MonitoringBulkDoc doc3 = new MonitoringBulkDoc(randomAsciiOfLength(2), - null, MonitoringIndex.TIMESTAMPED, randomAsciiOfLength(5), + MonitoringBulkDoc doc3 = new MonitoringBulkDoc(randomAlphaOfLength(2), + null, MonitoringIndex.TIMESTAMPED, randomAlphaOfLength(5), null, SOURCE, XContentType.JSON); request.add(doc3); // Doc4 has no id MonitoringBulkDoc doc4 = new MonitoringBulkDoc(null, - randomAsciiOfLength(2), MonitoringIndex.TIMESTAMPED, randomAsciiOfLength(5), + randomAlphaOfLength(2), MonitoringIndex.TIMESTAMPED, randomAlphaOfLength(5), null, SOURCE, XContentType.JSON); request.add(doc4); @@ -104,8 +103,8 @@ public class MonitoringBulkRequestTests extends ESTestCase { final int nbDocs = randomIntBetween(1, 20); for (int i = 0; i < nbDocs; i++) { request.add(new MonitoringBulkDoc(String.valueOf(i), String.valueOf(i), - randomFrom(MonitoringIndex.values()), randomAsciiOfLength(5), - randomAsciiOfLength(5), SOURCE, XContentType.JSON)); + randomFrom(MonitoringIndex.values()), randomAlphaOfLength(5), + randomAlphaOfLength(5), SOURCE, XContentType.JSON)); } assertThat(request.getDocs(), hasSize(nbDocs)); } @@ -128,7 +127,7 @@ public class MonitoringBulkRequestTests extends ESTestCase { indices[i] = MonitoringIndex.TIMESTAMPED; } if (randomBoolean()) { - types[i] = randomAsciiOfLength(5); + types[i] = randomAlphaOfLength(5); builder.field("_type", types[i]); } builder.endObject().endObject().flush(); @@ -138,9 +137,9 @@ public class MonitoringBulkRequestTests extends ESTestCase { } } - String defaultMonitoringId = randomBoolean() ? randomAsciiOfLength(2) : null; - String defaultMonitoringVersion = randomBoolean() ? randomAsciiOfLength(3) : null; - String defaultType = rarely() ? randomAsciiOfLength(4) : null; + String defaultMonitoringId = randomBoolean() ? randomAlphaOfLength(2) : null; + String defaultMonitoringVersion = randomBoolean() ? randomAlphaOfLength(3) : null; + String defaultType = rarely() ? randomAlphaOfLength(4) : null; MonitoringBulkRequest request = new MonitoringBulkRequest(); request.add(content.bytes(), defaultMonitoringId, defaultMonitoringVersion, defaultType, xContentType); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkResponseTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkResponseTests.java index fafaad6f6ed..b7de7766ecf 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkResponseTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkResponseTests.java @@ -30,7 +30,7 @@ public class MonitoringBulkResponseTests extends ESTestCase { assertThat(response.getError(), is(nullValue())); assertThat(response.status(), equalTo(RestStatus.OK)); - ExportException exception = new ExportException(randomAsciiOfLength(10)); + ExportException exception = new ExportException(randomAlphaOfLength(10)); response = new MonitoringBulkResponse(took, new MonitoringBulkResponse.Error(exception)); assertThat(response.getTookInMillis(), equalTo(took)); @@ -46,9 +46,9 @@ public class MonitoringBulkResponseTests extends ESTestCase { response = new MonitoringBulkResponse(Math.abs(randomLong())); } else { Exception exception = randomFrom( - new ExportException(randomAsciiOfLength(5), new IllegalStateException(randomAsciiOfLength(5))), - new IllegalStateException(randomAsciiOfLength(5)), - new IllegalArgumentException(randomAsciiOfLength(5))); + new ExportException(randomAlphaOfLength(5), new IllegalStateException(randomAlphaOfLength(5))), + new IllegalStateException(randomAlphaOfLength(5)), + new IllegalArgumentException(randomAlphaOfLength(5))); response = new MonitoringBulkResponse(Math.abs(randomLong()), new MonitoringBulkResponse.Error(exception)); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/TransportMonitoringBulkActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/TransportMonitoringBulkActionTests.java index 781790d805c..97d32259d7e 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/TransportMonitoringBulkActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/TransportMonitoringBulkActionTests.java @@ -18,7 +18,6 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.service.ClusterService; -import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.Setting; @@ -251,7 +250,7 @@ public class TransportMonitoringBulkActionTests extends ESTestCase { String monitoringVersion = randomVersion(random()).toString(); MonitoringIndex index = randomBoolean() ? randomFrom(MonitoringIndex.values()) : null; String type = randomFrom("type1", "type2", "type3"); - String id = randomAsciiOfLength(10); + String id = randomAlphaOfLength(10); BytesReference source; XContentType xContentType = randomFrom(XContentType.values()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/AbstractIndicesCleanerTestCase.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/AbstractIndicesCleanerTestCase.java index ccb1ffc7f42..af2cbf33a85 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/AbstractIndicesCleanerTestCase.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/AbstractIndicesCleanerTestCase.java @@ -189,8 +189,8 @@ public abstract class AbstractIndicesCleanerTestCase extends MonitoringIntegTest String monitoringId = randomFrom(MonitoredSystem.values()).getSystem(); String monitoringVersion = randomVersion(random()).toString(); String type = randomFrom("type1", "type2", "type3"); - String id = randomBoolean() ? randomAsciiOfLength(3) : null; - String clusterUUID = randomBoolean() ? randomAsciiOfLength(5) : null; + String id = randomBoolean() ? randomAlphaOfLength(3) : null; + String clusterUUID = randomBoolean() ? randomAlphaOfLength(5) : null; long timestamp = randomBoolean() ? randomNonNegativeLong() : 0L; MonitoringDoc.Node sourceNode = randomBoolean() ? newRandomSourceNode() : null; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringDocTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringDocTests.java index bb922cc085e..2970a6f904d 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringDocTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringDocTests.java @@ -23,11 +23,11 @@ public class MonitoringDocTests extends ESTestCase { public void testFromDiscoveryNode() { assertEquals(null, fromDiscoveryNode(null)); - String nodeId = randomAsciiOfLength(5); + String nodeId = randomAlphaOfLength(5); TransportAddress address = buildNewFakeTransportAddress(); Version version = randomFrom(Version.V_2_4_1, Version.V_5_0_1, Version.CURRENT); - String name = randomBoolean() ? randomAsciiOfLength(5) : ""; + String name = randomBoolean() ? randomAlphaOfLength(5) : ""; Map attributes = new HashMap<>(); if (randomBoolean()) { int nbAttrs = randomIntBetween(1, 5); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulkResponseListenerTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulkResponseListenerTests.java index de5dcd9bbe0..89152e58615 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulkResponseListenerTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulkResponseListenerTests.java @@ -68,7 +68,7 @@ public class HttpExportBulkResponseListenerTests extends ESTestCase { } public void testOnSuccessWithInnerErrors() { - final String[] expectedErrors = new String[] { randomAsciiOfLengthBetween(4, 10), randomAsciiOfLengthBetween(5, 9) }; + final String[] expectedErrors = new String[] { randomAlphaOfLengthBetween(4, 10), randomAlphaOfLengthBetween(5, 9) }; final AtomicInteger counter = new AtomicInteger(0); final Response response = mock(Response.class); final StringEntity entity = new StringEntity( diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java index 2c3da359f74..63e883fd2ea 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java @@ -123,7 +123,7 @@ public class HttpExporterIT extends MonitoringIntegTestCase { final boolean bwcIndexesExist = randomBoolean(); final boolean bwcAliasesExist = randomBoolean(); - final String headerValue = randomAsciiOfLengthBetween(3, 9); + final String headerValue = randomAlphaOfLengthBetween(3, 9); final String[] array = generateRandomStringArray(2, 4, false); final Map headers = new HashMap<>(); @@ -164,7 +164,7 @@ public class HttpExporterIT extends MonitoringIntegTestCase { final boolean bwcIndexesExist = randomBoolean(); final boolean bwcAliasesExist = randomBoolean(); - final String headerValue = randomAsciiOfLengthBetween(3, 9); + final String headerValue = randomAlphaOfLengthBetween(3, 9); final String[] array = generateRandomStringArray(2, 4, false); final Map headers = new HashMap<>(); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpHostBuilderTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpHostBuilderTests.java index 58efe54defe..371ad36a78a 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpHostBuilderTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpHostBuilderTests.java @@ -17,7 +17,7 @@ import static org.hamcrest.Matchers.equalTo; public class HttpHostBuilderTests extends ESTestCase { private final Scheme scheme = randomFrom(Scheme.values()); - private final String hostname = randomAsciiOfLengthBetween(1, 20); + private final String hostname = randomAlphaOfLengthBetween(1, 20); private final int port = randomIntBetween(1, 65535); public void testBuilder() { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/DataResolverTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/DataResolverTests.java index ac7dc5ec782..cb53addc85e 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/DataResolverTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/DataResolverTests.java @@ -27,8 +27,8 @@ public class DataResolverTests extends MonitoringIndexNameResolverTestCase { @Override protected MonitoringDoc newMonitoringDoc() { - MonitoringDoc doc = new MonitoringDoc(randomMonitoringId(), randomAsciiOfLength(2), - null, null, randomAsciiOfLength(5), Math.abs(randomLong()), + MonitoringDoc doc = new MonitoringDoc(randomMonitoringId(), randomAlphaOfLength(2), + null, null, randomAlphaOfLength(5), Math.abs(randomLong()), new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT)); return doc; } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/TimestampedResolverTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/TimestampedResolverTests.java index 45a2a8f5776..03fe35f2d7f 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/TimestampedResolverTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/TimestampedResolverTests.java @@ -36,8 +36,8 @@ public class TimestampedResolverTests extends MonitoringIndexNameResolverTestCas @Override protected MonitoringDoc newMonitoringDoc() { - MonitoringDoc doc = new MonitoringDoc(randomMonitoringId(), randomAsciiOfLength(2), - null, null, randomAsciiOfLength(5), 1437580442979L, // "2015-07-22T15:54:02.979Z" + MonitoringDoc doc = new MonitoringDoc(randomMonitoringId(), randomAlphaOfLength(2), + null, null, randomAlphaOfLength(5), 1437580442979L, // "2015-07-22T15:54:02.979Z" new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT)); return doc; } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/bulk/MonitoringBulkDataResolverTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/bulk/MonitoringBulkDataResolverTests.java index ecaf05119a9..8be3dc8cd1b 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/bulk/MonitoringBulkDataResolverTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/bulk/MonitoringBulkDataResolverTests.java @@ -5,8 +5,6 @@ */ package org.elasticsearch.xpack.monitoring.resolver.bulk; -import org.elasticsearch.Version; -import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.util.set.Sets; import org.elasticsearch.common.xcontent.XContentType; @@ -17,8 +15,6 @@ import org.elasticsearch.xpack.monitoring.action.MonitoringIndex; import org.elasticsearch.xpack.monitoring.exporter.MonitoringTemplateUtils; import org.elasticsearch.xpack.monitoring.resolver.MonitoringIndexNameResolverTestCase; -import static java.util.Collections.emptyMap; -import static java.util.Collections.emptySet; import static org.hamcrest.Matchers.equalTo; /** @@ -26,13 +22,13 @@ import static org.hamcrest.Matchers.equalTo; */ public class MonitoringBulkDataResolverTests extends MonitoringIndexNameResolverTestCase { - private final String id = randomBoolean() ? randomAsciiOfLength(35) : null; + private final String id = randomBoolean() ? randomAlphaOfLength(35) : null; @Override protected MonitoringBulkDoc newMonitoringDoc() { MonitoringBulkDoc doc = new MonitoringBulkDoc(MonitoredSystem.KIBANA.getSystem(), MonitoringTemplateUtils.TEMPLATE_VERSION, MonitoringIndex.DATA, "kibana", id, - randomAsciiOfLength(5), Math.abs(randomLong()), + randomAlphaOfLength(5), Math.abs(randomLong()), MonitoringBulkDocTests.newRandomSourceNode(), new BytesArray("{\"field1\" : \"value1\"}"), XContentType.JSON); return doc; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/bulk/MonitoringBulkTimestampedResolverTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/bulk/MonitoringBulkTimestampedResolverTests.java index a6194cb163e..7cd1fd1dea0 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/bulk/MonitoringBulkTimestampedResolverTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/bulk/MonitoringBulkTimestampedResolverTests.java @@ -28,8 +28,8 @@ public class MonitoringBulkTimestampedResolverTests MonitoringBulkDoc doc = new MonitoringBulkDoc(MonitoredSystem.KIBANA.getSystem(), MonitoringTemplateUtils.TEMPLATE_VERSION, MonitoringIndex.TIMESTAMPED, "kibana_stats", - randomBoolean() ? randomAsciiOfLength(35) : null, - randomAsciiOfLength(5), 1437580442979L, + randomBoolean() ? randomAlphaOfLength(35) : null, + randomAlphaOfLength(5), 1437580442979L, MonitoringBulkDocTests.newRandomSourceNode(), new BytesArray("{\"field1\" : \"value1\"}"), XContentType.JSON); return doc; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/cluster/ClusterInfoResolverTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/cluster/ClusterInfoResolverTests.java index dc1bd9484dd..da159dac731 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/cluster/ClusterInfoResolverTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/cluster/ClusterInfoResolverTests.java @@ -43,10 +43,10 @@ public class ClusterInfoResolverTests extends MonitoringIndexNameResolverTestCas ClusterInfoMonitoringDoc doc = new ClusterInfoMonitoringDoc(randomMonitoringId(), - randomAsciiOfLength(2), randomAsciiOfLength(5), + randomAlphaOfLength(2), randomAlphaOfLength(5), Math.abs(randomLong()), new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT), - randomAsciiOfLength(5), + randomAlphaOfLength(5), randomFrom(Version.V_2_0_0, Version.CURRENT).toString(), licenseBuilder.build(), Collections.singletonList(new MonitoringFeatureSet.Usage(randomBoolean(), randomBoolean(), emptyMap())), diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/cluster/ClusterStateNodeResolverTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/cluster/ClusterStateNodeResolverTests.java index 6880e33f29a..edea27d1a79 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/cluster/ClusterStateNodeResolverTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/cluster/ClusterStateNodeResolverTests.java @@ -26,9 +26,9 @@ public class ClusterStateNodeResolverTests extends @Override protected ClusterStateNodeMonitoringDoc newMonitoringDoc() { ClusterStateNodeMonitoringDoc doc = new ClusterStateNodeMonitoringDoc(randomMonitoringId(), - randomAsciiOfLength(2), randomAsciiOfLength(5), 1437580442979L, + randomAlphaOfLength(2), randomAlphaOfLength(5), 1437580442979L, new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT), - UUID.randomUUID().toString(), randomAsciiOfLength(5)); + UUID.randomUUID().toString(), randomAlphaOfLength(5)); return doc; } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/cluster/ClusterStateResolverTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/cluster/ClusterStateResolverTests.java index a0acf6480f8..8ffde0686b4 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/cluster/ClusterStateResolverTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/cluster/ClusterStateResolverTests.java @@ -35,7 +35,7 @@ public class ClusterStateResolverTests extends MonitoringIndexNameResolverTestCa ClusterState clusterState = ClusterState.builder(new ClusterName("test")).nodes(discoveryNodes).build(); ClusterStateMonitoringDoc doc = new ClusterStateMonitoringDoc(randomMonitoringId(), - randomAsciiOfLength(2), randomAsciiOfLength(5), 1437580442979L, + randomAlphaOfLength(2), randomAlphaOfLength(5), 1437580442979L, new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT), clusterState, randomFrom(ClusterHealthStatus.values())); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/cluster/ClusterStatsResolverTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/cluster/ClusterStatsResolverTests.java index d030122e96e..32724114886 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/cluster/ClusterStatsResolverTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/cluster/ClusterStatsResolverTests.java @@ -62,7 +62,7 @@ public class ClusterStatsResolverTests extends MonitoringIndexNameResolverTestCa @Override protected ClusterStatsMonitoringDoc newMonitoringDoc() { ClusterStatsMonitoringDoc doc = new ClusterStatsMonitoringDoc(randomMonitoringId(), - randomAsciiOfLength(2), randomAsciiOfLength(5), 1437580442979L, + randomAlphaOfLength(2), randomAlphaOfLength(5), 1437580442979L, new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT), randomClusterStats()); return doc; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/cluster/ClusterStatsTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/cluster/ClusterStatsTests.java index 12364e40807..8597ecea3e5 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/cluster/ClusterStatsTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/cluster/ClusterStatsTests.java @@ -45,7 +45,7 @@ public class ClusterStatsTests extends MonitoringIntegTestCase { ClusterStatsNodes.Counts counts = client().admin().cluster().prepareClusterStats().get().getNodesStats().getCounts(); assertThat(counts.getTotal(), greaterThan(0)); - String indexNameBase = randomAsciiOfLength(5).toLowerCase(Locale.ROOT); + String indexNameBase = randomAlphaOfLength(5).toLowerCase(Locale.ROOT); int indicesCount = randomIntBetween(1, 5); String[] indices = new String[indicesCount]; for (int i = 0; i < indicesCount; i++) { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/indices/IndexRecoveryResolverTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/indices/IndexRecoveryResolverTests.java index 26262496618..0f6ad74ce3d 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/indices/IndexRecoveryResolverTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/indices/IndexRecoveryResolverTests.java @@ -40,7 +40,7 @@ public class IndexRecoveryResolverTests extends MonitoringIndexNameResolverTestC shardRecoveryStates.put("test", Collections.singletonList(new RecoveryState(shardRouting, localNode, null))); IndexRecoveryMonitoringDoc doc = new IndexRecoveryMonitoringDoc(randomMonitoringId(), - randomAsciiOfLength(2), randomAsciiOfLength(5), 1437580442979L, + randomAlphaOfLength(2), randomAlphaOfLength(5), 1437580442979L, new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT), new RecoveryResponse(10, 10, 0, false, shardRecoveryStates, Collections.emptyList())); return doc; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/indices/IndexStatsResolverTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/indices/IndexStatsResolverTests.java index 920e0d7790f..d4012afc5f8 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/indices/IndexStatsResolverTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/indices/IndexStatsResolverTests.java @@ -44,7 +44,7 @@ public class IndexStatsResolverTests extends MonitoringIndexNameResolverTestCase @Override protected IndexStatsMonitoringDoc newMonitoringDoc() { IndexStatsMonitoringDoc doc = new IndexStatsMonitoringDoc(randomMonitoringId(), - randomAsciiOfLength(2), randomAsciiOfLength(5), 1437580442979L, + randomAlphaOfLength(2), randomAlphaOfLength(5), 1437580442979L, new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT), randomIndexStats()); return doc; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/indices/IndicesStatsResolverTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/indices/IndicesStatsResolverTests.java index e570c01cb70..4d62958b1b7 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/indices/IndicesStatsResolverTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/indices/IndicesStatsResolverTests.java @@ -48,7 +48,7 @@ public class IndicesStatsResolverTests extends MonitoringIndexNameResolverTestCa @Override protected IndicesStatsMonitoringDoc newMonitoringDoc() { IndicesStatsMonitoringDoc doc = new IndicesStatsMonitoringDoc(randomMonitoringId(), - randomAsciiOfLength(2), randomAsciiOfLength(5), 1437580442979L, + randomAlphaOfLength(2), randomAlphaOfLength(5), 1437580442979L, new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT), randomIndicesStats()); return doc; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/node/DiscoveryNodeResolverTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/node/DiscoveryNodeResolverTests.java index cca8a53163a..f497d757217 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/node/DiscoveryNodeResolverTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/node/DiscoveryNodeResolverTests.java @@ -27,8 +27,8 @@ public class DiscoveryNodeResolverTests extends MonitoringIndexNameResolverTestC @Override protected DiscoveryNodeMonitoringDoc newMonitoringDoc() { DiscoveryNodeMonitoringDoc doc = new DiscoveryNodeMonitoringDoc(randomMonitoringId(), - randomAsciiOfLength(2), randomAsciiOfLength(5), 1437580442979L, - new DiscoveryNode(randomAsciiOfLength(3), UUID.randomUUID().toString(), + randomAlphaOfLength(2), randomAlphaOfLength(5), 1437580442979L, + new DiscoveryNode(randomAlphaOfLength(3), UUID.randomUUID().toString(), buildNewFakeTransportAddress(), emptyMap(), emptySet(), randomVersionBetween(random(), VersionUtils.getFirstVersion(), Version.CURRENT))); return doc; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/node/NodeStatsResolverTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/node/NodeStatsResolverTests.java index 2dd5e396444..20ee4389eb8 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/node/NodeStatsResolverTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/node/NodeStatsResolverTests.java @@ -60,7 +60,7 @@ public class NodeStatsResolverTests extends MonitoringIndexNameResolverTestCase< @Override protected NodeStatsMonitoringDoc newMonitoringDoc() { NodeStatsMonitoringDoc doc = new NodeStatsMonitoringDoc(randomMonitoringId(), - randomAsciiOfLength(2), randomAsciiOfLength(5), + randomAlphaOfLength(2), randomAlphaOfLength(5), new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT), randomBoolean(), randomNodeStats(), randomBoolean()); return doc; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/shards/ShardsResolverTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/shards/ShardsResolverTests.java index cff34b1fbc1..5f150c529be 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/shards/ShardsResolverTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/shards/ShardsResolverTests.java @@ -30,14 +30,14 @@ public class ShardsResolverTests extends MonitoringIndexNameResolverTestCase metadata = MapBuilder.newMapBuilder().put("_key", "_val").map(); return mockExecutionContextBuilder("watch1") .wid(wid) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/notification/email/attachment/ReportingAttachmentParserTests.java b/plugin/src/test/java/org/elasticsearch/xpack/notification/email/attachment/ReportingAttachmentParserTests.java index b75e2791b47..a946065d1ea 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/notification/email/attachment/ReportingAttachmentParserTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/notification/email/attachment/ReportingAttachmentParserTests.java @@ -143,9 +143,9 @@ public class ReportingAttachmentParserTests extends ESTestCase { public void testGoodCase() throws Exception { // returns interval HTTP code for five times, then return expected data - String content = randomAsciiOfLength(200); + String content = randomAlphaOfLength(200); String path = "/ovb/api/reporting/jobs/download/iu5zfzvk15oa8990bfas9wy2"; - String randomContentType = randomAsciiOfLength(20); + String randomContentType = randomAlphaOfLength(20); Map headers = new HashMap<>(); headers.put("Content-Type", new String[] { randomContentType }); when(httpClient.execute(any(HttpRequest.class))) @@ -284,7 +284,7 @@ public class ReportingAttachmentParserTests extends ESTestCase { } public void testWithBasicAuth() throws Exception { - String content = randomAsciiOfLength(200); + String content = randomAlphaOfLength(200); when(httpClient.execute(any(HttpRequest.class))) .thenReturn(new HttpResponse(200, "{\"path\":\"whatever\"}")) .thenReturn(new HttpResponse(503)) @@ -345,7 +345,7 @@ public class ReportingAttachmentParserTests extends ESTestCase { when(httpClient.execute(any(HttpRequest.class))) .thenReturn(new HttpResponse(200, "{\"path\":\"whatever\"}")) .thenReturn(new HttpResponse(503)) - .thenReturn(new HttpResponse(200, randomAsciiOfLength(10))); + .thenReturn(new HttpResponse(200, randomAlphaOfLength(10))); TextTemplateEngine replaceHttpWithHttpsTemplateEngine = new TextTemplateEngine(Settings.EMPTY, null) { @Override @@ -381,7 +381,7 @@ public class ReportingAttachmentParserTests extends ESTestCase { private WatchExecutionContext createWatchExecutionContext() { DateTime now = DateTime.now(DateTimeZone.UTC); return mockExecutionContextBuilder("watch1") - .wid(new Wid(randomAsciiOfLength(5), now)) + .wid(new Wid(randomAlphaOfLength(5), now)) .payload(new Payload.Simple()) .time("watch1", now) .metadata(Collections.emptyMap()) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/notification/hipchat/HipChatAccountsTests.java b/plugin/src/test/java/org/elasticsearch/xpack/notification/hipchat/HipChatAccountsTests.java index ad53b19be97..85cfbc06c05 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/notification/hipchat/HipChatAccountsTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/notification/hipchat/HipChatAccountsTests.java @@ -167,9 +167,9 @@ public class HipChatAccountsTests extends ESTestCase { private void addAccountSettings(String name, Settings.Builder builder) { HipChatAccount.Profile profile = randomFrom(HipChatAccount.Profile.values()); builder.put("xpack.notification.hipchat.account." + name + ".profile", profile.value()); - builder.put("xpack.notification.hipchat.account." + name + ".auth_token", randomAsciiOfLength(50)); + builder.put("xpack.notification.hipchat.account." + name + ".auth_token", randomAlphaOfLength(50)); if (profile == HipChatAccount.Profile.INTEGRATION) { - builder.put("xpack.notification.hipchat.account." + name + ".room", randomAsciiOfLength(10)); + builder.put("xpack.notification.hipchat.account." + name + ".room", randomAlphaOfLength(10)); } } } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/notification/hipchat/HipChatMessageTests.java b/plugin/src/test/java/org/elasticsearch/xpack/notification/hipchat/HipChatMessageTests.java index 288beeb8b40..3eb4d47452e 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/notification/hipchat/HipChatMessageTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/notification/hipchat/HipChatMessageTests.java @@ -27,10 +27,10 @@ import static org.hamcrest.Matchers.notNullValue; public class HipChatMessageTests extends ESTestCase { public void testToXContent() throws Exception { - String message = randomAsciiOfLength(10); + String message = randomAlphaOfLength(10); String[] rooms = generateRandomStringArray(3, 10, true); String[] users = generateRandomStringArray(3, 10, true); - String from = randomBoolean() ? null : randomAsciiOfLength(10); + String from = randomBoolean() ? null : randomAlphaOfLength(10); HipChatMessage.Format format = rarely() ? null : randomFrom(HipChatMessage.Format.values()); HipChatMessage.Color color = rarely() ? null : randomFrom(HipChatMessage.Color.values()); Boolean notify = rarely() ? null : randomBoolean(); @@ -102,10 +102,10 @@ public class HipChatMessageTests extends ESTestCase { } public void testEquals() throws Exception { - String message = randomAsciiOfLength(10); + String message = randomAlphaOfLength(10); String[] rooms = generateRandomStringArray(3, 10, true); String[] users = generateRandomStringArray(3, 10, true); - String from = randomBoolean() ? null : randomAsciiOfLength(10); + String from = randomBoolean() ? null : randomAlphaOfLength(10); HipChatMessage.Format format = rarely() ? null : randomFrom(HipChatMessage.Format.values()); HipChatMessage.Color color = rarely() ? null : randomFrom(HipChatMessage.Color.values()); Boolean notify = rarely() ? null : randomBoolean(); @@ -160,14 +160,14 @@ public class HipChatMessageTests extends ESTestCase { XContentBuilder jsonBuilder = jsonBuilder(); jsonBuilder.startObject(); - TextTemplate body = new TextTemplate(randomAsciiOfLength(200)); + TextTemplate body = new TextTemplate(randomAlphaOfLength(200)); jsonBuilder.field("body", body, ToXContent.EMPTY_PARAMS); TextTemplate[] rooms = null; if (randomBoolean()) { jsonBuilder.startArray("room"); rooms = new TextTemplate[randomIntBetween(1, 3)]; for (int i = 0; i < rooms.length; i++) { - rooms[i] = new TextTemplate(randomAsciiOfLength(10)); + rooms[i] = new TextTemplate(randomAlphaOfLength(10)); rooms[i].toXContent(jsonBuilder, ToXContent.EMPTY_PARAMS); } jsonBuilder.endArray(); @@ -177,19 +177,19 @@ public class HipChatMessageTests extends ESTestCase { jsonBuilder.startArray("user"); users = new TextTemplate[randomIntBetween(1, 3)]; for (int i = 0; i < users.length; i++) { - users[i] = new TextTemplate(randomAsciiOfLength(10)); + users[i] = new TextTemplate(randomAlphaOfLength(10)); users[i].toXContent(jsonBuilder, ToXContent.EMPTY_PARAMS); } jsonBuilder.endArray(); } String from = null; if (randomBoolean()) { - from = randomAsciiOfLength(10); + from = randomAlphaOfLength(10); jsonBuilder.field("from", from); } TextTemplate color = null; if (randomBoolean()) { - color = new TextTemplate(randomAsciiOfLength(10)); + color = new TextTemplate(randomAlphaOfLength(10)); jsonBuilder.field("color", color, ToXContent.EMPTY_PARAMS); } HipChatMessage.Format format = null; @@ -228,26 +228,26 @@ public class HipChatMessageTests extends ESTestCase { } public void testTemplateParseSelfGenerated() throws Exception { - TextTemplate body = new TextTemplate(randomAsciiOfLength(10)); + TextTemplate body = new TextTemplate(randomAlphaOfLength(10)); HipChatMessage.Template.Builder templateBuilder = new HipChatMessage.Template.Builder(body); if (randomBoolean()) { int count = randomIntBetween(1, 3); for (int i = 0; i < count; i++) { - templateBuilder.addRooms(new TextTemplate(randomAsciiOfLength(10))); + templateBuilder.addRooms(new TextTemplate(randomAlphaOfLength(10))); } } if (randomBoolean()) { int count = randomIntBetween(1, 3); for (int i = 0; i < count; i++) { - templateBuilder.addUsers(new TextTemplate(randomAsciiOfLength(10))); + templateBuilder.addUsers(new TextTemplate(randomAlphaOfLength(10))); } } if (randomBoolean()) { - templateBuilder.setFrom(randomAsciiOfLength(10)); + templateBuilder.setFrom(randomAlphaOfLength(10)); } if (randomBoolean()) { - templateBuilder.setColor(new TextTemplate(randomAsciiOfLength(5))); + templateBuilder.setColor(new TextTemplate(randomAlphaOfLength(5))); } if (randomBoolean()) { templateBuilder.setFormat(randomFrom(HipChatMessage.Format.values())); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/notification/hipchat/HipChatServiceTests.java b/plugin/src/test/java/org/elasticsearch/xpack/notification/hipchat/HipChatServiceTests.java index a383ff508ef..e4c4d58e195 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/notification/hipchat/HipChatServiceTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/notification/hipchat/HipChatServiceTests.java @@ -32,7 +32,7 @@ public class HipChatServiceTests extends ESTestCase { } public void testSingleAccountV1() throws Exception { - String accountName = randomAsciiOfLength(10); + String accountName = randomAlphaOfLength(10); String host = randomBoolean() ? null : "_host"; int port = randomBoolean() ? -1 : randomIntBetween(300, 400); String defaultRoom = randomBoolean() ? null : "_r1, _r2"; @@ -78,10 +78,10 @@ public class HipChatServiceTests extends ESTestCase { } public void testSingleAccountIntegration() throws Exception { - String accountName = randomAsciiOfLength(10); + String accountName = randomAlphaOfLength(10); String host = randomBoolean() ? null : "_host"; int port = randomBoolean() ? -1 : randomIntBetween(300, 400); - String room = randomAsciiOfLength(10); + String room = randomAlphaOfLength(10); String defaultFrom = randomBoolean() ? null : "_from"; HipChatMessage.Color defaultColor = randomBoolean() ? null : randomFrom(HipChatMessage.Color.values()); HipChatMessage.Format defaultFormat = randomBoolean() ? null : randomFrom(HipChatMessage.Format.values()); @@ -121,7 +121,7 @@ public class HipChatServiceTests extends ESTestCase { } public void testSingleAccountIntegrationNoRoomSetting() throws Exception { - String accountName = randomAsciiOfLength(10); + String accountName = randomAlphaOfLength(10); Settings.Builder settingsBuilder = Settings.builder() .put("xpack.notification.hipchat.account." + accountName + ".profile", HipChatAccount.Profile.INTEGRATION.value()) @@ -133,7 +133,7 @@ public class HipChatServiceTests extends ESTestCase { } public void testSingleAccountUser() throws Exception { - String accountName = randomAsciiOfLength(10); + String accountName = randomAlphaOfLength(10); String host = randomBoolean() ? null : "_host"; int port = randomBoolean() ? -1 : randomIntBetween(300, 400); String defaultRoom = randomBoolean() ? null : "_r1, _r2"; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/notification/hipchat/IntegrationAccountTests.java b/plugin/src/test/java/org/elasticsearch/xpack/notification/hipchat/IntegrationAccountTests.java index f526601ecf8..078bebd87f6 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/notification/hipchat/IntegrationAccountTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/notification/hipchat/IntegrationAccountTests.java @@ -33,12 +33,12 @@ public class IntegrationAccountTests extends ESTestCase { Settings.Builder sb = Settings.builder(); - String authToken = randomAsciiOfLength(50); + String authToken = randomAlphaOfLength(50); sb.put(IntegrationAccount.AUTH_TOKEN_SETTING, authToken); String host = HipChatServer.DEFAULT.host(); if (randomBoolean()) { - host = randomAsciiOfLength(10); + host = randomAlphaOfLength(10); sb.put(HipChatServer.HOST_SETTING, host); } int port = HipChatServer.DEFAULT.port(); @@ -47,7 +47,7 @@ public class IntegrationAccountTests extends ESTestCase { sb.put(HipChatServer.PORT_SETTING, port); } - String room = randomAsciiOfLength(10); + String room = randomAlphaOfLength(10); sb.put(IntegrationAccount.ROOM_SETTING, room); HipChatMessage.Format defaultFormat = null; @@ -83,7 +83,7 @@ public class IntegrationAccountTests extends ESTestCase { public void testSettingsNoAuthToken() throws Exception { Settings.Builder sb = Settings.builder(); - sb.put(IntegrationAccount.ROOM_SETTING, randomAsciiOfLength(10)); + sb.put(IntegrationAccount.ROOM_SETTING, randomAlphaOfLength(10)); try { new IntegrationAccount("_name", sb.build(), HipChatServer.DEFAULT, mock(HttpClient.class), mock(Logger.class)); fail("Expected SettingsException"); @@ -94,7 +94,7 @@ public class IntegrationAccountTests extends ESTestCase { public void testSettingsWithoutRoom() throws Exception { Settings.Builder sb = Settings.builder(); - sb.put(IntegrationAccount.AUTH_TOKEN_SETTING, randomAsciiOfLength(50)); + sb.put(IntegrationAccount.AUTH_TOKEN_SETTING, randomAlphaOfLength(50)); try { new IntegrationAccount("_name", sb.build(), HipChatServer.DEFAULT, mock(HttpClient.class), mock(Logger.class)); fail("Expected SettingsException"); @@ -105,7 +105,7 @@ public class IntegrationAccountTests extends ESTestCase { public void testSettingsWithoutMultipleRooms() throws Exception { Settings.Builder sb = Settings.builder(); - sb.put(IntegrationAccount.AUTH_TOKEN_SETTING, randomAsciiOfLength(50)); + sb.put(IntegrationAccount.AUTH_TOKEN_SETTING, randomAlphaOfLength(50)); sb.put(IntegrationAccount.ROOM_SETTING, "_r1,_r2"); try { new IntegrationAccount("_name", sb.build(), HipChatServer.DEFAULT, mock(HttpClient.class), mock(Logger.class)); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/notification/hipchat/UserAccountTests.java b/plugin/src/test/java/org/elasticsearch/xpack/notification/hipchat/UserAccountTests.java index 22e01315002..c3904e9e074 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/notification/hipchat/UserAccountTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/notification/hipchat/UserAccountTests.java @@ -39,12 +39,12 @@ public class UserAccountTests extends ESTestCase { Settings.Builder sb = Settings.builder(); - String authToken = randomAsciiOfLength(50); + String authToken = randomAlphaOfLength(50); sb.put(UserAccount.AUTH_TOKEN_SETTING, authToken); String host = HipChatServer.DEFAULT.host(); if (randomBoolean()) { - host = randomAsciiOfLength(10); + host = randomAlphaOfLength(10); sb.put(HipChatServer.HOST_SETTING, host); } int port = HipChatServer.DEFAULT.port(); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/notification/hipchat/V1AccountTests.java b/plugin/src/test/java/org/elasticsearch/xpack/notification/hipchat/V1AccountTests.java index c092b715f79..6ca2b54635d 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/notification/hipchat/V1AccountTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/notification/hipchat/V1AccountTests.java @@ -30,12 +30,12 @@ public class V1AccountTests extends ESTestCase { Settings.Builder sb = Settings.builder(); - String authToken = randomAsciiOfLength(50); + String authToken = randomAlphaOfLength(50); sb.put(V1Account.AUTH_TOKEN_SETTING, authToken); String host = HipChatServer.DEFAULT.host(); if (randomBoolean()) { - host = randomAsciiOfLength(10); + host = randomAlphaOfLength(10); sb.put(HipChatServer.HOST_SETTING, host); } int port = HipChatServer.DEFAULT.port(); @@ -51,7 +51,7 @@ public class V1AccountTests extends ESTestCase { } String defaultFrom = null; if (randomBoolean()) { - defaultFrom = randomAsciiOfLength(10); + defaultFrom = randomAlphaOfLength(10); sb.put(HipChatAccount.DEFAULT_FROM_SETTING, defaultFrom); } HipChatMessage.Format defaultFormat = null; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/notification/jira/JiraAccountTests.java b/plugin/src/test/java/org/elasticsearch/xpack/notification/jira/JiraAccountTests.java index 7248ecf3709..2088e5a7420 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/notification/jira/JiraAccountTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/notification/jira/JiraAccountTests.java @@ -209,8 +209,8 @@ public class JiraAccountTests extends ESTestCase { private void addAccountSettings(String name, Settings.Builder builder) { builder.put("xpack.notification.jira.account." + name + "." + JiraAccount.URL_SETTING, "https://internal-jira.elastic.co:443"); - builder.put("xpack.notification.jira.account." + name + "." + JiraAccount.USER_SETTING, randomAsciiOfLength(10)); - builder.put("xpack.notification.jira.account." + name + "." + JiraAccount.PASSWORD_SETTING, randomAsciiOfLength(10)); + builder.put("xpack.notification.jira.account." + name + "." + JiraAccount.USER_SETTING, randomAlphaOfLength(10)); + builder.put("xpack.notification.jira.account." + name + "." + JiraAccount.PASSWORD_SETTING, randomAlphaOfLength(10)); Map defaults = randomIssueDefaults(); for (Map.Entry setting : defaults.entrySet()) { @@ -227,24 +227,24 @@ public class JiraAccountTests extends ESTestCase { MapBuilder builder = MapBuilder.newMapBuilder(); if (randomBoolean()) { Map project = new HashMap<>(); - project.put("project", singletonMap("id", randomAsciiOfLength(10))); + project.put("project", singletonMap("id", randomAlphaOfLength(10))); builder.putAll(project); } if (randomBoolean()) { Map project = new HashMap<>(); - project.put("issuetype", singletonMap("name", randomAsciiOfLength(5))); + project.put("issuetype", singletonMap("name", randomAlphaOfLength(5))); builder.putAll(project); } if (randomBoolean()) { - builder.put("summary", randomAsciiOfLength(10)); + builder.put("summary", randomAlphaOfLength(10)); } if (randomBoolean()) { - builder.put("description", randomAsciiOfLength(50)); + builder.put("description", randomAlphaOfLength(50)); } if (randomBoolean()) { int count = randomIntBetween(0, 5); for (int i = 0; i < count; i++) { - builder.put("customfield_" + i, randomAsciiOfLengthBetween(5, 10)); + builder.put("customfield_" + i, randomAlphaOfLengthBetween(5, 10)); } } return builder.immutableMap(); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/notification/jira/JiraIssueTests.java b/plugin/src/test/java/org/elasticsearch/xpack/notification/jira/JiraIssueTests.java index fccdc401738..15592fce7a6 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/notification/jira/JiraIssueTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/notification/jira/JiraIssueTests.java @@ -103,7 +103,7 @@ public class JiraIssueTests extends ESTestCase { final Map fields = new HashMap<>(issue1.getFields()); if (equals == false) { if (fields.isEmpty()) { - fields.put(randomAsciiOfLength(5), randomAsciiOfLength(10)); + fields.put(randomAlphaOfLength(5), randomAlphaOfLength(10)); } else { fields.remove(randomFrom(fields.keySet())); } @@ -119,7 +119,7 @@ public class JiraIssueTests extends ESTestCase { HttpRequest request = HttpRequest.builder(randomFrom("localhost", "internal-jira.elastic.co"), randomFrom(80, 443)) .method(HttpMethod.POST) .path(JiraAccount.DEFAULT_PATH) - .auth(new BasicAuth(randomAsciiOfLength(5), randomAsciiOfLength(5).toCharArray())) + .auth(new BasicAuth(randomAlphaOfLength(5), randomAlphaOfLength(5).toCharArray())) .build(); if (rarely()) { Tuple error = randomHttpError(); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/notification/pagerduty/IncidentEventDefaultsTests.java b/plugin/src/test/java/org/elasticsearch/xpack/notification/pagerduty/IncidentEventDefaultsTests.java index a77eb652592..d8b84fceff8 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/notification/pagerduty/IncidentEventDefaultsTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/notification/pagerduty/IncidentEventDefaultsTests.java @@ -44,62 +44,62 @@ public class IncidentEventDefaultsTests extends ESTestCase { public static Settings randomSettings() { Settings.Builder settings = Settings.builder(); if (randomBoolean()) { - settings.put("from", randomAsciiOfLength(10)); + settings.put("from", randomAlphaOfLength(10)); } if (randomBoolean()) { String[] to = new String[randomIntBetween(1, 3)]; for (int i = 0; i < to.length; i++) { - to[i] = randomAsciiOfLength(10); + to[i] = randomAlphaOfLength(10); } settings.putArray("to", to); } if (randomBoolean()) { - settings.put("text", randomAsciiOfLength(10)); + settings.put("text", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("event_type", randomAsciiOfLength(10)); + settings.put("event_type", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("icon", randomAsciiOfLength(10)); + settings.put("icon", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.fallback", randomAsciiOfLength(10)); + settings.put("attachment.fallback", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.color", randomAsciiOfLength(10)); + settings.put("attachment.color", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.pretext", randomAsciiOfLength(10)); + settings.put("attachment.pretext", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.author_name", randomAsciiOfLength(10)); + settings.put("attachment.author_name", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.author_link", randomAsciiOfLength(10)); + settings.put("attachment.author_link", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.author_icon", randomAsciiOfLength(10)); + settings.put("attachment.author_icon", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.title", randomAsciiOfLength(10)); + settings.put("attachment.title", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.title_link", randomAsciiOfLength(10)); + settings.put("attachment.title_link", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.text", randomAsciiOfLength(10)); + settings.put("attachment.text", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.image_url", randomAsciiOfLength(10)); + settings.put("attachment.image_url", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.thumb_url", randomAsciiOfLength(10)); + settings.put("attachment.thumb_url", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.field.title", randomAsciiOfLength(10)); + settings.put("attachment.field.title", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.field.value", randomAsciiOfLength(10)); + settings.put("attachment.field.value", randomAlphaOfLength(10)); } if (randomBoolean()) { settings.put("attachment.field.short", randomBoolean()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/notification/pagerduty/PagerDutyAccountsTests.java b/plugin/src/test/java/org/elasticsearch/xpack/notification/pagerduty/PagerDutyAccountsTests.java index 6ead551f983..d9d7347d07f 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/notification/pagerduty/PagerDutyAccountsTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/notification/pagerduty/PagerDutyAccountsTests.java @@ -152,7 +152,7 @@ public class PagerDutyAccountsTests extends ESTestCase { } private void addAccountSettings(String name, Settings.Builder builder) { - builder.put("xpack.notification.pagerduty.account." + name + ".service_api_key", randomAsciiOfLength(50)); + builder.put("xpack.notification.pagerduty.account." + name + ".service_api_key", randomAlphaOfLength(50)); Settings defaults = SlackMessageDefaultsTests.randomSettings(); for (Map.Entry setting : defaults.getAsMap().entrySet()) { builder.put("xpack.notification.pagerduty.message_defaults." + setting.getKey(), setting.getValue()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/notification/slack/SlackAccountsTests.java b/plugin/src/test/java/org/elasticsearch/xpack/notification/slack/SlackAccountsTests.java index 47c278a17cb..9a1b6c9ea82 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/notification/slack/SlackAccountsTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/notification/slack/SlackAccountsTests.java @@ -136,7 +136,7 @@ public class SlackAccountsTests extends ESTestCase { } private void addAccountSettings(String name, Settings.Builder builder) { - builder.put("xpack.notification.slack.account." + name + ".url", "https://hooks.slack.com/services/" + randomAsciiOfLength(50)); + builder.put("xpack.notification.slack.account." + name + ".url", "https://hooks.slack.com/services/" + randomAlphaOfLength(50)); Settings defaults = SlackMessageDefaultsTests.randomSettings(); for (Map.Entry setting : defaults.getAsMap().entrySet()) { builder.put("xpack.notification.slack.message_defaults." + setting.getKey(), setting.getValue()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/notification/slack/message/SlackMessageDefaultsTests.java b/plugin/src/test/java/org/elasticsearch/xpack/notification/slack/message/SlackMessageDefaultsTests.java index de47a6061b4..d03fec69f36 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/notification/slack/message/SlackMessageDefaultsTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/notification/slack/message/SlackMessageDefaultsTests.java @@ -37,59 +37,59 @@ public class SlackMessageDefaultsTests extends ESTestCase { public static Settings randomSettings() { Settings.Builder settings = Settings.builder(); if (randomBoolean()) { - settings.put("from", randomAsciiOfLength(10)); + settings.put("from", randomAlphaOfLength(10)); } if (randomBoolean()) { String[] to = new String[randomIntBetween(1, 3)]; for (int i = 0; i < to.length; i++) { - to[i] = randomAsciiOfLength(10); + to[i] = randomAlphaOfLength(10); } settings.putArray("to", to); } if (randomBoolean()) { - settings.put("text", randomAsciiOfLength(10)); + settings.put("text", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("icon", randomAsciiOfLength(10)); + settings.put("icon", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.fallback", randomAsciiOfLength(10)); + settings.put("attachment.fallback", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.color", randomAsciiOfLength(10)); + settings.put("attachment.color", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.pretext", randomAsciiOfLength(10)); + settings.put("attachment.pretext", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.author_name", randomAsciiOfLength(10)); + settings.put("attachment.author_name", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.author_link", randomAsciiOfLength(10)); + settings.put("attachment.author_link", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.author_icon", randomAsciiOfLength(10)); + settings.put("attachment.author_icon", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.title", randomAsciiOfLength(10)); + settings.put("attachment.title", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.title_link", randomAsciiOfLength(10)); + settings.put("attachment.title_link", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.text", randomAsciiOfLength(10)); + settings.put("attachment.text", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.image_url", randomAsciiOfLength(10)); + settings.put("attachment.image_url", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.thumb_url", randomAsciiOfLength(10)); + settings.put("attachment.thumb_url", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.field.title", randomAsciiOfLength(10)); + settings.put("attachment.field.title", randomAlphaOfLength(10)); } if (randomBoolean()) { - settings.put("attachment.field.value", randomAsciiOfLength(10)); + settings.put("attachment.field.value", randomAlphaOfLength(10)); } if (randomBoolean()) { settings.put("attachment.field.short", randomBoolean()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/notification/slack/message/SlackMessageTests.java b/plugin/src/test/java/org/elasticsearch/xpack/notification/slack/message/SlackMessageTests.java index e1da997b751..24a9c9da6ff 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/notification/slack/message/SlackMessageTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/notification/slack/message/SlackMessageTests.java @@ -28,35 +28,35 @@ import static org.hamcrest.Matchers.is; public class SlackMessageTests extends ESTestCase { public void testToXContent() throws Exception { - String from = randomBoolean() ? null : randomAsciiOfLength(10); + String from = randomBoolean() ? null : randomAlphaOfLength(10); String[] to = rarely() ? null : new String[randomIntBetween(0, 2)]; if (to != null) { for (int i = 0; i < to.length; i++) { - to[i] = randomAsciiOfLength(10); + to[i] = randomAlphaOfLength(10); } } - String icon = randomBoolean() ? null : randomAsciiOfLength(10); - String text = randomBoolean() ? null : randomAsciiOfLength(50); + String icon = randomBoolean() ? null : randomAlphaOfLength(10); + String text = randomBoolean() ? null : randomAlphaOfLength(50); Attachment[] attachments = randomBoolean() ? null : new Attachment[randomIntBetween(0, 2)]; if (attachments != null) { for (int i = 0; i < attachments.length; i++) { - String fallback = randomBoolean() ? null : randomAsciiOfLength(10); - String color = randomBoolean() ? null : randomAsciiOfLength(10); - String pretext = randomBoolean() ? null : randomAsciiOfLength(10); - String authorName = randomBoolean() ? null : randomAsciiOfLength(10); - String authorLink = authorName == null || randomBoolean() ? null : randomAsciiOfLength(10); - String authorIcon = authorName == null || randomBoolean() ? null : randomAsciiOfLength(10); - String title = randomBoolean() ? null : randomAsciiOfLength(10); - String titleLink = title == null ||randomBoolean() ? null : randomAsciiOfLength(10); - String attachmentText = randomBoolean() ? null : randomAsciiOfLength(10); + String fallback = randomBoolean() ? null : randomAlphaOfLength(10); + String color = randomBoolean() ? null : randomAlphaOfLength(10); + String pretext = randomBoolean() ? null : randomAlphaOfLength(10); + String authorName = randomBoolean() ? null : randomAlphaOfLength(10); + String authorLink = authorName == null || randomBoolean() ? null : randomAlphaOfLength(10); + String authorIcon = authorName == null || randomBoolean() ? null : randomAlphaOfLength(10); + String title = randomBoolean() ? null : randomAlphaOfLength(10); + String titleLink = title == null ||randomBoolean() ? null : randomAlphaOfLength(10); + String attachmentText = randomBoolean() ? null : randomAlphaOfLength(10); Field[] fields = randomBoolean() ? null : new Field[randomIntBetween(0, 2)]; if (fields != null) { for (int j = 0; j < fields.length; j++) { - fields[j] = new Field(randomAsciiOfLength(10), randomAsciiOfLength(10), randomBoolean()); + fields[j] = new Field(randomAlphaOfLength(10), randomAlphaOfLength(10), randomBoolean()); } } - String imageUrl = randomBoolean() ? null : randomAsciiOfLength(10); - String thumbUrl = randomBoolean() ? null : randomAsciiOfLength(10); + String imageUrl = randomBoolean() ? null : randomAlphaOfLength(10); + String thumbUrl = randomBoolean() ? null : randomAlphaOfLength(10); attachments[i] = new Attachment(fallback, color, pretext, authorName, authorLink, authorIcon, title, titleLink, attachmentText, fields, imageUrl, thumbUrl); } @@ -226,7 +226,7 @@ public class SlackMessageTests extends ESTestCase { TextTemplate from = null; if (randomBoolean()) { - from = new TextTemplate(randomAsciiOfLength(200)); + from = new TextTemplate(randomAlphaOfLength(200)); jsonBuilder.field("from", from, params); } TextTemplate[] to = null; @@ -234,19 +234,19 @@ public class SlackMessageTests extends ESTestCase { jsonBuilder.startArray("to"); to = new TextTemplate[randomIntBetween(1, 3)]; for (int i = 0; i < to.length; i++) { - to[i] = new TextTemplate(randomAsciiOfLength(10)); + to[i] = new TextTemplate(randomAlphaOfLength(10)); to[i].toXContent(jsonBuilder, params); } jsonBuilder.endArray(); } TextTemplate text = null; if (randomBoolean()) { - text = new TextTemplate(randomAsciiOfLength(200)); + text = new TextTemplate(randomAlphaOfLength(200)); jsonBuilder.field("text", text, params); } TextTemplate icon = null; if (randomBoolean()) { - icon = new TextTemplate(randomAsciiOfLength(10)); + icon = new TextTemplate(randomAlphaOfLength(10)); jsonBuilder.field("icon", icon); } Attachment.Template[] attachments = null; @@ -257,57 +257,57 @@ public class SlackMessageTests extends ESTestCase { jsonBuilder.startObject(); TextTemplate fallback = null; if (randomBoolean()) { - fallback = new TextTemplate(randomAsciiOfLength(200)); + fallback = new TextTemplate(randomAlphaOfLength(200)); jsonBuilder.field("fallback", fallback, params); } TextTemplate color = null; if (randomBoolean()) { - color = new TextTemplate(randomAsciiOfLength(200)); + color = new TextTemplate(randomAlphaOfLength(200)); jsonBuilder.field("color", color, params); } TextTemplate pretext = null; if (randomBoolean()) { - pretext = new TextTemplate(randomAsciiOfLength(200)); + pretext = new TextTemplate(randomAlphaOfLength(200)); jsonBuilder.field("pretext", pretext, params); } TextTemplate authorName = null; TextTemplate authorLink = null; TextTemplate authorIcon = null; if (randomBoolean()) { - authorName = new TextTemplate(randomAsciiOfLength(200)); + authorName = new TextTemplate(randomAlphaOfLength(200)); jsonBuilder.field("author_name", authorName, params); if (randomBoolean()) { - authorLink = new TextTemplate(randomAsciiOfLength(200)); + authorLink = new TextTemplate(randomAlphaOfLength(200)); jsonBuilder.field("author_link", authorLink, params); } if (randomBoolean()) { - authorIcon = new TextTemplate(randomAsciiOfLength(200)); + authorIcon = new TextTemplate(randomAlphaOfLength(200)); jsonBuilder.field("author_icon", authorIcon, params); } } TextTemplate title = null; TextTemplate titleLink = null; if (randomBoolean()) { - title = new TextTemplate(randomAsciiOfLength(200)); + title = new TextTemplate(randomAlphaOfLength(200)); jsonBuilder.field("title", title, params); if (randomBoolean()) { - titleLink = new TextTemplate(randomAsciiOfLength(200)); + titleLink = new TextTemplate(randomAlphaOfLength(200)); jsonBuilder.field("title_link", titleLink, params); } } TextTemplate attachmentText = null; if (randomBoolean()) { - attachmentText = new TextTemplate(randomAsciiOfLength(200)); + attachmentText = new TextTemplate(randomAlphaOfLength(200)); jsonBuilder.field("text", attachmentText, params); } TextTemplate imageUrl = null; if (randomBoolean()) { - imageUrl = new TextTemplate(randomAsciiOfLength(200)); + imageUrl = new TextTemplate(randomAlphaOfLength(200)); jsonBuilder.field("image_url", imageUrl, params); } TextTemplate thumbUrl = null; if (randomBoolean()) { - thumbUrl = new TextTemplate(randomAsciiOfLength(200)); + thumbUrl = new TextTemplate(randomAlphaOfLength(200)); jsonBuilder.field("thumb_url", thumbUrl, params); } Field.Template[] fields = null; @@ -316,9 +316,9 @@ public class SlackMessageTests extends ESTestCase { fields = new Field.Template[randomIntBetween(1,3)]; for (int j = 0; j < fields.length; j++) { jsonBuilder.startObject(); - TextTemplate fieldTitle = new TextTemplate(randomAsciiOfLength(50)); + TextTemplate fieldTitle = new TextTemplate(randomAlphaOfLength(50)); jsonBuilder.field("title", fieldTitle, params); - TextTemplate fieldValue = new TextTemplate(randomAsciiOfLength(50)); + TextTemplate fieldValue = new TextTemplate(randomAlphaOfLength(50)); jsonBuilder.field("value", fieldValue, params); boolean isShort = randomBoolean(); jsonBuilder.field("short", isShort); @@ -378,61 +378,61 @@ public class SlackMessageTests extends ESTestCase { SlackMessage.Template.Builder templateBuilder = SlackMessage.Template.builder(); if (randomBoolean()) { - templateBuilder.setFrom(randomAsciiOfLength(10)); + templateBuilder.setFrom(randomAlphaOfLength(10)); } if (randomBoolean()) { int count = randomIntBetween(0, 3); for (int i = 0; i < count; i++) { - templateBuilder.addTo(randomAsciiOfLength(10)); + templateBuilder.addTo(randomAlphaOfLength(10)); } } if (randomBoolean()) { - templateBuilder.setIcon(randomAsciiOfLength(10)); + templateBuilder.setIcon(randomAlphaOfLength(10)); } if (randomBoolean()) { - templateBuilder.setText(randomAsciiOfLength(10)); + templateBuilder.setText(randomAlphaOfLength(10)); } if (randomBoolean()) { int count = randomIntBetween(0, 3); for (int i = 0; i < count; i++) { Attachment.Template.Builder attachmentBuilder = Attachment.Template.builder(); if (randomBoolean()) { - attachmentBuilder.setAuthorName(randomAsciiOfLength(10)); + attachmentBuilder.setAuthorName(randomAlphaOfLength(10)); if (randomBoolean()) { - attachmentBuilder.setAuthorIcon(randomAsciiOfLength(10)); + attachmentBuilder.setAuthorIcon(randomAlphaOfLength(10)); } if (randomBoolean()) { - attachmentBuilder.setAuthorLink(randomAsciiOfLength(10)); + attachmentBuilder.setAuthorLink(randomAlphaOfLength(10)); } } if (randomBoolean()) { - attachmentBuilder.setColor(randomAsciiOfLength(10)); + attachmentBuilder.setColor(randomAlphaOfLength(10)); } if (randomBoolean()) { - attachmentBuilder.setFallback(randomAsciiOfLength(10)); + attachmentBuilder.setFallback(randomAlphaOfLength(10)); } if (randomBoolean()) { - attachmentBuilder.setImageUrl(randomAsciiOfLength(10)); + attachmentBuilder.setImageUrl(randomAlphaOfLength(10)); } if (randomBoolean()) { - attachmentBuilder.setPretext(randomAsciiOfLength(10)); + attachmentBuilder.setPretext(randomAlphaOfLength(10)); } if (randomBoolean()) { - attachmentBuilder.setThumbUrl(randomAsciiOfLength(10)); + attachmentBuilder.setThumbUrl(randomAlphaOfLength(10)); } if (randomBoolean()) { - attachmentBuilder.setTitle(randomAsciiOfLength(10)); + attachmentBuilder.setTitle(randomAlphaOfLength(10)); if (randomBoolean()) { - attachmentBuilder.setTitleLink(randomAsciiOfLength(10)); + attachmentBuilder.setTitleLink(randomAlphaOfLength(10)); } } if (randomBoolean()) { - attachmentBuilder.setText(randomAsciiOfLength(10)); + attachmentBuilder.setText(randomAlphaOfLength(10)); } if (randomBoolean()) { int fieldCount = randomIntBetween(0, 3); for (int j = 0; j < fieldCount; j++) { - attachmentBuilder.addField(randomAsciiOfLength(10), randomAsciiOfLength(10), randomBoolean()); + attachmentBuilder.addField(randomAlphaOfLength(10), randomAlphaOfLength(10), randomBoolean()); } } templateBuilder.addAttachments(attachmentBuilder); @@ -518,61 +518,61 @@ public class SlackMessageTests extends ESTestCase { SlackMessage.Template.Builder templateBuilder = SlackMessage.Template.builder(); if (randomBoolean()) { - templateBuilder.setFrom(randomAsciiOfLength(10)); + templateBuilder.setFrom(randomAlphaOfLength(10)); } if (randomBoolean()) { int count = randomIntBetween(0, 3); for (int i = 0; i < count; i++) { - templateBuilder.addTo(randomAsciiOfLength(10)); + templateBuilder.addTo(randomAlphaOfLength(10)); } } if (randomBoolean()) { - templateBuilder.setIcon(randomAsciiOfLength(10)); + templateBuilder.setIcon(randomAlphaOfLength(10)); } if (randomBoolean()) { - templateBuilder.setText(randomAsciiOfLength(10)); + templateBuilder.setText(randomAlphaOfLength(10)); } if (randomBoolean()) { int count = randomIntBetween(0, 3); for (int i = 0; i < count; i++) { Attachment.Template.Builder attachmentBuilder = Attachment.Template.builder(); if (randomBoolean()) { - attachmentBuilder.setAuthorName(randomAsciiOfLength(10)); + attachmentBuilder.setAuthorName(randomAlphaOfLength(10)); if (randomBoolean()) { - attachmentBuilder.setAuthorIcon(randomAsciiOfLength(10)); + attachmentBuilder.setAuthorIcon(randomAlphaOfLength(10)); } if (randomBoolean()) { - attachmentBuilder.setAuthorLink(randomAsciiOfLength(10)); + attachmentBuilder.setAuthorLink(randomAlphaOfLength(10)); } } if (randomBoolean()) { - attachmentBuilder.setColor(randomAsciiOfLength(10)); + attachmentBuilder.setColor(randomAlphaOfLength(10)); } if (randomBoolean()) { - attachmentBuilder.setFallback(randomAsciiOfLength(10)); + attachmentBuilder.setFallback(randomAlphaOfLength(10)); } if (randomBoolean()) { - attachmentBuilder.setImageUrl(randomAsciiOfLength(10)); + attachmentBuilder.setImageUrl(randomAlphaOfLength(10)); } if (randomBoolean()) { - attachmentBuilder.setPretext(randomAsciiOfLength(10)); + attachmentBuilder.setPretext(randomAlphaOfLength(10)); } if (randomBoolean()) { - attachmentBuilder.setThumbUrl(randomAsciiOfLength(10)); + attachmentBuilder.setThumbUrl(randomAlphaOfLength(10)); } if (randomBoolean()) { - attachmentBuilder.setTitle(randomAsciiOfLength(10)); + attachmentBuilder.setTitle(randomAlphaOfLength(10)); if (randomBoolean()) { - attachmentBuilder.setTitleLink(randomAsciiOfLength(10)); + attachmentBuilder.setTitleLink(randomAlphaOfLength(10)); } } if (randomBoolean()) { - attachmentBuilder.setText(randomAsciiOfLength(10)); + attachmentBuilder.setText(randomAlphaOfLength(10)); } if (randomBoolean()) { int fieldCount = randomIntBetween(0, 3); for (int j = 0; j < fieldCount; j++) { - attachmentBuilder.addField(randomAsciiOfLength(10), randomAsciiOfLength(10), randomBoolean()); + attachmentBuilder.addField(randomAlphaOfLength(10), randomAlphaOfLength(10), randomBoolean()); } } templateBuilder.addAttachments(attachmentBuilder); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksClusterServiceTests.java b/plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksClusterServiceTests.java index b3b1f3ceaf4..0305613ba33 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksClusterServiceTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksClusterServiceTests.java @@ -257,7 +257,7 @@ public class PersistentTasksClusterServiceTests extends ESTestCase { // add a node if there are unassigned tasks if (clusterState.nodes().getNodes().isEmpty()) { logger.info("added random node"); - builder.nodes(DiscoveryNodes.builder(clusterState.nodes()).add(newNode(randomAsciiOfLength(10)))); + builder.nodes(DiscoveryNodes.builder(clusterState.nodes()).add(newNode(randomAlphaOfLength(10)))); tasksOrNodesChanged = true; } @@ -303,7 +303,7 @@ public class PersistentTasksClusterServiceTests extends ESTestCase { // we don't have any unassigned tasks - adding a node or changing a routing table shouldn't affect anything if (randomBoolean()) { logger.info("added random node"); - builder.nodes(DiscoveryNodes.builder(clusterState.nodes()).add(newNode(randomAsciiOfLength(10)))); + builder.nodes(DiscoveryNodes.builder(clusterState.nodes()).add(newNode(randomAlphaOfLength(10)))); } if (randomBoolean()) { logger.info("added random unassignable task"); @@ -351,7 +351,7 @@ public class PersistentTasksClusterServiceTests extends ESTestCase { } } // Just add a random index - that shouldn't change anything - IndexMetaData indexMetaData = IndexMetaData.builder(randomAsciiOfLength(10)) + IndexMetaData indexMetaData = IndexMetaData.builder(randomAlphaOfLength(10)) .settings(Settings.builder().put("index.version.created", VersionUtils.randomVersion(random()))) .numberOfShards(1) .numberOfReplicas(1) @@ -381,15 +381,15 @@ public class PersistentTasksClusterServiceTests extends ESTestCase { private ClusterState.Builder addRandomTask(ClusterState.Builder clusterStateBuilder, MetaData.Builder metaData, PersistentTasksCustomMetaData.Builder tasks, String node) { - return addRandomTask(clusterStateBuilder, metaData, tasks, new Assignment(node, randomAsciiOfLength(10)), - randomAsciiOfLength(10)); + return addRandomTask(clusterStateBuilder, metaData, tasks, new Assignment(node, randomAlphaOfLength(10)), + randomAlphaOfLength(10)); } private ClusterState.Builder addRandomTask(ClusterState.Builder clusterStateBuilder, MetaData.Builder metaData, PersistentTasksCustomMetaData.Builder tasks, Assignment assignment, String param) { return clusterStateBuilder.metaData(metaData.putCustom(PersistentTasksCustomMetaData.TYPE, - tasks.addTask(randomAsciiOfLength(10), new TestRequest(param), assignment).build())); + tasks.addTask(randomAlphaOfLength(10), new TestRequest(param), assignment).build())); } private void addTask(PersistentTasksCustomMetaData.Builder tasks, String action, String param, String node) { @@ -423,7 +423,7 @@ public class PersistentTasksClusterServiceTests extends ESTestCase { } private void changeRoutingTable(MetaData.Builder metaData, RoutingTable.Builder routingTable) { - IndexMetaData indexMetaData = IndexMetaData.builder(randomAsciiOfLength(10)) + IndexMetaData indexMetaData = IndexMetaData.builder(randomAlphaOfLength(10)) .settings(Settings.builder().put("index.version.created", VersionUtils.randomVersion(random()))) .numberOfShards(1) .numberOfReplicas(1) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksCustomMetaDataTests.java b/plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksCustomMetaDataTests.java index 080dc459387..ada1842f1c4 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksCustomMetaDataTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksCustomMetaDataTests.java @@ -44,11 +44,11 @@ public class PersistentTasksCustomMetaDataTests extends AbstractDiffableSerializ int numberOfTasks = randomInt(10); PersistentTasksCustomMetaData.Builder tasks = PersistentTasksCustomMetaData.builder(); for (int i = 0; i < numberOfTasks; i++) { - tasks.addTask(TestPersistentTasksExecutor.NAME, new TestRequest(randomAsciiOfLength(10)), + tasks.addTask(TestPersistentTasksExecutor.NAME, new TestRequest(randomAlphaOfLength(10)), randomAssignment()); if (randomBoolean()) { // From time to time update status - tasks.updateTaskStatus(tasks.getCurrentId(), new Status(randomAsciiOfLength(10))); + tasks.updateTaskStatus(tasks.getCurrentId(), new Status(randomAlphaOfLength(10))); } } return tasks.build(); @@ -88,7 +88,7 @@ public class PersistentTasksCustomMetaDataTests extends AbstractDiffableSerializ if (tasksInProgress.tasks().isEmpty()) { addRandomTask(builder); } else { - builder.updateTaskStatus(pickRandomTask(tasksInProgress), randomBoolean() ? new Status(randomAsciiOfLength(10)) : null); + builder.updateTaskStatus(pickRandomTask(tasksInProgress), randomBoolean() ? new Status(randomAlphaOfLength(10)) : null); } break; case 3: @@ -135,7 +135,7 @@ public class PersistentTasksCustomMetaDataTests extends AbstractDiffableSerializ } private Builder addRandomTask(Builder builder) { - builder.addTask(TestPersistentTasksExecutor.NAME, new TestRequest(randomAsciiOfLength(10)), randomAssignment()); + builder.addTask(TestPersistentTasksExecutor.NAME, new TestRequest(randomAlphaOfLength(10)), randomAssignment()); return builder; } @@ -234,7 +234,7 @@ public class PersistentTasksCustomMetaDataTests extends AbstractDiffableSerializ if (builder.hasTask(lastKnownTask)) { changed = true; } - builder.updateTaskStatus(lastKnownTask, randomBoolean() ? new Status(randomAsciiOfLength(10)) : null); + builder.updateTaskStatus(lastKnownTask, randomBoolean() ? new Status(randomAlphaOfLength(10)) : null); break; case 4: if (builder.hasTask(lastKnownTask)) { @@ -261,9 +261,9 @@ public class PersistentTasksCustomMetaDataTests extends AbstractDiffableSerializ if (randomBoolean()) { return NO_NODE_FOUND; } else { - return new Assignment(null, randomAsciiOfLength(10)); + return new Assignment(null, randomAlphaOfLength(10)); } } - return new Assignment(randomAsciiOfLength(10), randomAsciiOfLength(10)); + return new Assignment(randomAlphaOfLength(10), randomAlphaOfLength(10)); } } \ No newline at end of file diff --git a/plugin/src/test/java/org/elasticsearch/xpack/persistent/StartPersistentActionRequestTests.java b/plugin/src/test/java/org/elasticsearch/xpack/persistent/StartPersistentActionRequestTests.java index 1943ce84003..037773dc2af 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/persistent/StartPersistentActionRequestTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/persistent/StartPersistentActionRequestTests.java @@ -20,15 +20,15 @@ public class StartPersistentActionRequestTests extends AbstractStreamableTestCas protected Request createTestInstance() { TestRequest testRequest = new TestRequest(); if (randomBoolean()) { - testRequest.setTestParam(randomAsciiOfLengthBetween(1, 20)); + testRequest.setTestParam(randomAlphaOfLengthBetween(1, 20)); } if (randomBoolean()) { - testRequest.setParentTask(randomAsciiOfLengthBetween(1, 20), randomLong()); + testRequest.setParentTask(randomAlphaOfLengthBetween(1, 20), randomLong()); } if (randomBoolean()) { - testRequest.setExecutorNodeAttr(randomAsciiOfLengthBetween(1, 20)); + testRequest.setExecutorNodeAttr(randomAlphaOfLengthBetween(1, 20)); } - return new Request(randomAsciiOfLengthBetween(1, 20), new TestRequest()); + return new Request(randomAlphaOfLengthBetween(1, 20), new TestRequest()); } @Override diff --git a/plugin/src/test/java/org/elasticsearch/xpack/persistent/UpdatePersistentTaskRequestTests.java b/plugin/src/test/java/org/elasticsearch/xpack/persistent/UpdatePersistentTaskRequestTests.java index db619f657e1..86b19c28602 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/persistent/UpdatePersistentTaskRequestTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/persistent/UpdatePersistentTaskRequestTests.java @@ -17,7 +17,7 @@ public class UpdatePersistentTaskRequestTests extends AbstractStreamableTestCase @Override protected Request createTestInstance() { - return new Request(randomLong(), randomLong(), new Status(randomAsciiOfLength(10))); + return new Request(randomLong(), randomLong(), new Status(randomAlphaOfLength(10))); } @Override diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/SecuritySettingsTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/SecuritySettingsTests.java index fa82da9d578..2acaafc7c2c 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/SecuritySettingsTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/SecuritySettingsTests.java @@ -113,7 +113,7 @@ public class SecuritySettingsTests extends ESTestCase { .put("tribe.t1.cluster.name", "non_existing") .put("tribe.t2.cluster.name", "non_existing2") .put(XPackSettings.RESERVED_REALM_ENABLED_SETTING.getKey(), false) - .put("xpack.security.authc.realms.foo.type", randomFrom("ldap", "pki", randomAsciiOfLengthBetween(1, 6))) + .put("xpack.security.authc.realms.foo.type", randomFrom("ldap", "pki", randomAlphaOfLengthBetween(1, 6))) .build(); Settings additionalSettings = Security.additionalSettings(noNative, false); assertNotNull(additionalSettings); @@ -122,7 +122,7 @@ public class SecuritySettingsTests extends ESTestCase { final Settings withReserved = Settings.builder() .put("tribe.t1.cluster.name", "non_existing") .put("tribe.t2.cluster.name", "non_existing2") - .put("xpack.security.authc.realms.foo.type", randomFrom("ldap", "pki", randomAsciiOfLengthBetween(1, 6))) + .put("xpack.security.authc.realms.foo.type", randomFrom("ldap", "pki", randomAlphaOfLengthBetween(1, 6))) .build(); IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> Security.additionalSettings(withReserved, false)); assertThat(e.getMessage(), containsString("tribe.on_conflict")); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/SecurityActionMapperTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/action/SecurityActionMapperTests.java index 92f18870ba1..e77492d9313 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/action/SecurityActionMapperTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/action/SecurityActionMapperTests.java @@ -33,7 +33,7 @@ public class SecurityActionMapperTests extends ESTestCase { if (randomBoolean()) { randomAction = randomFrom(actions); } else { - randomAction = randomAsciiOfLength(randomIntBetween(1, 30)); + randomAction = randomAlphaOfLength(randomIntBetween(1, 30)); } } while (randomAction.equals(ClearScrollAction.NAME) || randomAction.equals(AnalyzeAction.NAME) || @@ -48,7 +48,7 @@ public class SecurityActionMapperTests extends ESTestCase { ClearScrollRequest clearScrollRequest = new ClearScrollRequest(); int scrollIds = randomIntBetween(1, 10); for (int i = 0; i < scrollIds; i++) { - clearScrollRequest.addScrollId(randomAsciiOfLength(randomIntBetween(1, 30))); + clearScrollRequest.addScrollId(randomAlphaOfLength(randomIntBetween(1, 30))); } assertThat(securityActionMapper.action(ClearScrollAction.NAME, clearScrollRequest), equalTo(ClearScrollAction.NAME)); } @@ -58,7 +58,7 @@ public class SecurityActionMapperTests extends ESTestCase { ClearScrollRequest clearScrollRequest = new ClearScrollRequest(); int scrollIds = randomIntBetween(0, 10); for (int i = 0; i < scrollIds; i++) { - clearScrollRequest.addScrollId(randomAsciiOfLength(randomIntBetween(1, 30))); + clearScrollRequest.addScrollId(randomAlphaOfLength(randomIntBetween(1, 30))); } clearScrollRequest.addScrollId("_all"); //make sure that wherever the _all is among the scroll ids the action name gets translated @@ -72,10 +72,10 @@ public class SecurityActionMapperTests extends ESTestCase { SecurityActionMapper securityActionMapper = new SecurityActionMapper(); AnalyzeRequest analyzeRequest; if (randomBoolean()) { - analyzeRequest = new AnalyzeRequest(randomAsciiOfLength(randomIntBetween(1, 30))).text("text"); + analyzeRequest = new AnalyzeRequest(randomAlphaOfLength(randomIntBetween(1, 30))).text("text"); } else { analyzeRequest = new AnalyzeRequest(null).text("text"); - analyzeRequest.index(randomAsciiOfLength(randomIntBetween(1, 30))); + analyzeRequest.index(randomAlphaOfLength(randomIntBetween(1, 30))); } assertThat(securityActionMapper.action(AnalyzeAction.NAME, analyzeRequest), equalTo(AnalyzeAction.NAME)); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersActionTests.java index fcaaf1de23d..aa658475ab5 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersActionTests.java @@ -327,7 +327,7 @@ public class TransportGetUsersActionTests extends ESTestCase { int size = scaledRandomIntBetween(3, 16); List users = new ArrayList<>(size); for (int i = 0; i < size; i++) { - users.add(new User("user_" + i, randomAsciiOfLengthBetween(4, 12))); + users.add(new User("user_" + i, randomAlphaOfLengthBetween(4, 12))); } return users; } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportHasPrivilegesActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportHasPrivilegesActionTests.java index 0f5f27d03e9..6d782f8245e 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportHasPrivilegesActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportHasPrivilegesActionTests.java @@ -52,7 +52,7 @@ public class TransportHasPrivilegesActionTests extends ESTestCase { @Before public void setup() { final Settings settings = Settings.builder().build(); - user = new User(randomAsciiOfLengthBetween(4, 12)); + user = new User(randomAlphaOfLengthBetween(4, 12)); final ThreadPool threadPool = mock(ThreadPool.class); final ThreadContext threadContext = new ThreadContext(Settings.EMPTY); final TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/audit/AuditUtilTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/audit/AuditUtilTests.java index ab212923b2d..63896e96792 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/audit/AuditUtilTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/audit/AuditUtilTests.java @@ -27,7 +27,7 @@ public class AuditUtilTests extends ESTestCase { List expectedIndices = new ArrayList<>(); final boolean includeDuplicates = randomBoolean(); for (int i = 0; i < numberOfIndices; i++) { - String name = randomAsciiOfLengthBetween(1, 30); + String name = randomAlphaOfLengthBetween(1, 30); expectedIndices.add(name); if (includeDuplicates) { expectedIndices.add(name); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrailMutedTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrailMutedTests.java index 62a574ace5f..6dad48239a2 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrailMutedTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrailMutedTests.java @@ -149,7 +149,7 @@ public class IndexAuditTrailMutedTests extends ESTestCase { AuthenticationToken token = mock(AuthenticationToken.class); // with realm - auditTrail.authenticationFailed(randomAsciiOfLengthBetween(2, 10), token, "_action", message); + auditTrail.authenticationFailed(randomAlphaOfLengthBetween(2, 10), token, "_action", message); assertThat(messageEnqueued.get(), is(false)); assertThat(clientCalled.get(), is(false)); @@ -162,7 +162,7 @@ public class IndexAuditTrailMutedTests extends ESTestCase { AuthenticationToken token = mock(AuthenticationToken.class); // with realm - auditTrail.authenticationFailed(randomAsciiOfLengthBetween(2, 10), token, restRequest); + auditTrail.authenticationFailed(randomAlphaOfLengthBetween(2, 10), token, restRequest); assertThat(messageEnqueued.get(), is(false)); assertThat(clientCalled.get(), is(false)); verifyZeroInteractions(token, restRequest); @@ -172,7 +172,7 @@ public class IndexAuditTrailMutedTests extends ESTestCase { createAuditTrail(new String[] { "access_granted" }); TransportMessage message = mock(TransportMessage.class); User user = mock(User.class); - auditTrail.accessGranted(user, randomAsciiOfLengthBetween(6, 40), message); + auditTrail.accessGranted(user, randomAlphaOfLengthBetween(6, 40), message); assertThat(messageEnqueued.get(), is(false)); assertThat(clientCalled.get(), is(false)); @@ -194,7 +194,7 @@ public class IndexAuditTrailMutedTests extends ESTestCase { createAuditTrail(new String[] { "access_denied" }); TransportMessage message = mock(TransportMessage.class); User user = mock(User.class); - auditTrail.accessDenied(user, randomAsciiOfLengthBetween(6, 40), message); + auditTrail.accessDenied(user, randomAlphaOfLengthBetween(6, 40), message); assertThat(messageEnqueued.get(), is(false)); assertThat(clientCalled.get(), is(false)); @@ -207,12 +207,12 @@ public class IndexAuditTrailMutedTests extends ESTestCase { User user = mock(User.class); // with user - auditTrail.tamperedRequest(user, randomAsciiOfLengthBetween(6, 40), message); + auditTrail.tamperedRequest(user, randomAlphaOfLengthBetween(6, 40), message); assertThat(messageEnqueued.get(), is(false)); assertThat(clientCalled.get(), is(false)); // without user - auditTrail.tamperedRequest(randomAsciiOfLengthBetween(6, 40), message); + auditTrail.tamperedRequest(randomAlphaOfLengthBetween(6, 40), message); assertThat(messageEnqueued.get(), is(false)); assertThat(clientCalled.get(), is(false)); @@ -224,7 +224,7 @@ public class IndexAuditTrailMutedTests extends ESTestCase { InetAddress address = mock(InetAddress.class); SecurityIpFilterRule rule = mock(SecurityIpFilterRule.class); - auditTrail.connectionGranted(address, randomAsciiOfLengthBetween(1, 12), rule); + auditTrail.connectionGranted(address, randomAlphaOfLengthBetween(1, 12), rule); assertThat(messageEnqueued.get(), is(false)); assertThat(clientCalled.get(), is(false)); @@ -236,7 +236,7 @@ public class IndexAuditTrailMutedTests extends ESTestCase { InetAddress address = mock(InetAddress.class); SecurityIpFilterRule rule = mock(SecurityIpFilterRule.class); - auditTrail.connectionDenied(address, randomAsciiOfLengthBetween(1, 12), rule); + auditTrail.connectionDenied(address, randomAlphaOfLengthBetween(1, 12), rule); assertThat(messageEnqueued.get(), is(false)); assertThat(clientCalled.get(), is(false)); @@ -248,7 +248,7 @@ public class IndexAuditTrailMutedTests extends ESTestCase { TransportMessage message = mock(TransportMessage.class); User user = mock(User.class); - auditTrail.runAsGranted(user, randomAsciiOfLengthBetween(6, 40), message); + auditTrail.runAsGranted(user, randomAlphaOfLengthBetween(6, 40), message); assertThat(messageEnqueued.get(), is(false)); assertThat(clientCalled.get(), is(false)); @@ -260,7 +260,7 @@ public class IndexAuditTrailMutedTests extends ESTestCase { TransportMessage message = mock(TransportMessage.class); User user = mock(User.class); - auditTrail.runAsDenied(user, randomAsciiOfLengthBetween(6, 40), message); + auditTrail.runAsDenied(user, randomAlphaOfLengthBetween(6, 40), message); assertThat(messageEnqueued.get(), is(false)); assertThat(clientCalled.get(), is(false)); @@ -285,7 +285,7 @@ public class IndexAuditTrailMutedTests extends ESTestCase { TransportMessage message = mock(TransportMessage.class); User user = mock(User.class); String realm = "_realm"; - auditTrail.authenticationSuccess(realm, user, randomAsciiOfLengthBetween(6, 40), message); + auditTrail.authenticationSuccess(realm, user, randomAlphaOfLengthBetween(6, 40), message); assertThat(messageEnqueued.get(), is(false)); assertThat(clientCalled.get(), is(false)); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/RealmSettingsTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/RealmSettingsTests.java index 91281769bb0..facf8b10f7b 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/RealmSettingsTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/RealmSettingsTests.java @@ -46,7 +46,7 @@ public class RealmSettingsTests extends ESTestCase { public void testRealmWithUnknownTypeAcceptsAllSettings() throws Exception { final Settings.Builder settings = baseSettings("tam", true) .put("ip", "8.6.75.309") - .put(randomAsciiOfLengthBetween(4, 8), randomTimeValue()); + .put(randomAlphaOfLengthBetween(4, 8), randomTimeValue()); assertSuccess(realm("tam", settings)); } @@ -64,7 +64,7 @@ public class RealmSettingsTests extends ESTestCase { } public void testNativeRealmWithUnknownConfigurationDoesNotValidate() throws Exception { - final Settings.Builder builder = realm("native2", nativeSettings().put("not-valid", randomAsciiOfLength(10))); + final Settings.Builder builder = realm("native2", nativeSettings().put("not-valid", randomAlphaOfLength(10))); assertErrorWithCause("native2", "unknown setting [not-valid]", builder.build()); } @@ -133,12 +133,12 @@ public class RealmSettingsTests extends ESTestCase { if (userSearch) { builder.put("user_search.base_dn", "o=people, dc=example, dc=com"); builder.put("user_search.scope", "sub_tree"); - builder.put("user_search.attribute", randomAsciiOfLengthBetween(2, 5)); + builder.put("user_search.attribute", randomAlphaOfLengthBetween(2, 5)); builder.put("user_search.pool.enabled", randomBoolean()); builder.put("user_search.pool.size", randomIntBetween(10, 100)); builder.put("user_search.pool.initial_size", randomIntBetween(1, 10)); builder.put("user_search.pool.health_check.enabled", randomBoolean()); - builder.put("user_search.pool.health_check.dn", randomAsciiOfLength(32)); + builder.put("user_search.pool.health_check.dn", randomAlphaOfLength(32)); builder.put("user_search.pool.health_check.interval", randomPositiveTimeValue()); } else { builder.putArray("user_dn_templates", @@ -152,7 +152,7 @@ public class RealmSettingsTests extends ESTestCase { builder.put("group_search.filter", "userGroup"); builder.put("group_search.user_attribute", "uid"); } else { - builder.put("user_group_attribute", randomAsciiOfLength(8)); + builder.put("user_group_attribute", randomAlphaOfLength(8)); } return builder; } @@ -166,7 +166,7 @@ public class RealmSettingsTests extends ESTestCase { .put("domain_name", "MEGACORP"); builder.put("user_search.base_dn", "o=people, dc.example, dc.com"); builder.put("user_search.scope", "sub_tree"); - builder.put("user_search.filter", randomAsciiOfLength(5) + "={0}"); + builder.put("user_search.filter", randomAlphaOfLength(5) + "={0}"); builder.put("group_search.base_dn", "o=groups, dc=example, dc=com"); builder.put("group_search.scope", "one_level"); return builder; @@ -178,7 +178,7 @@ public class RealmSettingsTests extends ESTestCase { .put("load_balance.type", "round_robin") .put("load_balance.cache_ttl", randomTimeValue()) .put("unmapped_groups_as_roles", randomBoolean()) - .put("files.role_mapping", "x-pack/" + randomAsciiOfLength(8) + ".yml") + .put("files.role_mapping", "x-pack/" + randomAlphaOfLength(8) + ".yml") .put("timeout.tcp_connect", randomPositiveTimeValue()) .put("timeout.tcp_read", randomPositiveTimeValue()) .put("timeout.ldap_search", randomPositiveTimeValue()); @@ -193,12 +193,12 @@ public class RealmSettingsTests extends ESTestCase { private Settings.Builder pkiSettings(boolean useTrustStore) { final Settings.Builder builder = baseSettings("pki", false) .put("username_pattern", "CN=\\D(\\d+)(?:,\\|$)") - .put("files.role_mapping", "x-pack/" + randomAsciiOfLength(8) + ".yml"); + .put("files.role_mapping", "x-pack/" + randomAlphaOfLength(8) + ".yml"); if (useTrustStore) { - builder.put("truststore.path", randomAsciiOfLengthBetween(8, 32)); - builder.put("truststore.password", randomAsciiOfLengthBetween(4, 12)); - builder.put("truststore.algorithm", randomAsciiOfLengthBetween(6, 10)); + builder.put("truststore.path", randomAlphaOfLengthBetween(8, 32)); + builder.put("truststore.password", randomAlphaOfLengthBetween(4, 12)); + builder.put("truststore.algorithm", randomAlphaOfLengthBetween(6, 10)); } else { builder.putArray("certificate_authorities", generateRandomStringArray(5, 32, false, false)); } @@ -207,20 +207,20 @@ public class RealmSettingsTests extends ESTestCase { private Settings.Builder configureSsl(String prefix, Settings.Builder builder, boolean useKeyStore, boolean useTrustStore) { if (useKeyStore) { - builder.put(prefix + "keystore.path", "x-pack/ssl/" + randomAsciiOfLength(5) + ".jks"); - builder.put(prefix + "keystore.password", randomAsciiOfLength(8)); - builder.put(prefix + "keystore.key_password", randomAsciiOfLength(8)); + builder.put(prefix + "keystore.path", "x-pack/ssl/" + randomAlphaOfLength(5) + ".jks"); + builder.put(prefix + "keystore.password", randomAlphaOfLength(8)); + builder.put(prefix + "keystore.key_password", randomAlphaOfLength(8)); } else { - builder.put(prefix + "key", "x-pack/ssl/" + randomAsciiOfLength(5) + ".key"); - builder.put(prefix + "key_passphrase", randomAsciiOfLength(32)); - builder.put(prefix + "certificate", "x-pack/ssl/" + randomAsciiOfLength(5) + ".cert"); + builder.put(prefix + "key", "x-pack/ssl/" + randomAlphaOfLength(5) + ".key"); + builder.put(prefix + "key_passphrase", randomAlphaOfLength(32)); + builder.put(prefix + "certificate", "x-pack/ssl/" + randomAlphaOfLength(5) + ".cert"); } if (useTrustStore) { - builder.put(prefix + "truststore.path", "x-pack/ssl/" + randomAsciiOfLength(5) + ".jts"); - builder.put(prefix + "truststore.password", randomAsciiOfLength(8)); + builder.put(prefix + "truststore.path", "x-pack/ssl/" + randomAlphaOfLength(5) + ".jts"); + builder.put(prefix + "truststore.password", randomAlphaOfLength(8)); } else { - builder.put(prefix + "certificate_authorities", "x-pack/ssl/" + randomAsciiOfLength(8) + ".ca"); + builder.put(prefix + "certificate_authorities", "x-pack/ssl/" + randomAlphaOfLength(8) + ".ca"); } builder.put(prefix + "verification_mode", "full"); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ESNativeMigrateToolTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ESNativeMigrateToolTests.java index b595c0f9191..6eeac983fe0 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ESNativeMigrateToolTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ESNativeMigrateToolTests.java @@ -67,7 +67,7 @@ public class ESNativeMigrateToolTests extends NativeRealmIntegTestCase { int numToAdd = randomIntBetween(1,10); Set addedUsers = new HashSet(numToAdd); for (int i = 0; i < numToAdd; i++) { - String uname = randomAsciiOfLength(5); + String uname = randomAlphaOfLength(5); c.preparePutUser(uname, "s3kirt".toCharArray(), "role1", "user").get(); addedUsers.add(uname); } @@ -107,7 +107,7 @@ public class ESNativeMigrateToolTests extends NativeRealmIntegTestCase { int numToAdd = randomIntBetween(1,10); Set addedRoles = new HashSet<>(numToAdd); for (int i = 0; i < numToAdd; i++) { - String rname = randomAsciiOfLength(5); + String rname = randomAlphaOfLength(5); c.preparePutRole(rname) .cluster("all", "none") .runAs("root", "nobody") diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java index f634eae1490..edcbc74c257 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java @@ -169,7 +169,7 @@ public class NativeRealmIntegTests extends NativeRealmIntegTestCase { SecurityClient c = securityClient(); final List existingRoles = Arrays.asList(c.prepareGetRoles().get().roles()); final int existing = existingRoles.size(); - final Map metadata = Collections.singletonMap("key", randomAsciiOfLengthBetween(1, 10)); + final Map metadata = Collections.singletonMap("key", randomAlphaOfLengthBetween(1, 10)); logger.error("--> creating role"); c.preparePutRole("test_role") .cluster("all", "none") @@ -470,7 +470,7 @@ public class NativeRealmIntegTests extends NativeRealmIntegTestCase { public void testCannotCreateUserWithShortPassword() throws Exception { SecurityClient client = securityClient(); try { - client.preparePutUser("joe", randomAsciiOfLengthBetween(0, 5).toCharArray(), "admin_role").get(); + client.preparePutUser("joe", randomAlphaOfLengthBetween(0, 5).toCharArray(), "admin_role").get(); fail("cannot create a user without a password < 6 characters"); } catch (ValidationException v) { assertThat(v.getMessage().contains("password"), is(true)); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStoreTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStoreTests.java index 50fe071851d..bc2551407d6 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStoreTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStoreTests.java @@ -95,7 +95,7 @@ public class NativeUsersStoreTests extends ESTestCase { final GetResult result = new GetResult( SecurityLifecycleService.SECURITY_INDEX_NAME, NativeUsersStore.RESERVED_USER_DOC_TYPE, - randomAsciiOfLength(12), + randomAlphaOfLength(12), 1L, true, jsonBuilder().map(values).bytes(), diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmTests.java index 51927202e12..7a622cbca74 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmTests.java @@ -277,7 +277,7 @@ public class ReservedRealmTests extends ESTestCase { final String principal = expectedUser.principal(); assertThat(ReservedRealm.isReserved(principal, Settings.EMPTY), is(true)); - final String notExpected = randomFrom("foobar", "", randomAsciiOfLengthBetween(1, 30)); + final String notExpected = randomFrom("foobar", "", randomAlphaOfLengthBetween(1, 30)); assertThat(ReservedRealm.isReserved(notExpected, Settings.EMPTY), is(false)); } @@ -287,7 +287,7 @@ public class ReservedRealmTests extends ESTestCase { final String principal = expectedUser.principal(); assertThat(ReservedRealm.isReserved(principal, settings), is(false)); - final String notExpected = randomFrom("foobar", "", randomAsciiOfLengthBetween(1, 30)); + final String notExpected = randomFrom("foobar", "", randomAlphaOfLengthBetween(1, 30)); assertThat(ReservedRealm.isReserved(notExpected, settings), is(false)); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/file/FileUserPasswdStoreTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/file/FileUserPasswdStoreTests.java index 84ed32d589c..1638ccee765 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/file/FileUserPasswdStoreTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/file/FileUserPasswdStoreTests.java @@ -170,7 +170,7 @@ public class FileUserPasswdStoreTests extends ESTestCase { } public void testParseFile_WhenFileDoesNotExist() throws Exception { - Path file = createTempDir().resolve(randomAsciiOfLength(10)); + Path file = createTempDir().resolve(randomAlphaOfLength(10)); Logger logger = CapturingLogger.newCapturingLogger(Level.INFO); Map users = FileUserPasswdStore.parseFile(file, logger, Settings.EMPTY); assertThat(users, notNullValue()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/file/FileUserRolesStoreTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/file/FileUserRolesStoreTests.java index bf9698519c5..3d66a5a72f5 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/file/FileUserRolesStoreTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/file/FileUserRolesStoreTests.java @@ -181,7 +181,7 @@ public class FileUserRolesStoreTests extends ESTestCase { } public void testParseFileWhenFileDoesNotExist() throws Exception { - Path file = createTempDir().resolve(randomAsciiOfLength(10)); + Path file = createTempDir().resolve(randomAlphaOfLength(10)); Logger logger = CapturingLogger.newCapturingLogger(Level.INFO); Map usersRoles = FileUserRolesStore.parseFile(file, logger); assertThat(usersRoles, notNullValue()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapLoadBalancingTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapLoadBalancingTests.java index cefe7310dae..cd7fd3abeb3 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapLoadBalancingTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapLoadBalancingTests.java @@ -19,7 +19,7 @@ import static org.hamcrest.Matchers.is; public class LdapLoadBalancingTests extends ESTestCase { public void testBadTypeThrowsException() { - String badType = randomAsciiOfLengthBetween(3, 12); + String badType = randomAlphaOfLengthBetween(3, 12); Settings settings = Settings.builder().put(LdapLoadBalancing.LOAD_BALANCE_SETTINGS + "." + LdapLoadBalancing.LOAD_BALANCE_TYPE_SETTING, badType).build(); try { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactoryTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactoryTests.java index 7202ca0635d..9f15d50c136 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactoryTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactoryTests.java @@ -82,7 +82,7 @@ public class SessionFactoryTests extends ESTestCase { public void testUnauthenticatedSessionThrowsUnsupportedOperationException() throws Exception { UnsupportedOperationException e = expectThrows(UnsupportedOperationException.class, - () -> createSessionFactory().unauthenticatedSession(randomAsciiOfLength(5), new PlainActionFuture<>())); + () -> createSessionFactory().unauthenticatedSession(randomAlphaOfLength(5), new PlainActionFuture<>())); assertThat(e.getMessage(), containsString("unauthenticated sessions")); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/BCryptTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/BCryptTests.java index 58d7fd95d19..dc93330edb6 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/BCryptTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/BCryptTests.java @@ -31,7 +31,7 @@ public class BCryptTests extends ESTestCase { */ @AwaitsFix(bugUrl = "need a better way to test this") public void testUnderLoad() throws Exception { - final String password = randomAsciiOfLengthBetween(10, 32); + final String password = randomAlphaOfLengthBetween(10, 32); final String bcrypt = BCrypt.hashpw(SecuredStringTests.build(password), BCrypt.gensalt()); ExecutorService threadPoolExecutor = Executors.newFixedThreadPool(100); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealmTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealmTests.java index 2c28479bdcd..e1757f41bdc 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealmTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealmTests.java @@ -211,7 +211,7 @@ public class CachingUsernamePasswordRealmTests extends ESTestCase { public void testCacheConcurrency() throws Exception { final String username = "username"; final SecuredString password = new SecuredString("changeme".toCharArray()); - final SecuredString randomPassword = new SecuredString(randomAsciiOfLength(password.length()).toCharArray()); + final SecuredString randomPassword = new SecuredString(randomAlphaOfLength(password.length()).toCharArray()); final String passwordHash = new String(Hasher.BCRYPT.hash(password)); RealmConfig config = new RealmConfig("test_realm", Settings.EMPTY, globalSettings); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/DnRoleMapperTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/DnRoleMapperTests.java index e6f6471deb6..ad33c9a7d82 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/DnRoleMapperTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/DnRoleMapperTests.java @@ -233,7 +233,7 @@ public class DnRoleMapperTests extends ESTestCase { } public void testParseFile_WhenFileDoesNotExist() throws Exception { - Path file = createTempDir().resolve(randomAsciiOfLength(10)); + Path file = createTempDir().resolve(randomAlphaOfLength(10)); Logger logger = CapturingLogger.newCapturingLogger(Level.INFO); Map> mappings = DnRoleMapper.parseFile(file, logger, "_type", "_name"); assertThat(mappings, notNullValue()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/HasherTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/HasherTests.java index 9d1b2e2d6df..f8773241c35 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/HasherTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/HasherTests.java @@ -60,7 +60,7 @@ public class HasherTests extends ESTestCase { } private static void testHasherSelfGenerated(Hasher hasher) throws Exception { - SecuredString passwd = SecuredStringTests.build(randomAsciiOfLength(10)); + SecuredString passwd = SecuredStringTests.build(randomAlphaOfLength(10)); char[] hash = hasher.hash(passwd); assertTrue(hasher.verify(passwd, hash)); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java index c70838ec860..c42a64e6a75 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java @@ -822,7 +822,7 @@ public class AuthorizationServiceTests extends ESTestCase { when(authentication.getRunAsUser()).thenReturn(user); when(authentication.getAuthenticatedBy()).thenReturn(authenticatedBy); when(authenticatedBy.getType()) - .thenReturn(changePasswordRequest ? randomFrom(ReservedRealm.TYPE, NativeRealm.TYPE) : randomAsciiOfLengthBetween(4, 12)); + .thenReturn(changePasswordRequest ? randomFrom(ReservedRealm.TYPE, NativeRealm.TYPE) : randomAlphaOfLengthBetween(4, 12)); assertThat(request, instanceOf(UserRequest.class)); assertTrue(AuthorizationService.checkSameUserPermissions(action, request, authentication)); @@ -831,7 +831,7 @@ public class AuthorizationServiceTests extends ESTestCase { public void testSameUserPermissionDoesNotAllowNonMatchingUsername() { final User user = new User("joe"); final boolean changePasswordRequest = randomBoolean(); - final String username = randomFrom("", "joe" + randomAsciiOfLengthBetween(1, 5), randomAsciiOfLengthBetween(3, 10)); + final String username = randomFrom("", "joe" + randomAlphaOfLengthBetween(1, 5), randomAlphaOfLengthBetween(3, 10)); final TransportRequest request = changePasswordRequest ? new ChangePasswordRequestBuilder(mock(Client.class)).username(username).request() : new AuthenticateRequestBuilder(mock(Client.class)).username(username).request(); @@ -842,7 +842,7 @@ public class AuthorizationServiceTests extends ESTestCase { when(authentication.getRunAsUser()).thenReturn(user); when(authentication.getAuthenticatedBy()).thenReturn(authenticatedBy); when(authenticatedBy.getType()) - .thenReturn(changePasswordRequest ? randomFrom(ReservedRealm.TYPE, NativeRealm.TYPE) : randomAsciiOfLengthBetween(4, 12)); + .thenReturn(changePasswordRequest ? randomFrom(ReservedRealm.TYPE, NativeRealm.TYPE) : randomAlphaOfLengthBetween(4, 12)); assertThat(request, instanceOf(UserRequest.class)); assertFalse(AuthorizationService.checkSameUserPermissions(action, request, authentication)); @@ -853,7 +853,7 @@ public class AuthorizationServiceTests extends ESTestCase { final RealmRef lookedUpBy = mock(RealmRef.class); when(authentication.getLookedUpBy()).thenReturn(lookedUpBy); when(lookedUpBy.getType()) - .thenReturn(changePasswordRequest ? randomFrom(ReservedRealm.TYPE, NativeRealm.TYPE) : randomAsciiOfLengthBetween(4, 12)); + .thenReturn(changePasswordRequest ? randomFrom(ReservedRealm.TYPE, NativeRealm.TYPE) : randomAlphaOfLengthBetween(4, 12)); // this should still fail since the username is still different assertFalse(AuthorizationService.checkSameUserPermissions(action, request, authentication)); @@ -876,7 +876,7 @@ public class AuthorizationServiceTests extends ESTestCase { when(authentication.getRunAsUser()).thenReturn(randomBoolean() ? user : new User("runAs")); when(authentication.getAuthenticatedBy()).thenReturn(authenticatedBy); when(authenticatedBy.getType()) - .thenReturn(randomAsciiOfLengthBetween(4, 12)); + .thenReturn(randomAlphaOfLengthBetween(4, 12)); assertFalse(AuthorizationService.checkSameUserPermissions(action, request, authentication)); verifyZeroInteractions(user, request, authentication); @@ -900,7 +900,7 @@ public class AuthorizationServiceTests extends ESTestCase { when(authentication.getLookedUpBy()).thenReturn(lookedUpBy); when(authentication.isRunAs()).thenReturn(true); when(lookedUpBy.getType()) - .thenReturn(changePasswordRequest ? randomFrom(ReservedRealm.TYPE, NativeRealm.TYPE) : randomAsciiOfLengthBetween(4, 12)); + .thenReturn(changePasswordRequest ? randomFrom(ReservedRealm.TYPE, NativeRealm.TYPE) : randomAlphaOfLengthBetween(4, 12)); assertTrue(AuthorizationService.checkSameUserPermissions(action, request, authentication)); when(authentication.getRunAsUser()).thenReturn(user); @@ -918,7 +918,7 @@ public class AuthorizationServiceTests extends ESTestCase { when(authentication.isRunAs()).thenReturn(false); when(authentication.getAuthenticatedBy()).thenReturn(authenticatedBy); when(authenticatedBy.getType()).thenReturn(randomFrom(LdapRealm.LDAP_TYPE, FileRealm.TYPE, LdapRealm.AD_TYPE, PkiRealm.TYPE, - randomAsciiOfLengthBetween(4, 12))); + randomAlphaOfLengthBetween(4, 12))); assertThat(request, instanceOf(UserRequest.class)); assertFalse(AuthorizationService.checkSameUserPermissions(action, request, authentication)); @@ -943,7 +943,7 @@ public class AuthorizationServiceTests extends ESTestCase { when(authentication.getAuthenticatedBy()).thenReturn(authenticatedBy); when(authentication.getLookedUpBy()).thenReturn(lookedUpBy); when(lookedUpBy.getType()).thenReturn(randomFrom(LdapRealm.LDAP_TYPE, FileRealm.TYPE, LdapRealm.AD_TYPE, PkiRealm.TYPE, - randomAsciiOfLengthBetween(4, 12))); + randomAlphaOfLengthBetween(4, 12))); assertThat(request, instanceOf(UserRequest.class)); assertFalse(AuthorizationService.checkSameUserPermissions(action, request, authentication)); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationUtilsTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationUtilsTests.java index 76f580baeef..93c8419d1ce 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationUtilsTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationUtilsTests.java @@ -43,7 +43,7 @@ public class AuthorizationUtilsTests extends ESTestCase { } public void testSystemUserSwitchWithNonSystemUser() { - User user = new User(randomAsciiOfLength(6), new String[] {}); + User user = new User(randomAlphaOfLength(6), new String[] {}); Authentication authentication = new Authentication(user, new RealmRef("test", "test", "foo"), null); threadContext.putTransient(Authentication.AUTHENTICATION_KEY, authentication); threadContext.putTransient(AuthorizationService.ORIGINATING_ACTION_KEY, randomFrom("indices:foo", "cluster:bar")); @@ -51,7 +51,7 @@ public class AuthorizationUtilsTests extends ESTestCase { } public void testSystemUserSwitchWithNonSystemUserAndInternalAction() { - User user = new User(randomAsciiOfLength(6), new String[] {}); + User user = new User(randomAlphaOfLength(6), new String[] {}); Authentication authentication = new Authentication(user, new RealmRef("test", "test", "foo"), null); threadContext.putTransient(Authentication.AUTHENTICATION_KEY, authentication); threadContext.putTransient(AuthorizationService.ORIGINATING_ACTION_KEY, randomFrom("internal:foo/bar")); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesAccessControlTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesAccessControlTests.java index 5e1db413662..ea33ea1fe88 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesAccessControlTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesAccessControlTests.java @@ -17,6 +17,6 @@ public class IndicesAccessControlTests extends ESTestCase { public void testEmptyIndicesAccessControl() { IndicesAccessControl indicesAccessControl = new IndicesAccessControl(true, Collections.emptyMap()); assertTrue(indicesAccessControl.isGranted()); - assertNull(indicesAccessControl.getIndexPermissions(randomAsciiOfLengthBetween(3,20))); + assertNull(indicesAccessControl.getIndexPermissions(randomAlphaOfLengthBetween(3,20))); } } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesPermissionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesPermissionTests.java index cfd2eec465c..637fabdd8e3 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesPermissionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesPermissionTests.java @@ -89,7 +89,7 @@ public class IndicesPermissionTests extends ESTestCase { // match all fields String[] allFields = randomFrom(new String[]{"*"}, new String[]{"foo", "*"}, - new String[]{randomAsciiOfLengthBetween(1, 10), "*"}); + new String[]{randomAlphaOfLengthBetween(1, 10), "*"}); role = Role.builder("_role") .add(new FieldPermissions(fieldPermissionDef(allFields, null)), query, IndexPrivilege.ALL, "_alias").build(); permissions = role.authorize(SearchAction.NAME, Sets.newHashSet("_alias"), md, fieldPermissionsCache); @@ -101,14 +101,14 @@ public class IndicesPermissionTests extends ESTestCase { public void testIndicesPrivilegesStreaming() throws IOException { BytesStreamOutput out = new BytesStreamOutput(); - String[] allowed = new String[]{randomAsciiOfLength(5) + "*", randomAsciiOfLength(5) + "*", randomAsciiOfLength(5) + "*"}; - String[] denied = new String[]{allowed[0] + randomAsciiOfLength(5), allowed[1] + randomAsciiOfLength(5), - allowed[2] + randomAsciiOfLength(5)}; + String[] allowed = new String[]{randomAlphaOfLength(5) + "*", randomAlphaOfLength(5) + "*", randomAlphaOfLength(5) + "*"}; + String[] denied = new String[]{allowed[0] + randomAlphaOfLength(5), allowed[1] + randomAlphaOfLength(5), + allowed[2] + randomAlphaOfLength(5)}; RoleDescriptor.IndicesPrivileges.Builder indicesPrivileges = RoleDescriptor.IndicesPrivileges.builder(); indicesPrivileges.grantedFields(allowed); indicesPrivileges.deniedFields(denied); indicesPrivileges.query("{match_all:{}}"); - indicesPrivileges.indices(randomAsciiOfLength(5), randomAsciiOfLength(5), randomAsciiOfLength(5)); + indicesPrivileges.indices(randomAlphaOfLength(5), randomAlphaOfLength(5), randomAlphaOfLength(5)); indicesPrivileges.privileges("all", "read", "priv"); indicesPrivileges.build().writeTo(out); out.close(); @@ -148,7 +148,7 @@ public class IndicesPermissionTests extends ESTestCase { Map authzMap = core.authorize(SearchAction.NAME, Sets.newHashSet("a1", "ba"), metaData, fieldPermissionsCache); assertTrue(authzMap.get("a1").getFieldPermissions().grantsAccessTo("denied_field")); - assertTrue(authzMap.get("a1").getFieldPermissions().grantsAccessTo(randomAsciiOfLength(5))); + assertTrue(authzMap.get("a1").getFieldPermissions().grantsAccessTo(randomAlphaOfLength(5))); // did not define anything for ba so we allow all assertFalse(authzMap.get("ba").getFieldPermissions().hasFieldLevelSecurity()); @@ -168,8 +168,8 @@ public class IndicesPermissionTests extends ESTestCase { assertFalse(authzMap.get("a1").getFieldPermissions().hasFieldLevelSecurity()); assertFalse(authzMap.get("a2").getFieldPermissions().grantsAccessTo("denied_field2")); assertFalse(authzMap.get("a2").getFieldPermissions().grantsAccessTo("denied_field")); - assertTrue(authzMap.get("a2").getFieldPermissions().grantsAccessTo(randomAsciiOfLength(5) + "_field")); - assertTrue(authzMap.get("a2").getFieldPermissions().grantsAccessTo(randomAsciiOfLength(5) + "_field2")); + assertTrue(authzMap.get("a2").getFieldPermissions().grantsAccessTo(randomAlphaOfLength(5) + "_field")); + assertTrue(authzMap.get("a2").getFieldPermissions().grantsAccessTo(randomAlphaOfLength(5) + "_field2")); assertTrue(authzMap.get("a2").getFieldPermissions().hasFieldLevelSecurity()); assertTrue(core.check(SearchAction.NAME)); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissionsCacheTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissionsCacheTests.java index 53f95325121..3e92836e9ad 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissionsCacheTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissionsCacheTests.java @@ -17,9 +17,9 @@ public class FieldPermissionsCacheTests extends ESTestCase { public void testFieldPermissionsCaching() { FieldPermissionsCache fieldPermissionsCache = new FieldPermissionsCache(Settings.EMPTY); - String[] allowed = new String[]{randomAsciiOfLength(5) + "*", randomAsciiOfLength(5) + "*", randomAsciiOfLength(5) + "*"}; - String[] denied = new String[]{allowed[0] + randomAsciiOfLength(5), allowed[1] + randomAsciiOfLength(5), - allowed[2] + randomAsciiOfLength(5)}; + String[] allowed = new String[]{randomAlphaOfLength(5) + "*", randomAlphaOfLength(5) + "*", randomAlphaOfLength(5) + "*"}; + String[] denied = new String[]{allowed[0] + randomAlphaOfLength(5), allowed[1] + randomAlphaOfLength(5), + allowed[2] + randomAlphaOfLength(5)}; FieldPermissions fieldPermissions = fieldPermissionsCache.getFieldPermissions(allowed, denied); assertNotNull(fieldPermissions); final String[] allowed2 = randomBoolean() ? allowed : Arrays.copyOf(allowed, allowed.length); @@ -29,8 +29,8 @@ public class FieldPermissionsCacheTests extends ESTestCase { public void testMergeFieldPermissions() { FieldPermissionsCache fieldPermissionsCache = new FieldPermissionsCache(Settings.EMPTY); - String allowedPrefix1 = randomAsciiOfLength(5); - String allowedPrefix2 = randomAsciiOfLength(5); + String allowedPrefix1 = randomAlphaOfLength(5); + String allowedPrefix2 = randomAlphaOfLength(5); String[] allowed1 = new String[]{allowedPrefix1 + "*"}; String[] allowed2 = new String[]{allowedPrefix2 + "*"}; String[] denied1 = new String[]{allowedPrefix1 + "a"}; @@ -46,7 +46,7 @@ public class FieldPermissionsCacheTests extends ESTestCase { assertFalse(mergedFieldPermissions.grantsAccessTo(denied1[0])); assertFalse(mergedFieldPermissions.grantsAccessTo(denied2[0])); - allowed1 = new String[]{randomAsciiOfLength(5) + "*", randomAsciiOfLength(5) + "*"}; + allowed1 = new String[]{randomAlphaOfLength(5) + "*", randomAlphaOfLength(5) + "*"}; allowed2 = null; denied1 = new String[]{allowed1[0] + "a", allowed1[1] + "a"}; denied2 = null; @@ -59,7 +59,7 @@ public class FieldPermissionsCacheTests extends ESTestCase { assertFalse(mergedFieldPermissions.hasFieldLevelSecurity()); allowed1 = new String[]{}; - allowed2 = new String[]{randomAsciiOfLength(5) + "*", randomAsciiOfLength(5) + "*"}; + allowed2 = new String[]{randomAlphaOfLength(5) + "*", randomAlphaOfLength(5) + "*"}; denied1 = new String[]{}; denied2 = new String[]{allowed2[0] + "a", allowed2[1] + "a"}; fieldPermissions1 = randomBoolean() ? fieldPermissionsCache.getFieldPermissions(allowed1, denied1) : diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/permission/PermissionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/permission/PermissionTests.java index f2f9bda5e8f..f7bdaa124ca 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/permission/PermissionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/permission/PermissionTests.java @@ -54,7 +54,7 @@ public class PermissionTests extends ESTestCase { .build(); assertThat(permission.runAs().check("user1"), is(true)); assertThat(permission.runAs().check("user"), is(false)); - assertThat(permission.runAs().check("run" + randomAsciiOfLengthBetween(1, 10)), is(true)); + assertThat(permission.runAs().check("run" + randomAlphaOfLengthBetween(1, 10)), is(true)); } // "baz_*foo", "/fool.*bar/" diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStoreTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStoreTests.java index 455643a002d..7424db98d03 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStoreTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStoreTests.java @@ -184,7 +184,7 @@ public class CompositeRolesStoreTests extends ESTestCase { Collections.emptyList(), new ThreadContext(Settings.EMPTY), new XPackLicenseState()); verify(fileRolesStore).addListener(any(Runnable.class)); // adds a listener in ctor - final String roleName = randomAsciiOfLengthBetween(1, 10); + final String roleName = randomAlphaOfLengthBetween(1, 10); PlainActionFuture future = new PlainActionFuture<>(); final FieldPermissionsCache fieldPermissionsCache = new FieldPermissionsCache(Settings.EMPTY); compositeRolesStore.roles(Collections.singleton(roleName), fieldPermissionsCache, future); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStoreTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStoreTests.java index e4497de31c1..8ba74c5567a 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStoreTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStoreTests.java @@ -257,7 +257,7 @@ public class NativeRolesStoreTests extends ESTestCase { ShardRouting shardRouting = ShardRouting.newUnassigned(new ShardId(index, 0), true, EXISTING_STORE_INSTANCE, new UnassignedInfo(Reason.INDEX_CREATED, "")); IndexShardRoutingTable table = new IndexShardRoutingTable.Builder(new ShardId(index, 0)) - .addShard(shardRouting.initialize(randomAsciiOfLength(8), null, shardRouting.getExpectedShardSize()).moveToStarted()) + .addShard(shardRouting.initialize(randomAlphaOfLength(8), null, shardRouting.getExpectedShardSize()).moveToStarted()) .build(); RoutingTable routingTable = RoutingTable.builder() .add(IndexRoutingTable diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/ReservedRolesStoreTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/ReservedRolesStoreTests.java index 2eb70410e5b..f566be892af 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/ReservedRolesStoreTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/ReservedRolesStoreTests.java @@ -85,9 +85,9 @@ public class ReservedRolesStoreTests extends ESTestCase { assertThat(ingestAdminRole.cluster().check(MonitoringBulkAction.NAME), is(false)); assertThat(ingestAdminRole.indices().allowedIndicesMatcher(IndexAction.NAME).test("foo"), is(false)); - assertThat(ingestAdminRole.indices().allowedIndicesMatcher("indices:foo").test(randomAsciiOfLengthBetween(8, 24)), + assertThat(ingestAdminRole.indices().allowedIndicesMatcher("indices:foo").test(randomAlphaOfLengthBetween(8, 24)), is(false)); - assertThat(ingestAdminRole.indices().allowedIndicesMatcher(GetAction.NAME).test(randomAsciiOfLengthBetween(8, 24)), + assertThat(ingestAdminRole.indices().allowedIndicesMatcher(GetAction.NAME).test(randomAlphaOfLengthBetween(8, 24)), is(false)); } @@ -105,13 +105,13 @@ public class ReservedRolesStoreTests extends ESTestCase { assertThat(kibanaRole.cluster().check(ClusterUpdateSettingsAction.NAME), is(false)); assertThat(kibanaRole.cluster().check(MonitoringBulkAction.NAME), is(true)); - assertThat(kibanaRole.runAs().check(randomAsciiOfLengthBetween(1, 12)), is(false)); + assertThat(kibanaRole.runAs().check(randomAlphaOfLengthBetween(1, 12)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test("foo"), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(".reporting"), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(randomAsciiOfLengthBetween(8, 24)), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(randomAlphaOfLengthBetween(8, 24)), is(false)); - Arrays.asList(".kibana", ".kibana-devnull", ".reporting-" + randomAsciiOfLength(randomIntBetween(0, 13))).forEach((index) -> { + Arrays.asList(".kibana", ".kibana-devnull", ".reporting-" + randomAlphaOfLength(randomIntBetween(0, 13))).forEach((index) -> { logger.info("index name [{}]", index); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(index), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(index), is(true)); @@ -137,12 +137,12 @@ public class ReservedRolesStoreTests extends ESTestCase { assertThat(kibanaUserRole.cluster().check(ClusterUpdateSettingsAction.NAME), is(false)); assertThat(kibanaUserRole.cluster().check(MonitoringBulkAction.NAME), is(false)); - assertThat(kibanaUserRole.runAs().check(randomAsciiOfLengthBetween(1, 12)), is(false)); + assertThat(kibanaUserRole.runAs().check(randomAlphaOfLengthBetween(1, 12)), is(false)); assertThat(kibanaUserRole.indices().allowedIndicesMatcher(IndexAction.NAME).test("foo"), is(false)); assertThat(kibanaUserRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(".reporting"), is(false)); assertThat(kibanaUserRole.indices().allowedIndicesMatcher("indices:foo") - .test(randomAsciiOfLengthBetween(8, 24)), is(false)); + .test(randomAlphaOfLengthBetween(8, 24)), is(false)); Arrays.asList(".kibana", ".kibana-devnull").forEach((index) -> { logger.info("index name [{}]", index); @@ -173,16 +173,16 @@ public class ReservedRolesStoreTests extends ESTestCase { assertThat(monitoringUserRole.cluster().check(ClusterUpdateSettingsAction.NAME), is(false)); assertThat(monitoringUserRole.cluster().check(MonitoringBulkAction.NAME), is(false)); - assertThat(monitoringUserRole.runAs().check(randomAsciiOfLengthBetween(1, 12)), is(false)); + assertThat(monitoringUserRole.runAs().check(randomAlphaOfLengthBetween(1, 12)), is(false)); assertThat(monitoringUserRole.indices().allowedIndicesMatcher(SearchAction.NAME).test("foo"), is(false)); assertThat(monitoringUserRole.indices().allowedIndicesMatcher(SearchAction.NAME).test(".reporting"), is(false)); assertThat(monitoringUserRole.indices().allowedIndicesMatcher(SearchAction.NAME).test(".kibana"), is(false)); - assertThat(monitoringUserRole.indices().allowedIndicesMatcher("indices:foo").test(randomAsciiOfLengthBetween(8, 24)), + assertThat(monitoringUserRole.indices().allowedIndicesMatcher("indices:foo").test(randomAlphaOfLengthBetween(8, 24)), is(false)); - Arrays.asList(".monitoring-" + randomAsciiOfLength(randomIntBetween(0, 13)), - ".marvel-es-" + randomAsciiOfLength(randomIntBetween(0, 13))).forEach((index) -> { + Arrays.asList(".monitoring-" + randomAlphaOfLength(randomIntBetween(0, 13)), + ".marvel-es-" + randomAlphaOfLength(randomIntBetween(0, 13))).forEach((index) -> { assertThat(monitoringUserRole.indices().allowedIndicesMatcher("indices:foo").test(index), is(false)); assertThat(monitoringUserRole.indices().allowedIndicesMatcher("indices:bar").test(index), is(false)); assertThat(monitoringUserRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(index), is(false)); @@ -210,16 +210,16 @@ public class ReservedRolesStoreTests extends ESTestCase { is(false)); assertThat(remoteMonitoringAgentRole.cluster().check(MonitoringBulkAction.NAME), is(false)); - assertThat(remoteMonitoringAgentRole.runAs().check(randomAsciiOfLengthBetween(1, 12)), is(false)); + assertThat(remoteMonitoringAgentRole.runAs().check(randomAlphaOfLengthBetween(1, 12)), is(false)); assertThat(remoteMonitoringAgentRole.indices().allowedIndicesMatcher(SearchAction.NAME).test("foo"), is(false)); assertThat(remoteMonitoringAgentRole.indices().allowedIndicesMatcher(SearchAction.NAME).test(".reporting"), is(false)); assertThat(remoteMonitoringAgentRole.indices().allowedIndicesMatcher(SearchAction.NAME).test(".kibana"), is(false)); assertThat(remoteMonitoringAgentRole.indices().allowedIndicesMatcher("indices:foo") - .test(randomAsciiOfLengthBetween(8, 24)), is(false)); + .test(randomAlphaOfLengthBetween(8, 24)), is(false)); - Arrays.asList(".monitoring-" + randomAsciiOfLength(randomIntBetween(0, 13)), - ".marvel-es-" + randomAsciiOfLength(randomIntBetween(0, 13))).forEach((index) -> { + Arrays.asList(".monitoring-" + randomAlphaOfLength(randomIntBetween(0, 13)), + ".marvel-es-" + randomAlphaOfLength(randomIntBetween(0, 13))).forEach((index) -> { assertThat(remoteMonitoringAgentRole.indices().allowedIndicesMatcher("indices:foo").test(index), is(true)); assertThat(remoteMonitoringAgentRole.indices().allowedIndicesMatcher("indices:bar").test(index), is(true)); assertThat(remoteMonitoringAgentRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(index), is(true)); @@ -247,15 +247,15 @@ public class ReservedRolesStoreTests extends ESTestCase { assertThat(reportingUserRole.cluster().check(ClusterUpdateSettingsAction.NAME), is(false)); assertThat(reportingUserRole.cluster().check(MonitoringBulkAction.NAME), is(false)); - assertThat(reportingUserRole.runAs().check(randomAsciiOfLengthBetween(1, 12)), is(false)); + assertThat(reportingUserRole.runAs().check(randomAlphaOfLengthBetween(1, 12)), is(false)); assertThat(reportingUserRole.indices().allowedIndicesMatcher(SearchAction.NAME).test("foo"), is(false)); assertThat(reportingUserRole.indices().allowedIndicesMatcher(SearchAction.NAME).test(".reporting"), is(false)); assertThat(reportingUserRole.indices().allowedIndicesMatcher(SearchAction.NAME).test(".kibana"), is(false)); - assertThat(reportingUserRole.indices().allowedIndicesMatcher("indices:foo").test(randomAsciiOfLengthBetween(8, 24)), + assertThat(reportingUserRole.indices().allowedIndicesMatcher("indices:foo").test(randomAlphaOfLengthBetween(8, 24)), is(false)); - final String index = ".reporting-" + randomAsciiOfLength(randomIntBetween(0, 13)); + final String index = ".reporting-" + randomAlphaOfLength(randomIntBetween(0, 13)); assertThat(reportingUserRole.indices().allowedIndicesMatcher("indices:foo").test(index), is(false)); assertThat(reportingUserRole.indices().allowedIndicesMatcher("indices:bar").test(index), is(false)); assertThat(reportingUserRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(index), is(false)); @@ -315,7 +315,7 @@ public class ReservedRolesStoreTests extends ESTestCase { assertTrue(superuserRole.indices().check(SearchAction.NAME)); assertFalse(superuserRole.indices().check("unknown")); - assertThat(superuserRole.runAs().check(randomAsciiOfLengthBetween(1, 30)), is(true)); + assertThat(superuserRole.runAs().check(randomAlphaOfLengthBetween(1, 30)), is(true)); } public void testLogstashSystemRole() { @@ -332,11 +332,11 @@ public class ReservedRolesStoreTests extends ESTestCase { assertThat(logstashSystemRole.cluster().check(ClusterUpdateSettingsAction.NAME), is(false)); assertThat(logstashSystemRole.cluster().check(MonitoringBulkAction.NAME), is(true)); - assertThat(logstashSystemRole.runAs().check(randomAsciiOfLengthBetween(1, 30)), is(false)); + assertThat(logstashSystemRole.runAs().check(randomAlphaOfLengthBetween(1, 30)), is(false)); assertThat(logstashSystemRole.indices().allowedIndicesMatcher(IndexAction.NAME).test("foo"), is(false)); assertThat(logstashSystemRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(".reporting"), is(false)); - assertThat(logstashSystemRole.indices().allowedIndicesMatcher("indices:foo").test(randomAsciiOfLengthBetween(8, 24)), + assertThat(logstashSystemRole.indices().allowedIndicesMatcher("indices:foo").test(randomAlphaOfLengthBetween(8, 24)), is(false)); } @@ -354,11 +354,11 @@ public class ReservedRolesStoreTests extends ESTestCase { assertThat(beatsSystemRole.cluster().check(ClusterUpdateSettingsAction.NAME), is(false)); assertThat(beatsSystemRole.cluster().check(MonitoringBulkAction.NAME), is(true)); - assertThat(beatsSystemRole.runAs().check(randomAsciiOfLengthBetween(1, 30)), is(false)); + assertThat(beatsSystemRole.runAs().check(randomAlphaOfLengthBetween(1, 30)), is(false)); assertThat(beatsSystemRole.indices().allowedIndicesMatcher(IndexAction.NAME).test("foo"), is(false)); assertThat(beatsSystemRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(".reporting"), is(false)); - assertThat(beatsSystemRole.indices().allowedIndicesMatcher("indices:foo").test(randomAsciiOfLengthBetween(8, 24)), + assertThat(beatsSystemRole.indices().allowedIndicesMatcher("indices:foo").test(randomAlphaOfLengthBetween(8, 24)), is(false)); } } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/crypto/CryptoServiceTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/crypto/CryptoServiceTests.java index 2d24b5dd3ba..838ca1cb662 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/crypto/CryptoServiceTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/crypto/CryptoServiceTests.java @@ -44,14 +44,14 @@ public class CryptoServiceTests extends ESTestCase { public void testSigned() throws Exception { CryptoService service = new CryptoService(settings, env); - String text = randomAsciiOfLength(10); + String text = randomAlphaOfLength(10); String signed = service.sign(text); assertThat(service.isSigned(signed), is(true)); } public void testSignAndUnsign() throws Exception { CryptoService service = new CryptoService(settings, env); - String text = randomAsciiOfLength(10); + String text = randomAlphaOfLength(10); String signed = service.sign(text); assertThat(text.equals(signed), is(false)); String text2 = service.unsignAndVerify(signed); @@ -61,7 +61,7 @@ public class CryptoServiceTests extends ESTestCase { public void testSignAndUnsignNoKeyFile() throws Exception { Files.delete(keyFile); CryptoService service = new CryptoService(Settings.EMPTY, env); - final String text = randomAsciiOfLength(10); + final String text = randomAlphaOfLength(10); String signed = service.sign(text); assertThat(text, equalTo(signed)); String unsigned = service.unsignAndVerify(signed); @@ -70,11 +70,11 @@ public class CryptoServiceTests extends ESTestCase { public void testTamperedSignature() throws Exception { CryptoService service = new CryptoService(settings, env); - String text = randomAsciiOfLength(10); + String text = randomAlphaOfLength(10); String signed = service.sign(text); int i = signed.indexOf("$$", 2); int length = Integer.parseInt(signed.substring(2, i)); - String fakeSignature = randomAsciiOfLength(length); + String fakeSignature = randomAlphaOfLength(length); String fakeSignedText = "$$" + length + "$$" + fakeSignature + signed.substring(i + 2 + length); try { @@ -87,12 +87,12 @@ public class CryptoServiceTests extends ESTestCase { public void testTamperedSignatureOneChar() throws Exception { CryptoService service = new CryptoService(settings, env); - String text = randomAsciiOfLength(10); + String text = randomAlphaOfLength(10); String signed = service.sign(text); int i = signed.indexOf("$$", 2); int length = Integer.parseInt(signed.substring(2, i)); StringBuilder fakeSignature = new StringBuilder(signed.substring(i + 2, i + 2 + length)); - fakeSignature.setCharAt(randomIntBetween(0, fakeSignature.length() - 1), randomAsciiOfLength(1).charAt(0)); + fakeSignature.setCharAt(randomIntBetween(0, fakeSignature.length() - 1), randomAlphaOfLength(1).charAt(0)); String fakeSignedText = "$$" + length + "$$" + fakeSignature.toString() + signed.substring(i + 2 + length); @@ -106,11 +106,11 @@ public class CryptoServiceTests extends ESTestCase { public void testTamperedSignatureLength() throws Exception { CryptoService service = new CryptoService(settings, env); - String text = randomAsciiOfLength(10); + String text = randomAlphaOfLength(10); String signed = service.sign(text); int i = signed.indexOf("$$", 2); int length = Integer.parseInt(signed.substring(2, i)); - String fakeSignature = randomAsciiOfLength(length); + String fakeSignature = randomAlphaOfLength(length); // Smaller sig length String fakeSignedText = "$$" + randomIntBetween(0, length - 1) + "$$" + fakeSignature + signed.substring(i + 2 + length); @@ -134,7 +134,7 @@ public class CryptoServiceTests extends ESTestCase { public void testEncryptionAndDecryptionChars() throws Exception { CryptoService service = new CryptoService(settings, env); assertThat(service.isEncryptionEnabled(), is(true)); - final char[] chars = randomAsciiOfLengthBetween(0, 1000).toCharArray(); + final char[] chars = randomAlphaOfLengthBetween(0, 1000).toCharArray(); final char[] encrypted = service.encrypt(chars); assertThat(encrypted, notNullValue()); assertThat(Arrays.equals(encrypted, chars), is(false)); @@ -147,7 +147,7 @@ public class CryptoServiceTests extends ESTestCase { Files.delete(keyFile); CryptoService service = new CryptoService(Settings.EMPTY, env); assertThat(service.isEncryptionEnabled(), is(false)); - final char[] chars = randomAsciiOfLengthBetween(0, 1000).toCharArray(); + final char[] chars = randomAlphaOfLengthBetween(0, 1000).toCharArray(); final char[] encryptedChars = service.encrypt(chars); final char[] decryptedChars = service.decrypt(encryptedChars); assertThat(chars, equalTo(encryptedChars)); @@ -173,8 +173,8 @@ public class CryptoServiceTests extends ESTestCase { assertThat(service.isEncrypted(new char[0]), is(false)); assertThat(service.isEncrypted(new char[CryptoService.ENCRYPTED_TEXT_PREFIX.length()]), is(false)); assertThat(service.isEncrypted(CryptoService.ENCRYPTED_TEXT_PREFIX.toCharArray()), is(true)); - assertThat(service.isEncrypted(randomAsciiOfLengthBetween(0, 100).toCharArray()), is(false)); - assertThat(service.isEncrypted(service.encrypt(randomAsciiOfLength(10).toCharArray())), is(true)); + assertThat(service.isEncrypted(randomAlphaOfLengthBetween(0, 100).toCharArray()), is(false)); + assertThat(service.isEncrypted(service.encrypt(randomAlphaOfLength(10).toCharArray())), is(true)); } public void testSystemKeyFileRequired() throws Exception { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/crypto/tool/SystemKeyToolTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/crypto/tool/SystemKeyToolTests.java index 62761ed9e54..34ba29e2074 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/crypto/tool/SystemKeyToolTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/crypto/tool/SystemKeyToolTests.java @@ -47,7 +47,7 @@ public class SystemKeyToolTests extends CommandTestCase { public void testGenerate() throws Exception { final Path homeDir = initFileSystem(true); - Path path = jimfs.getPath(randomAsciiOfLength(10)).resolve("key"); + Path path = jimfs.getPath(randomAlphaOfLength(10)).resolve("key"); Files.createDirectory(path.getParent()); execute("-Epath.home=" + homeDir, path.toString()); @@ -83,7 +83,7 @@ public class SystemKeyToolTests extends CommandTestCase { public void testThatSystemKeyMayOnlyBeReadByOwner() throws Exception { final Path homeDir = initFileSystem(true); - Path path = jimfs.getPath(randomAsciiOfLength(10)).resolve("key"); + Path path = jimfs.getPath(randomAlphaOfLength(10)).resolve("key"); Files.createDirectories(path.getParent()); execute("-Epath.home=" + homeDir, path.toString()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/support/SecurityFilesTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/support/SecurityFilesTests.java index f8284209a83..f546fbfda53 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/support/SecurityFilesTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/support/SecurityFilesTests.java @@ -66,8 +66,8 @@ public class SecurityFilesTests extends ESTestCase { Files.write(tempPath, "bar".getBytes(StandardCharsets.UTF_8)); PosixFileAttributeView view = Files.getFileAttributeView(path, PosixFileAttributeView.class); - view.setGroup(fs.getUserPrincipalLookupService().lookupPrincipalByGroupName(randomAsciiOfLength(10))); - view.setOwner(fs.getUserPrincipalLookupService().lookupPrincipalByName(randomAsciiOfLength(10))); + view.setGroup(fs.getUserPrincipalLookupService().lookupPrincipalByGroupName(randomAlphaOfLength(10))); + view.setOwner(fs.getUserPrincipalLookupService().lookupPrincipalByName(randomAlphaOfLength(10))); PosixFileAttributeView tempPathView = Files.getFileAttributeView(tempPath, PosixFileAttributeView.class); assertThat(tempPathView.getOwner(), not(equalTo(view.getOwner()))); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/support/ValidationTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/support/ValidationTests.java index 2fc80ce0f17..39ffc8f98d9 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/support/ValidationTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/support/ValidationTests.java @@ -79,7 +79,7 @@ public class ValidationTests extends ESTestCase { } public void testUsersValidatePassword() throws Exception { - String passwd = randomAsciiOfLength(randomIntBetween(0, 20)); + String passwd = randomAlphaOfLength(randomIntBetween(0, 20)); logger.info("{}[{}]", passwd, passwd.length()); if (passwd.length() >= 6) { assertThat(Users.validatePassword(passwd.toCharArray()), nullValue()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/test/SecurityTestUtils.java b/plugin/src/test/java/org/elasticsearch/xpack/security/test/SecurityTestUtils.java index 0d09436f89d..3d05b0f4775 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/test/SecurityTestUtils.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/test/SecurityTestUtils.java @@ -96,7 +96,7 @@ public class SecurityTestUtils { Index index = new Index(SecurityLifecycleService.SECURITY_INDEX_NAME, UUID.randomUUID().toString()); ShardRouting shardRouting = ShardRouting.newUnassigned(new ShardId(index, 0), true, EXISTING_STORE_INSTANCE, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, "")); - String nodeId = ESTestCase.randomAsciiOfLength(8); + String nodeId = ESTestCase.randomAlphaOfLength(8); IndexShardRoutingTable table = new IndexShardRoutingTable.Builder(new ShardId(index, 0)) .addShard(shardRouting.initialize(nodeId, null, shardRouting.getExpectedShardSize()).moveToStarted()) .build(); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/user/UserTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/user/UserTests.java index dbfbef84490..b594872ea8d 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/user/UserTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/user/UserTests.java @@ -22,7 +22,7 @@ import static org.hamcrest.Matchers.sameInstance; public class UserTests extends ESTestCase { public void testWriteToAndReadFrom() throws Exception { - User user = new User(randomAsciiOfLengthBetween(4, 30), + User user = new User(randomAlphaOfLengthBetween(4, 30), generateRandomStringArray(20, 30, false)); BytesStreamOutput output = new BytesStreamOutput(); @@ -36,9 +36,9 @@ public class UserTests extends ESTestCase { } public void testWriteToAndReadFromWithRunAs() throws Exception { - User runAs = new User(randomAsciiOfLengthBetween(4, 30), + User runAs = new User(randomAlphaOfLengthBetween(4, 30), randomBoolean() ? generateRandomStringArray(20, 30, false) : null); - User user = new User(randomAsciiOfLengthBetween(4, 30), + User user = new User(randomAlphaOfLengthBetween(4, 30), generateRandomStringArray(20, 30, false), runAs); BytesStreamOutput output = new BytesStreamOutput(); @@ -78,7 +78,7 @@ public class UserTests extends ESTestCase { public void testFakeInternalUserSerialization() throws Exception { BytesStreamOutput output = new BytesStreamOutput(); output.writeBoolean(true); - output.writeString(randomAsciiOfLengthBetween(4, 30)); + output.writeString(randomAlphaOfLengthBetween(4, 30)); try { User.readFrom(output.bytes().streamInput()); fail("system user had wrong name"); @@ -89,7 +89,7 @@ public class UserTests extends ESTestCase { public void testCreateUserRunningAsSystemUser() throws Exception { try { - new User(randomAsciiOfLengthBetween(3, 10), + new User(randomAlphaOfLengthBetween(3, 10), generateRandomStringArray(16, 30, false), SystemUser.INSTANCE); fail("should not be able to create a runAs user with the system user"); } catch (ElasticsearchSecurityException e) { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ssl/CertificateToolTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ssl/CertificateToolTests.java index 6970e99f80c..f0d300b4946 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ssl/CertificateToolTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ssl/CertificateToolTests.java @@ -108,7 +108,7 @@ public class CertificateToolTests extends ESTestCase { assertTrue(terminal.getOutput().isEmpty()); // test with empty user input - String defaultFilename = randomAsciiOfLengthBetween(1, 10); + String defaultFilename = randomAlphaOfLengthBetween(1, 10); Path expectedDefaultPath = XPackPlugin.resolveConfigFile(env, defaultFilename); terminal.addTextInput(""); resolvedOutputFile = CertificateTool.getOutputFile(terminal, null, env, defaultFilename); @@ -373,7 +373,7 @@ public class CertificateToolTests extends ESTestCase { assertEquals("my instance", name.filename); // too long - String userProvidedName = randomAsciiOfLength(CertificateTool.MAX_FILENAME_LENGTH + 1); + String userProvidedName = randomAlphaOfLength(CertificateTool.MAX_FILENAME_LENGTH + 1); name = Name.fromUserProvidedName(userProvidedName, userProvidedName); assertEquals(userProvidedName, name.originalName); assertThat(name.error, containsString("valid filename")); @@ -459,7 +459,7 @@ public class CertificateToolTests extends ESTestCase { String name; boolean valid; do { - name = randomAsciiOfLengthBetween(1, 32); + name = randomAlphaOfLengthBetween(1, 32); valid = Name.fromUserProvidedName(name, name).error == null; } while (valid == false); return name; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ssl/GeneratedKeyConfigTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ssl/GeneratedKeyConfigTests.java index d9803315bdc..add53b1e034 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ssl/GeneratedKeyConfigTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ssl/GeneratedKeyConfigTests.java @@ -22,7 +22,7 @@ import static org.hamcrest.Matchers.is; public class GeneratedKeyConfigTests extends ESTestCase { public void testGenerating() throws Exception { - Settings settings = Settings.builder().put(Node.NODE_NAME_SETTING.getKey(), randomAsciiOfLengthBetween(1, 8)).build(); + Settings settings = Settings.builder().put(Node.NODE_NAME_SETTING.getKey(), randomAlphaOfLengthBetween(1, 8)).build(); GeneratedKeyConfig keyConfig = new GeneratedKeyConfig(settings); assertThat(keyConfig.filesToMonitor(null), is(empty())); X509ExtendedKeyManager keyManager = keyConfig.createKeyManager(null); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ssl/SSLConfigurationSettingsTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ssl/SSLConfigurationSettingsTests.java index ffbc33541dc..a5d3a42ea64 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ssl/SSLConfigurationSettingsTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ssl/SSLConfigurationSettingsTests.java @@ -47,7 +47,7 @@ public class SSLConfigurationSettingsTests extends ESTestCase { final SSLConfigurationSettings ssl = SSLConfigurationSettings.withPrefix("xpack.security.authc.realms.ldap1.ssl."); assertThat(ssl.keystoreAlgorithm.match("xpack.security.authc.realms.ldap1.ssl.keystore.algorithm"), is(true)); - final String algo = randomAsciiOfLength(16); + final String algo = randomAlphaOfLength(16); final Settings settings = Settings.builder() .put("xpack.security.authc.realms.ldap1.ssl.keystore.algorithm", algo) .build(); @@ -73,7 +73,7 @@ public class SSLConfigurationSettingsTests extends ESTestCase { assertThat(ssl.keystorePassword.match("xpack.ssl.keystore.key_password"), is(false)); assertThat(ssl.keystoreKeyPassword.match("xpack.ssl.keystore.password"), is(false)); - final String password = randomAsciiOfLength(16); + final String password = randomAlphaOfLength(16); final Settings settings = Settings.builder() .put("xpack.ssl.keystore.password", password) .build(); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ssl/SSLConfigurationTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ssl/SSLConfigurationTests.java index 7f6babcda43..2f72e865499 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ssl/SSLConfigurationTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ssl/SSLConfigurationTests.java @@ -128,11 +128,11 @@ public class SSLConfigurationTests extends ESTestCase { public void testThatSettingsWithDifferentKeystoresAreNotEqual() { SSLConfiguration sslConfiguration = new SSLConfiguration(Settings.builder() .put("keystore.path", "path") - .put("keystore.password", randomAsciiOfLength(5)) + .put("keystore.password", randomAlphaOfLength(5)) .build()); SSLConfiguration sslConfiguration1 = new SSLConfiguration(Settings.builder() .put("keystore.path", "path1") - .put("keystore.password", randomAsciiOfLength(5)) + .put("keystore.password", randomAlphaOfLength(5)) .build()); assertThat(sslConfiguration.equals(sslConfiguration1), is(equalTo(false))); assertThat(sslConfiguration1.equals(sslConfiguration), is(equalTo(false))); @@ -143,11 +143,11 @@ public class SSLConfigurationTests extends ESTestCase { public void testThatSettingsWithDifferentTruststoresAreNotEqual() { SSLConfiguration sslConfiguration = new SSLConfiguration(Settings.builder() .put("truststore.path", "/trust") - .put("truststore.password", randomAsciiOfLength(5)) + .put("truststore.password", randomAlphaOfLength(5)) .build()); SSLConfiguration sslConfiguration1 = new SSLConfiguration(Settings.builder() .put("truststore.path", "/truststore") - .put("truststore.password", randomAsciiOfLength(5)) + .put("truststore.password", randomAlphaOfLength(5)) .build()); assertThat(sslConfiguration.equals(sslConfiguration1), is(equalTo(false))); assertThat(sslConfiguration1.equals(sslConfiguration), is(equalTo(false))); @@ -167,11 +167,11 @@ public class SSLConfigurationTests extends ESTestCase { public void testThatSettingsWithDifferentKeystoresHaveDifferentHashCode() { SSLConfiguration sslConfiguration = new SSLConfiguration(Settings.builder() .put("keystore.path", "path") - .put("keystore.password", randomAsciiOfLength(5)) + .put("keystore.password", randomAlphaOfLength(5)) .build()); SSLConfiguration sslConfiguration1 = new SSLConfiguration(Settings.builder() .put("keystore.path", "path1") - .put("keystore.password", randomAsciiOfLength(5)) + .put("keystore.password", randomAlphaOfLength(5)) .build()); assertThat(sslConfiguration.hashCode(), is(not(equalTo(sslConfiguration1.hashCode())))); } @@ -179,11 +179,11 @@ public class SSLConfigurationTests extends ESTestCase { public void testThatSettingsWithDifferentTruststoresHaveDifferentHashCode() { SSLConfiguration sslConfiguration = new SSLConfiguration(Settings.builder() .put("truststore.path", "/trust") - .put("truststore.password", randomAsciiOfLength(5)) + .put("truststore.password", randomAlphaOfLength(5)) .build()); SSLConfiguration sslConfiguration1 = new SSLConfiguration(Settings.builder() .put("truststore.path", "/truststore") - .put("truststore.password", randomAsciiOfLength(5)) + .put("truststore.password", randomAlphaOfLength(5)) .build()); assertThat(sslConfiguration.hashCode(), is(not(equalTo(sslConfiguration1.hashCode())))); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/email/EmailActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/email/EmailActionTests.java index 664ab47d612..38be35f3aa4 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/email/EmailActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/email/EmailActionTests.java @@ -138,7 +138,7 @@ public class EmailActionTests extends ESTestCase { DateTime now = DateTime.now(DateTimeZone.UTC); - Wid wid = new Wid(randomAsciiOfLength(5), now); + Wid wid = new Wid(randomAlphaOfLength(5), now); WatchExecutionContext ctx = mockExecutionContextBuilder("watch1") .wid(wid) .payload(payload) @@ -291,7 +291,7 @@ public class EmailActionTests extends ESTestCase { ExecutableEmailAction executable = new EmailActionFactory(Settings.EMPTY, emailService, engine, emailAttachmentParser) - .parseExecutable(randomAsciiOfLength(8), randomAsciiOfLength(3), parser); + .parseExecutable(randomAlphaOfLength(8), randomAlphaOfLength(3), parser); assertThat(executable, notNullValue()); assertThat(executable.action().getAccount(), is("_account")); @@ -366,7 +366,7 @@ public class EmailActionTests extends ESTestCase { EmailTemplate email = emailTemplate.build(); Authentication auth = randomBoolean() ? null : new Authentication("_user", new Secret("_passwd".toCharArray())); Profile profile = randomFrom(Profile.values()); - String account = randomAsciiOfLength(6); + String account = randomAlphaOfLength(6); DataAttachment dataAttachment = randomDataAttachment(); EmailAttachments emailAttachments = randomEmailAttachments(); @@ -385,7 +385,7 @@ public class EmailActionTests extends ESTestCase { parser.nextToken(); ExecutableEmailAction parsed = new EmailActionFactory(Settings.EMPTY, service, engine, emailAttachmentParser) - .parseExecutable(randomAsciiOfLength(4), randomAsciiOfLength(10), parser); + .parseExecutable(randomAlphaOfLength(4), randomAlphaOfLength(10), parser); if (!hideSecrets) { assertThat(parsed, equalTo(executable)); @@ -415,7 +415,7 @@ public class EmailActionTests extends ESTestCase { parser.nextToken(); try { new EmailActionFactory(Settings.EMPTY, emailService, engine, emailAttachmentsParser) - .parseExecutable(randomAsciiOfLength(3), randomAsciiOfLength(7), parser); + .parseExecutable(randomAlphaOfLength(3), randomAlphaOfLength(7), parser); } catch (ElasticsearchParseException e) { assertThat(e.getMessage(), containsString("unexpected string field [unknown_field]")); } @@ -452,7 +452,7 @@ public class EmailActionTests extends ESTestCase { EmailActionFactory emailActionFactory = createEmailActionFactory(); ExecutableEmailAction executableEmailAction = - emailActionFactory.parseExecutable(randomAsciiOfLength(3), randomAsciiOfLength(7), parser); + emailActionFactory.parseExecutable(randomAlphaOfLength(3), randomAlphaOfLength(7), parser); Action.Result result = executableEmailAction.execute("test", createWatchExecutionContext(), new Payload.Simple()); assertThat(result, instanceOf(EmailAction.Result.Success.class)); @@ -470,7 +470,7 @@ public class EmailActionTests extends ESTestCase { } public void testThatDataAttachmentGetsAttachedWithId() throws Exception { - String attachmentId = randomAsciiOfLength(10) + ".yml"; + String attachmentId = randomAlphaOfLength(10) + ".yml"; XContentBuilder builder = jsonBuilder().startObject() .startObject("attachments") @@ -487,7 +487,7 @@ public class EmailActionTests extends ESTestCase { EmailActionFactory emailActionFactory = createEmailActionFactory(); ExecutableEmailAction executableEmailAction = - emailActionFactory.parseExecutable(randomAsciiOfLength(3), randomAsciiOfLength(7), parser); + emailActionFactory.parseExecutable(randomAlphaOfLength(3), randomAlphaOfLength(7), parser); Action.Result result = executableEmailAction.execute("test", createWatchExecutionContext(), new Payload.Simple()); assertThat(result, instanceOf(EmailAction.Result.Success.class)); @@ -540,10 +540,10 @@ public class EmailActionTests extends ESTestCase { parser.nextToken(); ExecutableEmailAction executableEmailAction = new EmailActionFactory(Settings.EMPTY, emailService, engine, - emailAttachmentsParser).parseExecutable(randomAsciiOfLength(3), randomAsciiOfLength(7), parser); + emailAttachmentsParser).parseExecutable(randomAlphaOfLength(3), randomAlphaOfLength(7), parser); DateTime now = DateTime.now(DateTimeZone.UTC); - Wid wid = new Wid(randomAsciiOfLength(5), now); + Wid wid = new Wid(randomAlphaOfLength(5), now); Map metadata = MapBuilder.newMapBuilder().put("_key", "_val").map(); WatchExecutionContext ctx = mockExecutionContextBuilder("watch1") .wid(wid) @@ -569,7 +569,7 @@ public class EmailActionTests extends ESTestCase { private WatchExecutionContext createWatchExecutionContext() { DateTime now = DateTime.now(DateTimeZone.UTC); - Wid wid = new Wid(randomAsciiOfLength(5), now); + Wid wid = new Wid(randomAlphaOfLength(5), now); Map metadata = MapBuilder.newMapBuilder().put("_key", "_val").map(); return mockExecutionContextBuilder("watch1") .wid(wid) @@ -595,10 +595,10 @@ public class EmailActionTests extends ESTestCase { when(httpClient.execute(any(HttpRequest.class))).thenReturn(mockResponse); HttpRequestTemplate template = HttpRequestTemplate.builder("localhost", 1234).build(); - attachments.add(new HttpRequestAttachment(randomAsciiOfLength(10), template, + attachments.add(new HttpRequestAttachment(randomAlphaOfLength(10), template, randomBoolean(), randomFrom("my/custom-type", null))); } else if ("data".equals(attachmentType)) { - attachments.add(new org.elasticsearch.xpack.notification.email.attachment.DataAttachment(randomAsciiOfLength(10), + attachments.add(new org.elasticsearch.xpack.notification.email.attachment.DataAttachment(randomAlphaOfLength(10), randomFrom(DataAttachment.JSON, DataAttachment.YAML))); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatActionTests.java index 253b071b88c..17a2a699991 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatActionTests.java @@ -74,7 +74,7 @@ public class HipChatActionTests extends ESTestCase { DateTime now = DateTime.now(DateTimeZone.UTC); - Wid wid = new Wid(randomAsciiOfLength(5), now); + Wid wid = new Wid(randomAlphaOfLength(5), now); WatchExecutionContext ctx = mockExecutionContextBuilder(wid.watchId()) .wid(wid) .payload(payload) @@ -123,7 +123,7 @@ public class HipChatActionTests extends ESTestCase { public void testParser() throws Exception { XContentBuilder builder = jsonBuilder().startObject(); - String accountName = randomAsciiOfLength(10); + String accountName = randomAlphaOfLength(10); builder.field("account", accountName); builder.startObject("message"); @@ -146,7 +146,7 @@ public class HipChatActionTests extends ESTestCase { } String from = null; if (randomBoolean()) { - from = randomAsciiOfLength(10); + from = randomAlphaOfLength(10); builder.field("from", from); } HipChatMessage.Format format = null; @@ -187,7 +187,7 @@ public class HipChatActionTests extends ESTestCase { } public void testParserSelfGenerated() throws Exception { - String accountName = randomAsciiOfLength(10); + String accountName = randomAlphaOfLength(10); TextTemplate body = new TextTemplate("_body"); HipChatMessage.Template.Builder templateBuilder = new HipChatMessage.Template.Builder(body); @@ -216,7 +216,7 @@ public class HipChatActionTests extends ESTestCase { builder.array("user", u1, u2); } if (randomBoolean()) { - String from = randomAsciiOfLength(10); + String from = randomAlphaOfLength(10); templateBuilder.setFrom(from); builder.field("from", from); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java index 91c2fb7d690..899d1d9d986 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java @@ -57,7 +57,7 @@ public class IndexActionTests extends ESIntegTestCase { public void testIndexActionExecuteSingleDoc() throws Exception { boolean customId = randomBoolean(); boolean docIdAsParam = customId && randomBoolean(); - String docId = randomAsciiOfLength(5); + String docId = randomAlphaOfLength(5); String timestampField = randomFrom("@timestamp", null); boolean customTimestampField = timestampField != null; @@ -209,7 +209,7 @@ public class IndexActionTests extends ESIntegTestCase { XContentParser parser = createParser(builder); parser.nextToken(); - ExecutableIndexAction executable = actionParser.parseExecutable(randomAsciiOfLength(5), randomAsciiOfLength(3), parser); + ExecutableIndexAction executable = actionParser.parseExecutable(randomAlphaOfLength(5), randomAlphaOfLength(3), parser); assertThat(executable.action().docType, equalTo("test-type")); assertThat(executable.action().index, equalTo("test-index")); @@ -240,7 +240,7 @@ public class IndexActionTests extends ESIntegTestCase { XContentParser parser = createParser(builder); parser.nextToken(); try { - actionParser.parseExecutable(randomAsciiOfLength(4), randomAsciiOfLength(5), parser); + actionParser.parseExecutable(randomAlphaOfLength(4), randomAlphaOfLength(5), parser); if (!(useIndex && useType)) { fail(); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/ExecutableJiraActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/ExecutableJiraActionTests.java index 902de1c3216..b812451cbfe 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/ExecutableJiraActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/ExecutableJiraActionTests.java @@ -59,8 +59,8 @@ public class ExecutableJiraActionTests extends ESTestCase { final String host = randomFrom("localhost", "internal-jira.elastic.co"); final int port = randomFrom(80, 8080, 449, 9443); final String url = "https://" + host + ":" + port; - final String user = randomAsciiOfLength(10); - final String password = randomAsciiOfLength(10); + final String user = randomAlphaOfLength(10); + final String password = randomAlphaOfLength(10); Settings accountSettings = Settings.builder() .put("url", url) @@ -75,7 +75,7 @@ public class ExecutableJiraActionTests extends ESTestCase { DateTime now = DateTime.now(DateTimeZone.UTC); - Wid wid = new Wid(randomAsciiOfLength(5), now); + Wid wid = new Wid(randomAlphaOfLength(5), now); WatchExecutionContext ctx = mockExecutionContextBuilder(wid.watchId()) .wid(wid) .payload(new Payload.Simple()) @@ -286,7 +286,7 @@ public class ExecutableJiraActionTests extends ESTestCase { private WatchExecutionContext createWatchExecutionContext() { DateTime now = DateTime.now(DateTimeZone.UTC); - Wid wid = new Wid(randomAsciiOfLength(5), now); + Wid wid = new Wid(randomAlphaOfLength(5), now); Map metadata = MapBuilder.newMapBuilder().put("_key", "_val").map(); return mockExecutionContextBuilder("watch1") .wid(wid) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/JiraActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/JiraActionTests.java index 6bc5a700690..fb72b153115 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/JiraActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/JiraActionTests.java @@ -55,7 +55,7 @@ import static org.mockito.Mockito.when; public class JiraActionTests extends ESTestCase { public void testParser() throws Exception { - final String accountName = randomAsciiOfLength(10); + final String accountName = randomAlphaOfLength(10); final Map issueDefaults = JiraAccountTests.randomIssueDefaults(); XContentBuilder builder = jsonBuilder().startObject() @@ -186,17 +186,17 @@ public class JiraActionTests extends ESTestCase { final Map model = new HashMap<>(); final MapBuilder actionFields = MapBuilder.newMapBuilder(); - String summary = randomAsciiOfLength(15); + String summary = randomAlphaOfLength(15); actionFields.put("summary", "{{ctx.summary}}"); model.put("{{ctx.summary}}", summary); - String projectId = randomAsciiOfLength(10); + String projectId = randomAlphaOfLength(10); actionFields.put("project", singletonMap("id", "{{ctx.project_id}}")); model.put("{{ctx.project_id}}", projectId); String description = null; if (randomBoolean()) { - description = randomAsciiOfLength(50); + description = randomAlphaOfLength(50); actionFields.put("description", description); } @@ -236,7 +236,7 @@ public class JiraActionTests extends ESTestCase { DateTime now = DateTime.now(DateTimeZone.UTC); - Wid wid = new Wid(randomAsciiOfLength(5), now); + Wid wid = new Wid(randomAlphaOfLength(5), now); WatchExecutionContext context = mockExecutionContextBuilder(wid.watchId()) .wid(wid) .payload(payload) @@ -267,7 +267,7 @@ public class JiraActionTests extends ESTestCase { private static JiraAction randomJiraAction() { String account = null; if (randomBoolean()) { - account = randomAsciiOfLength(randomIntBetween(5, 10)); + account = randomAlphaOfLength(randomIntBetween(5, 10)); } Map fields = emptyMap(); if (frequently()) { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/logging/LoggingActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/logging/LoggingActionTests.java index 4cf8f6ca350..85c3164dc8b 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/logging/LoggingActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/logging/LoggingActionTests.java @@ -74,7 +74,7 @@ public class LoggingActionTests extends ESTestCase { ctxModel.put("trigger", triggerModel); Map expectedModel = singletonMap("ctx", ctxModel); - String text = randomAsciiOfLength(10); + String text = randomAlphaOfLength(10); TextTemplate template = new TextTemplate(text); LoggingAction action = new LoggingAction(template, level, "_category"); ExecutableLoggingAction executable = new ExecutableLoggingAction(action, logger, actionLogger, engine); @@ -95,14 +95,14 @@ public class LoggingActionTests extends ESTestCase { Settings settings = Settings.EMPTY; LoggingActionFactory parser = new LoggingActionFactory(settings, engine); - String text = randomAsciiOfLength(10); + String text = randomAlphaOfLength(10); TextTemplate template = new TextTemplate(text); XContentBuilder builder = jsonBuilder().startObject(); builder.field("text", template); String category = null; if (randomBoolean()) { - category = randomAsciiOfLength(10); + category = randomAlphaOfLength(10); builder.field("category", category); } LoggingLevel level = null; @@ -115,7 +115,7 @@ public class LoggingActionTests extends ESTestCase { XContentParser xContentParser = createParser(builder); xContentParser.nextToken(); - ExecutableLoggingAction executable = parser.parseExecutable(randomAsciiOfLength(5), randomAsciiOfLength(3), xContentParser); + ExecutableLoggingAction executable = parser.parseExecutable(randomAlphaOfLength(5), randomAlphaOfLength(3), xContentParser); assertThat(executable, notNullValue()); assertThat(executable.action().category, is(category)); @@ -129,9 +129,9 @@ public class LoggingActionTests extends ESTestCase { Settings settings = Settings.EMPTY; LoggingActionFactory parser = new LoggingActionFactory(settings, engine); - String text = randomAsciiOfLength(10); + String text = randomAlphaOfLength(10); TextTemplate template = new TextTemplate(text); - String category = randomAsciiOfLength(10); + String category = randomAlphaOfLength(10); LoggingAction action = new LoggingAction(template, level, category); ExecutableLoggingAction executable = new ExecutableLoggingAction(action, logger, settings, engine); XContentBuilder builder = jsonBuilder(); @@ -140,7 +140,7 @@ public class LoggingActionTests extends ESTestCase { XContentParser xContentParser = createParser(builder); xContentParser.nextToken(); - ExecutableLoggingAction parsedAction = parser.parseExecutable(randomAsciiOfLength(5), randomAsciiOfLength(5), xContentParser); + ExecutableLoggingAction parsedAction = parser.parseExecutable(randomAlphaOfLength(5), randomAlphaOfLength(5), xContentParser); assertThat(parsedAction, equalTo(executable)); } @@ -149,11 +149,11 @@ public class LoggingActionTests extends ESTestCase { Settings settings = Settings.EMPTY; LoggingActionFactory parser = new LoggingActionFactory(settings, engine); - String text = randomAsciiOfLength(10); + String text = randomAlphaOfLength(10); TextTemplate template = new TextTemplate(text); LoggingAction.Builder actionBuilder = loggingAction(template); if (randomBoolean()) { - actionBuilder.setCategory(randomAsciiOfLength(10)); + actionBuilder.setCategory(randomAlphaOfLength(10)); } if (randomBoolean()) { actionBuilder.setLevel(randomFrom(LoggingLevel.values())); @@ -164,7 +164,7 @@ public class LoggingActionTests extends ESTestCase { XContentParser xContentParser = createParser(builder); assertThat(xContentParser.nextToken(), is(XContentParser.Token.START_OBJECT)); - ExecutableLoggingAction executable = parser.parseExecutable(randomAsciiOfLength(4), randomAsciiOfLength(5), xContentParser); + ExecutableLoggingAction executable = parser.parseExecutable(randomAlphaOfLength(4), randomAlphaOfLength(5), xContentParser); assertThat(executable, notNullValue()); assertThat(executable.action(), is(action)); assertThat(executable.action(), is(action)); @@ -182,7 +182,7 @@ public class LoggingActionTests extends ESTestCase { xContentParser.nextToken(); try { - parser.parseExecutable(randomAsciiOfLength(5), randomAsciiOfLength(5), xContentParser); + parser.parseExecutable(randomAlphaOfLength(5), randomAlphaOfLength(5), xContentParser); fail("Expected failure as there's no text"); } catch (ElasticsearchParseException e) { assertThat(e.getMessage(), containsString("missing required [text] field")); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionTests.java index 3dbc6be7ac9..a266686483d 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionTests.java @@ -79,7 +79,7 @@ public class PagerDutyActionTests extends ESTestCase { DateTime now = DateTime.now(DateTimeZone.UTC); - Wid wid = new Wid(randomAsciiOfLength(5), now); + Wid wid = new Wid(randomAlphaOfLength(5), now); WatchExecutionContext ctx = mockExecutionContextBuilder(wid.watchId()) .wid(wid) .payload(payload) @@ -126,7 +126,7 @@ public class PagerDutyActionTests extends ESTestCase { XContentBuilder builder = jsonBuilder().startObject(); - String accountName = randomAsciiOfLength(10); + String accountName = randomAlphaOfLength(10); builder.field("account", accountName); TextTemplate incidentKey = null; @@ -197,16 +197,16 @@ public class PagerDutyActionTests extends ESTestCase { } public void testParserSelfGenerated() throws Exception { - IncidentEvent.Template.Builder event = IncidentEvent.templateBuilder(randomAsciiOfLength(50)); + IncidentEvent.Template.Builder event = IncidentEvent.templateBuilder(randomAlphaOfLength(50)); if (randomBoolean()) { - event.setIncidentKey(new TextTemplate(randomAsciiOfLength(50))); + event.setIncidentKey(new TextTemplate(randomAlphaOfLength(50))); } if (randomBoolean()) { - event.setClient(new TextTemplate(randomAsciiOfLength(50))); + event.setClient(new TextTemplate(randomAlphaOfLength(50))); } if (randomBoolean()) { - event.setClientUrl(new TextTemplate(randomAsciiOfLength(50))); + event.setClientUrl(new TextTemplate(randomAlphaOfLength(50))); } if (randomBoolean()) { event.setAttachPayload(randomBoolean()); @@ -219,10 +219,10 @@ public class PagerDutyActionTests extends ESTestCase { new TextTemplate("_alt"))); } if (randomBoolean()) { - event.setEventType(new TextTemplate(randomAsciiOfLength(50))); + event.setEventType(new TextTemplate(randomAlphaOfLength(50))); } if (randomBoolean()) { - event.setAccount(randomAsciiOfLength(50)).build(); + event.setAccount(randomAlphaOfLength(50)).build(); } if (randomBoolean()) { event.setProxy(new HttpProxy("localhost", 8080)); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/ExecutableSlackActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/ExecutableSlackActionTests.java index 5be26a94e7b..6cddd4b99e3 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/ExecutableSlackActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/ExecutableSlackActionTests.java @@ -48,7 +48,7 @@ public class ExecutableSlackActionTests extends ESTestCase { DateTime now = DateTime.now(DateTimeZone.UTC); - Wid wid = new Wid(randomAsciiOfLength(5), now); + Wid wid = new Wid(randomAlphaOfLength(5), now); WatchExecutionContext ctx = mockExecutionContextBuilder(wid.watchId()) .wid(wid) .payload(new Payload.Simple()) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionTests.java index ffe641c69f4..17a2135a19e 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionTests.java @@ -76,7 +76,7 @@ public class SlackActionTests extends ESTestCase { DateTime now = DateTime.now(DateTimeZone.UTC); - Wid wid = new Wid(randomAsciiOfLength(5), now); + Wid wid = new Wid(randomAlphaOfLength(5), now); WatchExecutionContext ctx = mockExecutionContextBuilder(wid.watchId()) .wid(wid) .payload(payload) @@ -112,17 +112,17 @@ public class SlackActionTests extends ESTestCase { HttpRequest request = mock(HttpRequest.class); switch (randomIntBetween(0, 2)) { case 0: - messages.add(SentMessages.SentMessage.error(randomAsciiOfLength(10), message, "unknown error")); + messages.add(SentMessages.SentMessage.error(randomAlphaOfLength(10), message, "unknown error")); hasError = true; break; case 1: when(response.status()).thenReturn(randomIntBetween(300, 600)); // error reponse - messages.add(SentMessages.SentMessage.responded(randomAsciiOfLength(10), message, request, response)); + messages.add(SentMessages.SentMessage.responded(randomAlphaOfLength(10), message, request, response)); hasError = true; break; case 2: when(response.status()).thenReturn(randomIntBetween(200, 299)); // success - messages.add(SentMessages.SentMessage.responded(randomAsciiOfLength(10), message, request, response)); + messages.add(SentMessages.SentMessage.responded(randomAlphaOfLength(10), message, request, response)); hasSuccess = true; } } @@ -145,7 +145,7 @@ public class SlackActionTests extends ESTestCase { public void testParser() throws Exception { XContentBuilder builder = jsonBuilder().startObject(); - String accountName = randomAsciiOfLength(10); + String accountName = randomAlphaOfLength(10); SlackMessage.Template message = SlackMessageTests.createRandomTemplate(); builder.field("account", accountName); @@ -166,7 +166,7 @@ public class SlackActionTests extends ESTestCase { } public void testParserSelfGenerated() throws Exception { - String accountName = randomBoolean() ? randomAsciiOfLength(10) : null; + String accountName = randomBoolean() ? randomAlphaOfLength(10) : null; SlackMessage.Template message = SlackMessageTests.createRandomTemplate(); HttpProxy proxy = null; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionTests.java index 6ad7f9d160c..43a0ed3f33c 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionTests.java @@ -140,7 +140,7 @@ public class WebhookActionTests extends ESTestCase { XContentParser parser = createParser(builder); parser.nextToken(); - ExecutableWebhookAction executable = actionParser.parseExecutable(randomAsciiOfLength(5), randomAsciiOfLength(5), parser); + ExecutableWebhookAction executable = actionParser.parseExecutable(randomAlphaOfLength(5), randomAlphaOfLength(5), parser); assertThat(executable.action().getRequest(), equalTo(request)); } @@ -150,7 +150,7 @@ public class WebhookActionTests extends ESTestCase { TextTemplate path = new TextTemplate("_url"); String host = "test.host"; String watchId = "_watch"; - String actionId = randomAsciiOfLength(5); + String actionId = randomAlphaOfLength(5); HttpMethod method = randomFrom(HttpMethod.GET, HttpMethod.POST, HttpMethod.PUT, HttpMethod.DELETE, HttpMethod.HEAD, null); @@ -177,7 +177,7 @@ public class WebhookActionTests extends ESTestCase { String host = "test.host"; String watchId = "_watch"; - String actionId = randomAsciiOfLength(5); + String actionId = randomAlphaOfLength(5); HttpMethod method = randomFrom(HttpMethod.GET, HttpMethod.POST, HttpMethod.PUT, HttpMethod.DELETE, HttpMethod.HEAD, null); HttpRequestTemplate request = getHttpRequestTemplate(method, host, TEST_PORT, path, body, null); @@ -210,7 +210,7 @@ public class WebhookActionTests extends ESTestCase { WebhookActionFactory actionParser = webhookFactory(ExecuteScenario.Success.client()); //This should fail since we are not supplying a url try { - actionParser.parseExecutable("_watch", randomAsciiOfLength(5), parser); + actionParser.parseExecutable("_watch", randomAlphaOfLength(5), parser); fail("expected a WebhookActionException since we only provided either a host or a port but not both"); } catch (ElasticsearchParseException e) { assertThat(e.getMessage(), containsString("failed parsing http request template")); @@ -235,7 +235,7 @@ public class WebhookActionTests extends ESTestCase { WebhookAction action = new WebhookAction(builder.build()); ExecutableWebhookAction executable = new ExecutableWebhookAction(action, logger, httpClient, templateEngine); - String watchId = "test_url_encode" + randomAsciiOfLength(10); + String watchId = "test_url_encode" + randomAlphaOfLength(10); Watch watch = createWatch(watchId, "account1"); WatchExecutionContext ctx = new TriggeredExecutionContext(watch, new DateTime(UTC), new ScheduleTriggerEvent(watchId, new DateTime(UTC), new DateTime(UTC)), timeValueSeconds(5)); @@ -249,7 +249,7 @@ public class WebhookActionTests extends ESTestCase { HttpClient client = mock(HttpClient.class); when(client.execute(any(HttpRequest.class))) .thenReturn(new HttpResponse(randomIntBetween(200, 399))); - String watchId = "test_url_encode" + randomAsciiOfLength(10); + String watchId = "test_url_encode" + randomAlphaOfLength(10); HttpMethod method = HttpMethod.POST; TextTemplate path = new TextTemplate("/test_" + watchId); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInputTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInputTests.java index eca0cfea2e8..cbacadba8f8 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInputTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInputTests.java @@ -63,7 +63,7 @@ public class ExecutableChainInputTests extends ESTestCase { private WatchExecutionContext createWatchExecutionContext() { DateTime now = DateTime.now(DateTimeZone.UTC); - Wid wid = new Wid(randomAsciiOfLength(5), now); + Wid wid = new Wid(randomAlphaOfLength(5), now); return mockExecutionContextBuilder(wid.watchId()) .wid(wid) .payload(new Payload.Simple()) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputTests.java index 525fd77b56c..c2d1b663534 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputTests.java @@ -152,11 +152,11 @@ public class HttpInputTests extends ESTestCase { public void testParser() throws Exception { final HttpMethod httpMethod = rarely() ? null : randomFrom(HttpMethod.values()); Scheme scheme = randomFrom(Scheme.HTTP, Scheme.HTTPS, null); - String host = randomAsciiOfLength(3); + String host = randomAlphaOfLength(3); int port = randomIntBetween(8000, 9000); - String path = randomAsciiOfLength(3); + String path = randomAlphaOfLength(3); TextTemplate pathTemplate = new TextTemplate(path); - String body = randomBoolean() ? randomAsciiOfLength(3) : null; + String body = randomBoolean() ? randomAlphaOfLength(3) : null; Map params = randomBoolean() ? new MapBuilder().put("a", new TextTemplate("b")).map() : null; Map headers = @@ -235,8 +235,8 @@ public class HttpInputTests extends ESTestCase { } public void testThatHeadersAreIncludedInPayload() throws Exception { - String headerName = randomAsciiOfLength(10); - String headerValue = randomAsciiOfLength(10); + String headerName = randomAlphaOfLength(10); + String headerValue = randomAlphaOfLength(10); boolean responseHasContent = randomBoolean(); HttpRequestTemplate.Builder request = HttpRequestTemplate.builder("localhost", 8080); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchActionTests.java index fa36b2878fc..2cd48447cb1 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchActionTests.java @@ -32,7 +32,7 @@ public class RestExecuteWatchActionTests extends ESTestCase { private WatcherClient watcherClient = mock(WatcherClient.class); public void testThatFlagsCanBeSpecifiedViaParameters() throws Exception { - String randomId = randomAsciiOfLength(10); + String randomId = randomAlphaOfLength(10); for (String recordExecution : Arrays.asList("true", "false", null)) { for (String ignoreCondition : Arrays.asList("true", "false", null)) { for (String debugCondition : Arrays.asList("true", "false", null)) { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherUtilsTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherUtilsTests.java index b7ab542f5a0..07380b14351 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherUtilsTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherUtilsTests.java @@ -100,10 +100,10 @@ public class WatcherUtilsTests extends ESTestCase { if (randomBoolean()) { int maxParams = randomIntBetween(1, 10); for (int i = 0; i < maxParams; i++) { - params.put(randomAsciiOfLengthBetween(1, 5), randomAsciiOfLengthBetween(1, 5)); + params.put(randomAlphaOfLengthBetween(1, 5), randomAlphaOfLengthBetween(1, 5)); } } - String text = randomAsciiOfLengthBetween(1, 5); + String text = randomAlphaOfLengthBetween(1, 5); ScriptType scriptType = randomFrom(ScriptType.values()); expectedTemplate = new Script(scriptType, "mustache", text, params); request = new WatcherSearchTemplateRequest(expectedIndices, expectedTypes, expectedSearchType, @@ -198,10 +198,10 @@ public class WatcherUtilsTests extends ESTestCase { if (randomBoolean()) { int maxParams = randomIntBetween(1, 10); for (int i = 0; i < maxParams; i++) { - params.put(randomAsciiOfLengthBetween(1, 5), randomAsciiOfLengthBetween(1, 5)); + params.put(randomAlphaOfLengthBetween(1, 5), randomAlphaOfLengthBetween(1, 5)); } } - String text = randomAsciiOfLengthBetween(1, 5); + String text = randomAlphaOfLengthBetween(1, 5); ScriptType scriptType = randomFrom(ScriptType.values()); template = new Script(scriptType, "mustache", text, params); builder.field("template", template); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/action/put/PutWatchSerializationTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/action/put/PutWatchSerializationTests.java index 81609ab7910..f7449e45df3 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/action/put/PutWatchSerializationTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/action/put/PutWatchSerializationTests.java @@ -24,10 +24,10 @@ public class PutWatchSerializationTests extends ESTestCase { // https://github.com/elastic/x-plugins/issues/2490 public void testPutWatchSerialization() throws Exception { PutWatchRequest request = new PutWatchRequest(); - request.setId(randomAsciiOfLength(10)); + request.setId(randomAlphaOfLength(10)); request.setActive(randomBoolean()); request.setSource( - new BytesArray(JsonXContent.contentBuilder().startObject().field("foo", randomAsciiOfLength(20)).endObject().string()), + new BytesArray(JsonXContent.contentBuilder().startObject().field("foo", randomAlphaOfLength(20)).endObject().string()), XContentType.JSON); BytesStreamOutput streamOutput = new BytesStreamOutput(); @@ -43,10 +43,10 @@ public class PutWatchSerializationTests extends ESTestCase { public void testPutWatchSerializationXContent() throws Exception { PutWatchRequest request = new PutWatchRequest(); - request.setId(randomAsciiOfLength(10)); + request.setId(randomAlphaOfLength(10)); request.setActive(randomBoolean()); request.setSource( - new BytesArray(JsonXContent.contentBuilder().startObject().field("foo", randomAsciiOfLength(20)).endObject().string()), + new BytesArray(JsonXContent.contentBuilder().startObject().field("foo", randomAlphaOfLength(20)).endObject().string()), XContentType.JSON); assertEquals(XContentType.JSON, request.xContentType()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTestCase.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTestCase.java index 769481d3d6a..f823b212a82 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTestCase.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTestCase.java @@ -209,7 +209,7 @@ public abstract class ScheduleTestCase extends ESTestCase { protected static Object invalidDayOfMonth() { return randomBoolean() ? - randomAsciiOfLength(5) : + randomAlphaOfLength(5) : randomBoolean() ? randomIntBetween(-30, -1) : randomIntBetween(33, 45); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchTests.java index 4b35078fe80..96a5c3e2efd 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchTests.java @@ -465,7 +465,7 @@ public class WatchTests extends ESTestCase { if (randomBoolean()) { EmailAction action = new EmailAction(EmailTemplate.builder().build(), null, null, Profile.STANDARD, randomFrom(DataAttachment.JSON, DataAttachment.YAML), EmailAttachments.EMPTY_ATTACHMENTS); - list.add(new ActionWrapper("_email_" + randomAsciiOfLength(8), randomThrottler(), + list.add(new ActionWrapper("_email_" + randomAlphaOfLength(8), randomThrottler(), AlwaysConditionTests.randomCondition(scriptService), randomTransform(), new ExecutableEmailAction(action, logger, emailService, templateEngine, htmlSanitizer, Collections.emptyMap()))); } @@ -473,7 +473,7 @@ public class WatchTests extends ESTestCase { DateTimeZone timeZone = randomBoolean() ? DateTimeZone.UTC : null; TimeValue timeout = randomBoolean() ? timeValueSeconds(between(1, 10000)) : null; IndexAction action = new IndexAction("_index", "_type", randomBoolean() ? "123" : null, null, timeout, timeZone); - list.add(new ActionWrapper("_index_" + randomAsciiOfLength(8), randomThrottler(), + list.add(new ActionWrapper("_index_" + randomAlphaOfLength(8), randomThrottler(), AlwaysConditionTests.randomCondition(scriptService), randomTransform(), new ExecutableIndexAction(action, logger, client, null))); } @@ -483,7 +483,7 @@ public class WatchTests extends ESTestCase { .path(new TextTemplate("_url")) .build(); WebhookAction action = new WebhookAction(httpRequest); - list.add(new ActionWrapper("_webhook_" + randomAsciiOfLength(8), randomThrottler(), + list.add(new ActionWrapper("_webhook_" + randomAlphaOfLength(8), randomThrottler(), AlwaysConditionTests.randomCondition(scriptService), randomTransform(), new ExecutableWebhookAction(action, logger, httpClient, templateEngine))); } diff --git a/qa/security-example-extension/src/test/java/org/elasticsearch/example/realm/CustomRealmIT.java b/qa/security-example-extension/src/test/java/org/elasticsearch/example/realm/CustomRealmIT.java index 5dec4978636..2e81cc479c5 100644 --- a/qa/security-example-extension/src/test/java/org/elasticsearch/example/realm/CustomRealmIT.java +++ b/qa/security-example-extension/src/test/java/org/elasticsearch/example/realm/CustomRealmIT.java @@ -97,7 +97,7 @@ public class CustomRealmIT extends ESIntegTestCase { Settings settings = Settings.builder() .put("cluster.name", clusterName) .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toAbsolutePath().toString()) - .put(ThreadContext.PREFIX + "." + CustomRealm.USER_HEADER, CustomRealm.KNOWN_USER + randomAsciiOfLength(1)) + .put(ThreadContext.PREFIX + "." + CustomRealm.USER_HEADER, CustomRealm.KNOWN_USER + randomAlphaOfLength(1)) .put(ThreadContext.PREFIX + "." + CustomRealm.PW_HEADER, CustomRealm.KNOWN_PW) .build(); try (TransportClient client = new PreBuiltXPackTransportClient(settings)) {