Skip to content
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
8 changes: 7 additions & 1 deletion json-logs/samples/api/apps.manifest.export.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@
],
"unfurl_domains": [
""
]
],
"user_connections": {
"is_enabled": false,
"auth_hosts": [
""
]
}
},
"oauth_config": {
"scopes": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,9 @@ public static File initFileObject() {
.shortcuts(Arrays.asList(initProperties(AppManifest.Shortcut.builder().build())))
.slashCommands(Arrays.asList(initProperties(AppManifest.SlashCommand.builder().build())))
.unfurlDomains(Arrays.asList(""))
.userConnections(initProperties(AppManifest.UserConnections.builder()
.authHosts(Arrays.asList(""))
.build()))
.build()))
.settings(initProperties(AppManifest.Settings.builder()
.allowedIpAddressRanges(Arrays.asList(""))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public static class Features {
private List<Shortcut> shortcuts;
private List<SlashCommand> slashCommands;
private List<String> unfurlDomains;
private UserConnections userConnections;
}

@Data
Expand All @@ -112,6 +113,15 @@ public static class BotUser {
private Boolean alwaysOnline;
}

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class UserConnections {
private Boolean isEnabled;
private List<String> authHosts;
}

@Data
@Builder
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public static class Features {
private List<Shortcut> shortcuts;
private List<SlashCommand> slashCommands;
private List<String> unfurlDomains;
private UserConnections userConnections;
}

@Data
Expand All @@ -108,6 +109,15 @@ public static class BotUser {
private Boolean alwaysOnline;
}

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class UserConnections {
private Boolean isEnabled;
private List<String> authHosts;
}

@Data
@Builder
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package test_locally.api.model;

import com.google.gson.Gson;
import com.slack.api.model.manifest.AppManifest;
import com.slack.api.model.manifest.AppManifestParams;
import org.junit.Test;
import test_locally.unit.GsonFactory;

import java.util.Arrays;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
Expand Down Expand Up @@ -103,4 +108,48 @@ public void parser() {
.fromJson(json, AppManifest.class);
assertThat(appManifest.getSettings(), is(notNullValue()));
}

@Test
public void userConnections() {
String json = "{\n" +
" \"display_information\": {\n" +
" \"name\": \"connector\"\n" +
" },\n" +
" \"features\": {\n" +
" \"user_connections\": {\n" +
" \"is_enabled\": true,\n" +
" \"auth_hosts\": [\n" +
" \"example.com\",\n" +
" \"auth.example.com\"\n" +
" ]\n" +
" }\n" +
" }\n" +
"}";

Gson gson = GsonFactory.createSnakeCase(true, true);
AppManifest appManifest = gson.fromJson(json, AppManifest.class);
AppManifest.UserConnections userConnections = appManifest.getFeatures().getUserConnections();
assertThat(userConnections.getIsEnabled(), is(true));
assertThat(userConnections.getAuthHosts(), is(Arrays.asList("example.com", "auth.example.com")));

String serialized = gson.toJson(appManifest);
assertThat(serialized, containsString(
"\"user_connections\":{\"is_enabled\":true,\"auth_hosts\":[\"example.com\",\"auth.example.com\"]}"));
}

@Test
public void userConnectionsParams() {
AppManifestParams params = AppManifestParams.builder()
.features(AppManifestParams.Features.builder()
.userConnections(AppManifestParams.UserConnections.builder()
.isEnabled(false)
.authHosts(Arrays.asList("example.com"))
.build())
.build())
.build();

String serialized = GsonFactory.createSnakeCase(true, true).toJson(params);
assertThat(serialized, containsString(
"\"user_connections\":{\"is_enabled\":false,\"auth_hosts\":[\"example.com\"]}"));
}
}
Loading