-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a new "http" sub-command to the certutil CLI tool. The http command generates certificates/CSRs for use on the http interface of an elasticsearch node/cluster. It is designed to be a guided tool that provides explanations and sugestions for each of the configuration options. The generated zip file output includes extensive "readme" documentation and sample configuration files for core Elastic products.
- Loading branch information
Showing
19 changed files
with
2,477 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
x-pack/plugin/core/src/test/java/org/elasticsearch/test/FileMatchers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.test; | ||
|
||
import org.hamcrest.CustomMatcher; | ||
import org.hamcrest.Description; | ||
import org.hamcrest.Matcher; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.LinkOption; | ||
import java.nio.file.Path; | ||
|
||
public class FileMatchers { | ||
public static Matcher<Path> pathExists(LinkOption... options) { | ||
return new CustomMatcher<>("Path exists") { | ||
@Override | ||
public boolean matches(Object item) { | ||
if (item instanceof Path) { | ||
Path path = (Path) item; | ||
return Files.exists(path, options); | ||
} else { | ||
return false; | ||
} | ||
|
||
} | ||
}; | ||
} | ||
|
||
public static Matcher<Path> isDirectory(LinkOption... options) { | ||
return new FileTypeMatcher("directory", options) { | ||
@Override | ||
protected boolean matchPath(Path path) { | ||
return Files.isDirectory(path, options); | ||
} | ||
}; | ||
} | ||
|
||
public static Matcher<Path> isRegularFile(LinkOption... options) { | ||
return new FileTypeMatcher("regular file", options) { | ||
@Override | ||
protected boolean matchPath(Path path) { | ||
return Files.isRegularFile(path, options); | ||
} | ||
}; | ||
} | ||
|
||
private abstract static class FileTypeMatcher extends CustomMatcher<Path> { | ||
private final LinkOption[] options; | ||
|
||
FileTypeMatcher(String typeName, LinkOption... options) { | ||
super("Path is " + typeName); | ||
this.options = options; | ||
} | ||
|
||
@Override | ||
public boolean matches(Object item) { | ||
if (item instanceof Path) { | ||
Path path = (Path) item; | ||
return matchPath(path); | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
protected abstract boolean matchPath(Path path); | ||
|
||
@Override | ||
public void describeMismatch(Object item, Description description) { | ||
super.describeMismatch(item, description); | ||
if (item instanceof Path) { | ||
Path path = (Path) item; | ||
if (Files.exists(path, options) == false) { | ||
description.appendText(" (file not found)"); | ||
} else if (Files.isDirectory(path, options)) { | ||
description.appendText(" (directory)"); | ||
} else if (Files.isSymbolicLink(path)) { | ||
description.appendText(" (symlink)"); | ||
} else if (Files.isRegularFile(path, options)) { | ||
description.appendText(" (regular file)"); | ||
} else { | ||
description.appendText(" (unknown file type)"); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.