|
16 | 16 |
|
17 | 17 | package io.opentelemetry.contrib.generator.telemetry;
|
18 | 18 |
|
| 19 | +import io.opentelemetry.contrib.generator.core.exception.GeneratorException; |
19 | 20 | import io.opentelemetry.contrib.generator.telemetry.cli.CLIProcessor;
|
| 21 | +import org.apache.commons.cli.MissingOptionException; |
20 | 22 | import org.apache.commons.cli.ParseException;
|
21 | 23 | import org.testng.annotations.Test;
|
22 | 24 |
|
@@ -50,4 +52,104 @@ public void testMetricsTracesBasicAuthGRPC() throws ParseException {
|
50 | 52 | CLIProcessor.main(cliArgs);
|
51 | 53 | }
|
52 | 54 |
|
| 55 | + @Test(expectedExceptions = MissingOptionException.class) |
| 56 | + public void testWithoutEntityDefinition() throws ParseException { |
| 57 | + String noAuthTargetYAML = Paths.get(cliResourcesPath, "target-noauth.yaml").toString(); |
| 58 | + String[] cliArgs = new String[] { METRICS_YAML, "-l", LOGS_YAML, "-s", TRACES_YAML, "-t", noAuthTargetYAML }; |
| 59 | + CLIProcessor.main(cliArgs); |
| 60 | + } |
| 61 | + |
| 62 | + @Test(expectedExceptions = GeneratorException.class) |
| 63 | + public void testWithOnlyEntityDefinition() throws ParseException { |
| 64 | + String noAuthTargetYAML = Paths.get(cliResourcesPath, "target-noauth.yaml").toString(); |
| 65 | + String[] cliArgs = new String[] { "-e", ENTITIES_YAML, "-t", noAuthTargetYAML }; |
| 66 | + CLIProcessor.main(cliArgs); |
| 67 | + } |
| 68 | + |
| 69 | + @Test(expectedExceptions = MissingOptionException.class) |
| 70 | + public void testWithoutTargetAuthYAML() throws ParseException { |
| 71 | + String[] cliArgs = new String[] { "-e", ENTITIES_YAML, METRICS_YAML, "-l", LOGS_YAML, "-s", TRACES_YAML }; |
| 72 | + CLIProcessor.main(cliArgs); |
| 73 | + } |
| 74 | + |
| 75 | + @Test(expectedExceptions = GeneratorException.class) |
| 76 | + public void testWithoutAuthMode() throws ParseException { |
| 77 | + String noAuthModeYAML = Paths.get(cliResourcesPath, "negative", "no-auth-mode.yaml").toString(); |
| 78 | + String[] cliArgs = new String[] { |
| 79 | + "-e", ENTITIES_YAML, "-m", METRICS_YAML, "-l", LOGS_YAML, "-s", TRACES_YAML, "-t", noAuthModeYAML |
| 80 | + }; |
| 81 | + CLIProcessor.main(cliArgs); |
| 82 | + } |
| 83 | + |
| 84 | + @Test(expectedExceptions = GeneratorException.class) |
| 85 | + public void testWithInvalidAuthMode() throws ParseException { |
| 86 | + String invalidAuthModeYAML = Paths.get(cliResourcesPath, "negative", "invalid-auth-mode.yaml").toString(); |
| 87 | + String[] cliArgs = new String[] { |
| 88 | + "-e", ENTITIES_YAML, "-m", METRICS_YAML, "-l", LOGS_YAML, "-s", TRACES_YAML, "-t", invalidAuthModeYAML |
| 89 | + }; |
| 90 | + CLIProcessor.main(cliArgs); |
| 91 | + } |
| 92 | + |
| 93 | + @Test(expectedExceptions = GeneratorException.class) |
| 94 | + public void testWithoutEndpoint() throws ParseException { |
| 95 | + String noEndpointYAML = Paths.get(cliResourcesPath, "negative", "without-endpoint.yaml").toString(); |
| 96 | + String[] cliArgs = new String[] { |
| 97 | + "-e", ENTITIES_YAML, "-m", METRICS_YAML, "-l", LOGS_YAML, "-s", TRACES_YAML, "-t", noEndpointYAML |
| 98 | + }; |
| 99 | + CLIProcessor.main(cliArgs); |
| 100 | + } |
| 101 | + |
| 102 | + @Test(expectedExceptions = GeneratorException.class) |
| 103 | + public void testWithOnlyGRPCHost() throws ParseException { |
| 104 | + String onlyGRPCHostYAML = Paths.get(cliResourcesPath, "negative", "only-grpc-host.yaml").toString(); |
| 105 | + String[] cliArgs = new String[] { |
| 106 | + "-e", ENTITIES_YAML, "-m", METRICS_YAML, "-l", LOGS_YAML, "-s", TRACES_YAML, "-t", onlyGRPCHostYAML |
| 107 | + }; |
| 108 | + CLIProcessor.main(cliArgs); |
| 109 | + } |
| 110 | + |
| 111 | + @Test(expectedExceptions = GeneratorException.class) |
| 112 | + public void testWithOnlyGRPCPort() throws ParseException { |
| 113 | + String onlyGRPCPortYAML = Paths.get(cliResourcesPath, "negative", "only-grpc-port.yaml").toString(); |
| 114 | + String[] cliArgs = new String[] { |
| 115 | + "-e", ENTITIES_YAML, "-m", METRICS_YAML, "-l", LOGS_YAML, "-s", TRACES_YAML, "-t", onlyGRPCPortYAML |
| 116 | + }; |
| 117 | + CLIProcessor.main(cliArgs); |
| 118 | + } |
| 119 | + |
| 120 | + @Test |
| 121 | + public void testWithAuthModeNoneAndBasicCredentials() throws ParseException { |
| 122 | + String noneAuthModeYAML = Paths.get(cliResourcesPath, "negative", "none-auth-mode.yaml").toString(); |
| 123 | + String[] cliArgs = new String[] { |
| 124 | + "-e", ENTITIES_YAML, "-m", METRICS_YAML, "-l", LOGS_YAML, "-s", TRACES_YAML, "-t", noneAuthModeYAML |
| 125 | + }; |
| 126 | + CLIProcessor.main(cliArgs); |
| 127 | + } |
| 128 | + |
| 129 | + @Test(expectedExceptions = GeneratorException.class) |
| 130 | + public void testWithAuthModeBasicAndNoUsername() throws ParseException { |
| 131 | + String noUsernameYAML = Paths.get(cliResourcesPath, "negative", "no-username.yaml").toString(); |
| 132 | + String[] cliArgs = new String[] { |
| 133 | + "-e", ENTITIES_YAML, "-m", METRICS_YAML, "-l", LOGS_YAML, "-s", TRACES_YAML, "-t", noUsernameYAML |
| 134 | + }; |
| 135 | + CLIProcessor.main(cliArgs); |
| 136 | + } |
| 137 | + |
| 138 | + @Test(expectedExceptions = GeneratorException.class) |
| 139 | + public void testWithAuthModeBasicAndNoPassword() throws ParseException { |
| 140 | + String noPasswordYAML = Paths.get(cliResourcesPath, "negative", "no-password.yaml").toString(); |
| 141 | + String[] cliArgs = new String[] { |
| 142 | + "-e", ENTITIES_YAML, "-m", METRICS_YAML, "-l", LOGS_YAML, "-s", TRACES_YAML, "-t", noPasswordYAML |
| 143 | + }; |
| 144 | + CLIProcessor.main(cliArgs); |
| 145 | + } |
| 146 | + |
| 147 | + @Test(expectedExceptions = GeneratorException.class) |
| 148 | + public void testWithAuthModeBasicAndNoCredentials() throws ParseException { |
| 149 | + String noCredsYAML = Paths.get(cliResourcesPath, "negative", "no-credentials.yaml").toString(); |
| 150 | + String[] cliArgs = new String[] { |
| 151 | + "-e", ENTITIES_YAML, "-m", METRICS_YAML, "-l", LOGS_YAML, "-s", TRACES_YAML, "-t", noCredsYAML |
| 152 | + }; |
| 153 | + CLIProcessor.main(cliArgs); |
| 154 | + } |
53 | 155 | }
|
0 commit comments