You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2023/02/07 07:32:51 UTC
[camel-quarkus] 05/18: Telegram: Testing subscribing and unsubscribing to Webhook Fixes #3562
This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch 2.13.x
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 9d2adaadb8033620e8a448dd21a1219c8f18276b
Author: Zineb Bendhiba <be...@gmail.com>
AuthorDate: Thu Dec 1 09:25:06 2022 +0100
Telegram: Testing subscribing and unsubscribing to Webhook
Fixes #3562
---
.../ROOT/pages/reference/extensions/telegram.adoc | 19 +++++++++++++
.../telegram/runtime/src/main/doc/usage.adoc | 14 ++++++++++
integration-tests/telegram/pom.xml | 9 +++----
.../quarkus/component/telegram/it/Routes.java | 31 ++++++++++++++++++++++
.../mappings/telegramWebhook-register.json | 21 +++++++++++++++
.../mappings/telegramWebhook-unregister.json | 21 +++++++++++++++
6 files changed, 110 insertions(+), 5 deletions(-)
diff --git a/docs/modules/ROOT/pages/reference/extensions/telegram.adoc b/docs/modules/ROOT/pages/reference/extensions/telegram.adoc
index ecb36dad6e..e5cfef4607 100644
--- a/docs/modules/ROOT/pages/reference/extensions/telegram.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/telegram.adoc
@@ -45,6 +45,25 @@ ifeval::[{doc-show-user-guide-link} == true]
Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
endif::[]
+[id="extensions-telegram-usage"]
+== Usage
+[id="extensions-telegram-usage-webhook-mode"]
+== Webhook Mode
+
+The Telegram extension supports usage in the webhook mode.
+
+In order to enable webhook mode, users need first to add a REST implementation to their application.
+Maven users, for example, can add *camel-quarkus-rest* extension to their `pom.xml` file:
+
+[source,xml]
+----
+<dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-rest</artifactId>
+</dependency>
+----
+
+
[id="extensions-telegram-ssl-in-native-mode"]
== SSL in native mode
diff --git a/extensions/telegram/runtime/src/main/doc/usage.adoc b/extensions/telegram/runtime/src/main/doc/usage.adoc
new file mode 100644
index 0000000000..e3960854be
--- /dev/null
+++ b/extensions/telegram/runtime/src/main/doc/usage.adoc
@@ -0,0 +1,14 @@
+== Webhook Mode
+
+The Telegram extension supports usage in the webhook mode.
+
+In order to enable webhook mode, users need first to add a REST implementation to their application.
+Maven users, for example, can add *camel-quarkus-rest* extension to their `pom.xml` file:
+
+[source,xml]
+----
+<dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-rest</artifactId>
+</dependency>
+----
\ No newline at end of file
diff --git a/integration-tests/telegram/pom.xml b/integration-tests/telegram/pom.xml
index 539c95eea1..99b9af6295 100644
--- a/integration-tests/telegram/pom.xml
+++ b/integration-tests/telegram/pom.xml
@@ -43,12 +43,12 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
-
- <!-- To serve the mock Telegram API -->
+ <!-- Wehbook usage -->
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-platform-http</artifactId>
+ <artifactId>camel-quarkus-rest</artifactId>
</dependency>
+ <!-- To serve the mock Telegram API -->
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-attachments</artifactId>
@@ -88,7 +88,6 @@
</dependency>
</dependencies>
-
<profiles>
<profile>
<id>native</id>
@@ -141,7 +140,7 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-platform-http-deployment</artifactId>
+ <artifactId>camel-quarkus-rest-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
diff --git a/integration-tests/telegram/src/main/java/org/apache/camel/quarkus/component/telegram/it/Routes.java b/integration-tests/telegram/src/main/java/org/apache/camel/quarkus/component/telegram/it/Routes.java
new file mode 100644
index 0000000000..d7ee2b93f8
--- /dev/null
+++ b/integration-tests/telegram/src/main/java/org/apache/camel/quarkus/component/telegram/it/Routes.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.telegram.it;
+
+import javax.enterprise.context.ApplicationScoped;
+
+import org.apache.camel.builder.RouteBuilder;
+
+@ApplicationScoped
+public class Routes extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("webhook:telegram:bots?webhookPath=/my-test&webhook-external-url=http://localhost:8080")
+ .log("webhook message : ${body}");
+ }
+}
diff --git a/integration-tests/telegram/src/test/resources/mappings/telegramWebhook-register.json b/integration-tests/telegram/src/test/resources/mappings/telegramWebhook-register.json
new file mode 100644
index 0000000000..9152c9ff70
--- /dev/null
+++ b/integration-tests/telegram/src/test/resources/mappings/telegramWebhook-register.json
@@ -0,0 +1,21 @@
+{
+ "id" : "70c0a770-2a98-4f46-ba01-8ba3a71d8e3d",
+ "name": "botfake-webhook",
+ "request": {
+ "url": "/botfake-token/setWebhook?url=http://localhost:8080/my-test",
+ "method": "GET"
+ },
+ "response": {
+ "status": 200,
+ "body": "{\"ok\":true,\"result\":true,\"description\":\"Webhook was set\"}",
+ "headers": {
+ "Server": "nginx/1.16.1",
+ "Date": "Tue, 03 Nov 2020 12:26:06 GMT",
+ "Content-Type": "application/json",
+ "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload"
+ }
+ },
+ "uuid": "f47c81d1-def8-4246-b14f-2a0555829f7d",
+ "persistent": true,
+ "insertionIndex": 8
+}
\ No newline at end of file
diff --git a/integration-tests/telegram/src/test/resources/mappings/telegramWebhook-unregister.json b/integration-tests/telegram/src/test/resources/mappings/telegramWebhook-unregister.json
new file mode 100644
index 0000000000..f4e592e7f7
--- /dev/null
+++ b/integration-tests/telegram/src/test/resources/mappings/telegramWebhook-unregister.json
@@ -0,0 +1,21 @@
+{
+ "id" : "70c0a770-2a98-4f46-ba01-8ba3a71d8e3d",
+ "name": "botfake-delete-webhook",
+ "request": {
+ "url": "/botfake-token/deleteWebhook",
+ "method": "GET"
+ },
+ "response": {
+ "status": 200,
+ "body": "{\"ok\":true,\"result\":true,\"description\":\"Webhook was set\"}",
+ "headers": {
+ "Server": "nginx/1.16.1",
+ "Date": "Tue, 03 Nov 2020 12:26:06 GMT",
+ "Content-Type": "application/json",
+ "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload"
+ }
+ },
+ "uuid": "f47c81d1-def8-4246-b14f-2a0555829f7d",
+ "persistent": true,
+ "insertionIndex": 8
+}
\ No newline at end of file