Skip to content

Commit 2d884d7

Browse files
WilliamBergaminClaude
andauthored
feat: add user_connections to the app manifest features model (#1662)
* feat: add user_connections to the app manifest features model Adds AppManifest.UserConnections (isEnabled, authHosts) on Features so apps.manifest.create, update and export keep the standardized app authentication settings instead of dropping them. The export json-logs sample and SampleObjects carry the field so generated response types pick it up. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com> * feat: add user_connections to the app manifest request params apps.manifest.create, update and validate take AppManifestParams, not AppManifest, so the feature could be read from an export but not sent. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com> --------- Co-authored-by: Claude <svc-devxp-claude@slack-corp.com>
1 parent e8352d1 commit 2d884d7

5 files changed

Lines changed: 79 additions & 1 deletion

File tree

‎json-logs/samples/api/apps.manifest.export.json‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,13 @@
6868
],
6969
"unfurl_domains": [
7070
""
71-
]
71+
],
72+
"user_connections": {
73+
"is_enabled": false,
74+
"auth_hosts": [
75+
""
76+
]
77+
}
7278
},
7379
"oauth_config": {
7480
"scopes": {

‎slack-api-client/src/test/java/util/sample_json_generation/SampleObjects.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,9 @@ public static File initFileObject() {
466466
.shortcuts(Arrays.asList(initProperties(AppManifest.Shortcut.builder().build())))
467467
.slashCommands(Arrays.asList(initProperties(AppManifest.SlashCommand.builder().build())))
468468
.unfurlDomains(Arrays.asList(""))
469+
.userConnections(initProperties(AppManifest.UserConnections.builder()
470+
.authHosts(Arrays.asList(""))
471+
.build()))
469472
.build()))
470473
.settings(initProperties(AppManifest.Settings.builder()
471474
.allowedIpAddressRanges(Arrays.asList(""))

‎slack-api-model/src/main/java/com/slack/api/model/manifest/AppManifest.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public static class Features {
9191
private List<Shortcut> shortcuts;
9292
private List<SlashCommand> slashCommands;
9393
private List<String> unfurlDomains;
94+
private UserConnections userConnections;
9495
}
9596

9697
@Data
@@ -112,6 +113,15 @@ public static class BotUser {
112113
private Boolean alwaysOnline;
113114
}
114115

116+
@Data
117+
@Builder
118+
@NoArgsConstructor
119+
@AllArgsConstructor
120+
public static class UserConnections {
121+
private Boolean isEnabled;
122+
private List<String> authHosts;
123+
}
124+
115125
@Data
116126
@Builder
117127
@NoArgsConstructor

‎slack-api-model/src/main/java/com/slack/api/model/manifest/AppManifestParams.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public static class Features {
8787
private List<Shortcut> shortcuts;
8888
private List<SlashCommand> slashCommands;
8989
private List<String> unfurlDomains;
90+
private UserConnections userConnections;
9091
}
9192

9293
@Data
@@ -108,6 +109,15 @@ public static class BotUser {
108109
private Boolean alwaysOnline;
109110
}
110111

112+
@Data
113+
@Builder
114+
@NoArgsConstructor
115+
@AllArgsConstructor
116+
public static class UserConnections {
117+
private Boolean isEnabled;
118+
private List<String> authHosts;
119+
}
120+
111121
@Data
112122
@Builder
113123
@NoArgsConstructor

‎slack-api-model/src/test/java/test_locally/api/model/AppManifestTest.java‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
package test_locally.api.model;
22

3+
import com.google.gson.Gson;
34
import com.slack.api.model.manifest.AppManifest;
5+
import com.slack.api.model.manifest.AppManifestParams;
46
import org.junit.Test;
57
import test_locally.unit.GsonFactory;
68

9+
import java.util.Arrays;
10+
11+
import static org.hamcrest.CoreMatchers.containsString;
712
import static org.hamcrest.CoreMatchers.is;
813
import static org.hamcrest.CoreMatchers.notNullValue;
914
import static org.hamcrest.MatcherAssert.assertThat;
@@ -103,4 +108,48 @@ public void parser() {
103108
.fromJson(json, AppManifest.class);
104109
assertThat(appManifest.getSettings(), is(notNullValue()));
105110
}
111+
112+
@Test
113+
public void userConnections() {
114+
String json = "{\n" +
115+
" \"display_information\": {\n" +
116+
" \"name\": \"connector\"\n" +
117+
" },\n" +
118+
" \"features\": {\n" +
119+
" \"user_connections\": {\n" +
120+
" \"is_enabled\": true,\n" +
121+
" \"auth_hosts\": [\n" +
122+
" \"example.com\",\n" +
123+
" \"auth.example.com\"\n" +
124+
" ]\n" +
125+
" }\n" +
126+
" }\n" +
127+
"}";
128+
129+
Gson gson = GsonFactory.createSnakeCase(true, true);
130+
AppManifest appManifest = gson.fromJson(json, AppManifest.class);
131+
AppManifest.UserConnections userConnections = appManifest.getFeatures().getUserConnections();
132+
assertThat(userConnections.getIsEnabled(), is(true));
133+
assertThat(userConnections.getAuthHosts(), is(Arrays.asList("example.com", "auth.example.com")));
134+
135+
String serialized = gson.toJson(appManifest);
136+
assertThat(serialized, containsString(
137+
"\"user_connections\":{\"is_enabled\":true,\"auth_hosts\":[\"example.com\",\"auth.example.com\"]}"));
138+
}
139+
140+
@Test
141+
public void userConnectionsParams() {
142+
AppManifestParams params = AppManifestParams.builder()
143+
.features(AppManifestParams.Features.builder()
144+
.userConnections(AppManifestParams.UserConnections.builder()
145+
.isEnabled(false)
146+
.authHosts(Arrays.asList("example.com"))
147+
.build())
148+
.build())
149+
.build();
150+
151+
String serialized = GsonFactory.createSnakeCase(true, true).toJson(params);
152+
assertThat(serialized, containsString(
153+
"\"user_connections\":{\"is_enabled\":false,\"auth_hosts\":[\"example.com\"]}"));
154+
}
106155
}

0 commit comments

Comments
 (0)