Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watcher: Ensure secret tests also run triggered watch #30478

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
*/
package org.elasticsearch.xpack.core.watcher.support.xcontent;

import org.apache.lucene.util.BytesRef;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.xcontent.DeprecationHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class HttpSecretsIntegrationTests extends AbstractWatcherIntegrationTestC

private MockWebServer webServer = new MockWebServer();
private static Boolean encryptSensitiveData = null;
private static byte[] encryptionKey = CryptoServiceTests.generateKey();
private static final byte[] encryptionKey = CryptoServiceTests.generateKey();

@Before
public void init() throws Exception {
Expand Down Expand Up @@ -155,6 +155,14 @@ public void testHttpInput() throws Exception {
assertThat(webServer.requests(), hasSize(1));
assertThat(webServer.requests().get(0).getHeader("Authorization"),
is(ApplicableBasicAuth.headerValue(USERNAME, PASSWORD.toCharArray())));

// now trigger the by the scheduler and make sure that the password is also correctly transmitted
webServer.enqueue(new MockResponse().setResponseCode(200).setBody(
BytesReference.bytes(jsonBuilder().startObject().field("key", "value").endObject()).utf8ToString()));
timeWarp().trigger("_id");
assertThat(webServer.requests(), hasSize(2));
assertThat(webServer.requests().get(1).getHeader("Authorization"),
is(ApplicableBasicAuth.headerValue(USERNAME, PASSWORD.toCharArray())));
}

public void testWebhookAction() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public ScheduleTriggerEvent parseTriggerEvent(TriggerService service, String wat

@Override
public void start(Collection<Watch> jobs) {
jobs.forEach(this::add);
}

@Override
Expand Down