Skip to content

INTEG-2619: [Zendesk][Input] Remove the support for basic authentication #90

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.4.7 - 2025-03-18
* [enhancement] Remove the support for basic authentication

## 0.4.6 - 2024-10-24
* [enhancement] Update the API endpoint pattern for Chat endpoint [#88](https://github.com./treasure-data/embulk-input-zendesk/pull/88)

Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ Required Embulk version >= 0.9.6.
## Configuration

- **login_url**: Login URL for Zendesk (string, required)
- **auth_method**: `basic`, `token`, or `oauth`. For more detail on [zendesk document](https://developer.zendesk.com/rest_api/docs/core/introduction#security-and-authentication). (string, required)
- **auth_method**: `token`, or `oauth`. For more detail on [zendesk document](https://developer.zendesk.com/rest_api/docs/core/introduction#security-and-authentication). (string, required)
- **target**: Which export Zendesk resource. Currently supported are `tickets`, `ticket_events`, `users`, `organizations`, `ticket_fields`, `ticket_forms`, `ticket_metrics`, `scores`, `recipients`, `object_records`, `relationship_records` or `user_events`. (string, required)
- **includes**: Will fetch sub resources. For example, ticket has ticket_audits, ticket_comments. See below example config. (array, default: `[]`)
- **username**: The user name a.k.a. email. Required if `auth_method` is `basic` or `token`. (string, default: `null`)
- **password**: Password. required if `auth_method` is `basic`. (string, default: `null`)
- **username**: The user name a.k.a. email. Required if `auth_method` is `token`. (string, default: `null`)
- **token**: Token. required if `auth_method` is `token`. (string, default: `null`)
- **access_token**: OAuth Access Token. required if `auth_method` is `oauth`. (string, default: `null`)
- **start_time**: Start export from this time if present. (string, default: `null`)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repositories {
def embulkVersion = '0.10.31'

group = "com.treasuredata.embulk.plugins"
version = "0.4.6-SNAPSHOT"
version = "0.4.7"
description = "Loads records From Zendesk"

sourceCompatibility = 1.8
Expand Down
12 changes: 1 addition & 11 deletions src/main/java/org/embulk/input/zendesk/ZendeskInputPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public interface PluginTask
String getLoginUrl();

@Config("auth_method")
@ConfigDefault("\"basic\"")
@ConfigDefault("\"token\"")
AuthenticationMethod getAuthenticationMethod();

@Config("target")
Expand All @@ -80,10 +80,6 @@ public interface PluginTask
@ConfigDefault("null")
Optional<String> getUsername();

@Config("password")
@ConfigDefault("null")
Optional<String> getPassword();

@Config("token")
@ConfigDefault("null")
Optional<String> getToken();
Expand Down Expand Up @@ -511,12 +507,6 @@ private void validateCredentials(PluginTask task)
task.getAuthenticationMethod().name().toLowerCase()));
}
break;
case BASIC:
if (!task.getUsername().isPresent() || !task.getPassword().isPresent()) {
throw new ConfigException(String.format("username and password are required for authentication method '%s'",
task.getAuthenticationMethod().name().toLowerCase()));
}
break;
default:
throw new ConfigException("Unknown authentication method");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,6 @@ private ImmutableMap<String, String> buildAuthHeader(final PluginTask task)
private String buildCredential(final PluginTask task)
{
switch (task.getAuthenticationMethod()) {
case BASIC:
return "Basic " + ZendeskUtils.convertBase64(String.format("%s:%s", task.getUsername().get(), task.getPassword().get()));
case TOKEN:
return "Basic " + ZendeskUtils.convertBase64(String.format("%s/token:%s", task.getUsername().get(), task.getToken().get()));
case OAUTH:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public enum AuthenticationMethod
{
BASIC, OAUTH, TOKEN;
OAUTH, TOKEN;

@JsonCreator
public static AuthenticationMethod fromString(final String value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,19 +274,6 @@ public void validateCredentialOauthShouldThrowException()
assertValidation(configSource, "access_token is required for authentication method 'oauth'");
}

@Test
public void validateCredentialBasicShouldThrowException()
{
ConfigSource configSource = ZendeskTestHelper.getConfigSource("base_validator.yml");
configSource.set("auth_method", "basic");
configSource.remove("username");
assertValidation(configSource, "username and password are required for authentication method 'basic'");

configSource.set("username", "");
configSource.remove("password");
assertValidation(configSource, "username and password are required for authentication method 'basic'");
}

@Test
public void validateCredentialTokenShouldThrowException()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,24 +254,6 @@ public void authenticationOauthSuccess() throws IOException
setupAndVerifyAuthenticationString(expectedValue, pluginTask);
}

@Test
public void authenticationBasicSuccess() throws IOException
{
setup("doGet200");

String username = "zendesk_username";
String password = "zendesk_password";

ConfigSource configSource = ZendeskTestHelper.getConfigSource("incremental.yml");
configSource.set("auth_method", "basic");
configSource.set("username", Optional.of(username));
configSource.set("password", password);
PluginTask pluginTask = CONFIG_MAPPER.map(configSource, PluginTask.class);

String expectedValue = "Basic " + ZendeskUtils.convertBase64(String.format("%s:%s", username, password));
setupAndVerifyAuthenticationString(expectedValue, pluginTask);
}

@Test
public void authenticationTokenSuccess() throws IOException
{
Expand Down
5 changes: 2 additions & 3 deletions src/test/resources/config/chat.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
type: zendesk
login_url: https://www.chat.zendesk.com
auth_method: basic
username: username
password: password
auth_method: oauth
access_token: dummy
target: chat
app_marketplace_integration_name: abc
app_marketplace_app_id: abc
Expand Down
Loading