|
9 | 9 | import org.elasticsearch.common.settings.Settings; |
10 | 10 | import org.elasticsearch.common.util.iterable.Iterables; |
11 | 11 | import org.elasticsearch.license.License.OperationMode; |
12 | | -import org.elasticsearch.license.XPackLicenseState.Feature; |
13 | 12 | import org.elasticsearch.test.ESTestCase; |
14 | 13 | import org.elasticsearch.xpack.core.XPackField; |
15 | 14 | import org.elasticsearch.xpack.core.XPackSettings; |
@@ -88,122 +87,6 @@ public static OperationMode randomBasicStandardOrGold() { |
88 | 87 | return randomFrom(BASIC, STANDARD, GOLD); |
89 | 88 | } |
90 | 89 |
|
91 | | - public void testSecurityDefaults() { |
92 | | - Settings settings = Settings.builder().put(XPackSettings.SECURITY_ENABLED.getKey(), true).build(); |
93 | | - XPackLicenseState licenseState = new XPackLicenseState(settings, () -> 0); |
94 | | - assertThat(licenseState.isSecurityEnabled(), is(true)); |
95 | | - assertThat(licenseState.checkFeature(Feature.SECURITY_AUDITING), is(true)); |
96 | | - |
97 | | - licenseState = TestUtils.newTestLicenseState(); |
98 | | - assertSecurityNotAllowed(licenseState); |
99 | | - } |
100 | | - |
101 | | - public void testTransportSslDoesNotAutomaticallyEnableSecurityOnTrialLicense() { |
102 | | - Settings settings = Settings.builder().put(XPackSettings.TRANSPORT_SSL_ENABLED.getKey(), true).build(); |
103 | | - final XPackLicenseState licenseState= new XPackLicenseState(settings, () -> 0); |
104 | | - assertSecurityNotAllowed(licenseState); |
105 | | - } |
106 | | - |
107 | | - public void testSecurityBasicWithoutExplicitSecurityEnabled() { |
108 | | - XPackLicenseState licenseState = TestUtils.newTestLicenseState(); |
109 | | - licenseState.update(BASIC, true, null); |
110 | | - |
111 | | - assertThat(licenseState.isSecurityEnabled(), is(false)); |
112 | | - assertThat(licenseState.checkFeature(Feature.SECURITY_AUDITING), is(false)); |
113 | | - assertThat(licenseState.checkFeature(Feature.SECURITY_TOKEN_SERVICE), is(false)); |
114 | | - |
115 | | - assertThat(licenseState.isSecurityEnabled(), is(false)); |
116 | | - } |
117 | | - |
118 | | - public void testSecurityBasicWithExplicitSecurityEnabled() { |
119 | | - final Settings settings = Settings.builder().put(XPackSettings.SECURITY_ENABLED.getKey(), true).build(); |
120 | | - XPackLicenseState licenseState = new XPackLicenseState(settings, () -> 0); |
121 | | - licenseState.update(BASIC, true, null); |
122 | | - assertThat(licenseState.isSecurityEnabled(), is(true)); |
123 | | - assertThat(licenseState.checkFeature(Feature.SECURITY_AUDITING), is(false)); |
124 | | - assertThat(licenseState.checkFeature(Feature.SECURITY_TOKEN_SERVICE), is(false)); |
125 | | - |
126 | | - assertThat(licenseState.isSecurityEnabled(), is(true)); |
127 | | - } |
128 | | - |
129 | | - public void testSecurityStandard() { |
130 | | - Settings settings = randomFrom(Settings.EMPTY, |
131 | | - Settings.builder().put(XPackSettings.SECURITY_ENABLED.getKey(), true).build()); |
132 | | - XPackLicenseState licenseState = new XPackLicenseState(settings, () -> 0); |
133 | | - licenseState.update(STANDARD, true, null); |
134 | | - |
135 | | - assertThat(licenseState.isSecurityEnabled(), is(true)); |
136 | | - assertThat(licenseState.checkFeature(Feature.SECURITY_AUDITING), is(false)); |
137 | | - assertThat(licenseState.checkFeature(Feature.SECURITY_TOKEN_SERVICE), is(true)); |
138 | | - } |
139 | | - |
140 | | - public void testSecurityStandardExpired() { |
141 | | - Settings settings = randomFrom(Settings.EMPTY, |
142 | | - Settings.builder().put(XPackSettings.SECURITY_ENABLED.getKey(), true).build()); |
143 | | - XPackLicenseState licenseState = new XPackLicenseState(settings, () -> 0); |
144 | | - licenseState.update(STANDARD, false, null); |
145 | | - |
146 | | - assertThat(licenseState.isSecurityEnabled(), is(true)); |
147 | | - assertThat(licenseState.checkFeature(Feature.SECURITY_AUDITING), is(false)); |
148 | | - assertThat(licenseState.checkFeature(Feature.SECURITY_TOKEN_SERVICE), is(true)); |
149 | | - } |
150 | | - |
151 | | - public void testSecurityGold() { |
152 | | - Settings settings = randomFrom(Settings.EMPTY, |
153 | | - Settings.builder().put(XPackSettings.SECURITY_ENABLED.getKey(), true).build()); |
154 | | - XPackLicenseState licenseState = new XPackLicenseState(settings, () -> 0); |
155 | | - licenseState.update(GOLD, true, null); |
156 | | - |
157 | | - assertThat(licenseState.isSecurityEnabled(), is(true)); |
158 | | - assertThat(licenseState.checkFeature(Feature.SECURITY_AUDITING), is(true)); |
159 | | - assertThat(licenseState.checkFeature(Feature.SECURITY_TOKEN_SERVICE), is(true)); |
160 | | - } |
161 | | - |
162 | | - public void testSecurityGoldExpired() { |
163 | | - Settings settings = randomFrom(Settings.EMPTY, |
164 | | - Settings.builder().put(XPackSettings.SECURITY_ENABLED.getKey(), true).build()); |
165 | | - XPackLicenseState licenseState = new XPackLicenseState(settings, () -> 0); |
166 | | - licenseState.update(GOLD, false, null); |
167 | | - |
168 | | - assertThat(licenseState.isSecurityEnabled(), is(true)); |
169 | | - assertThat(licenseState.checkFeature(Feature.SECURITY_AUDITING), is(true)); |
170 | | - assertThat(licenseState.checkFeature(Feature.SECURITY_TOKEN_SERVICE), is(true)); |
171 | | - } |
172 | | - |
173 | | - public void testSecurityPlatinum() { |
174 | | - Settings settings = randomFrom(Settings.EMPTY, |
175 | | - Settings.builder().put(XPackSettings.SECURITY_ENABLED.getKey(), true).build()); |
176 | | - XPackLicenseState licenseState = new XPackLicenseState(settings, () -> 0); |
177 | | - licenseState.update(PLATINUM, true, null); |
178 | | - |
179 | | - assertThat(licenseState.isSecurityEnabled(), is(true)); |
180 | | - assertThat(licenseState.checkFeature(Feature.SECURITY_AUDITING), is(true)); |
181 | | - assertThat(licenseState.checkFeature(Feature.SECURITY_TOKEN_SERVICE), is(true)); |
182 | | - } |
183 | | - |
184 | | - public void testSecurityPlatinumExpired() { |
185 | | - Settings settings = randomFrom(Settings.EMPTY, |
186 | | - Settings.builder().put(XPackSettings.SECURITY_ENABLED.getKey(), true).build()); |
187 | | - XPackLicenseState licenseState = new XPackLicenseState(settings, () -> 0); |
188 | | - licenseState.update(PLATINUM, false, null); |
189 | | - |
190 | | - assertThat(licenseState.isSecurityEnabled(), is(true)); |
191 | | - assertThat(licenseState.checkFeature(Feature.SECURITY_AUDITING), is(true)); |
192 | | - assertThat(licenseState.checkFeature(Feature.SECURITY_TOKEN_SERVICE), is(true)); |
193 | | - } |
194 | | - |
195 | | - public void testNewTrialDefaultsSecurityOff() { |
196 | | - XPackLicenseState licenseState = TestUtils.newTestLicenseState(); |
197 | | - licenseState.update(TRIAL, true, null); |
198 | | - |
199 | | - assertThat(licenseState.isSecurityEnabled(), is(false)); |
200 | | - assertSecurityNotAllowed(licenseState); |
201 | | - } |
202 | | - |
203 | | - private void assertSecurityNotAllowed(XPackLicenseState licenseState) { |
204 | | - assertThat(licenseState.isSecurityEnabled(), is(false)); |
205 | | - } |
206 | | - |
207 | 90 | public void testSecurityAckBasicToNotGoldOrStandard() { |
208 | 91 | OperationMode toMode = randomFrom(OperationMode.values(), mode -> mode != GOLD && mode != STANDARD); |
209 | 92 | assertAckMessages(XPackField.SECURITY, BASIC, toMode, 0); |
|
0 commit comments