Merge branch 'release' into feature/acl-spring-object
# Conflicts: # appsmith-server/src/main/java/com/appsmith/server/constants/FieldName.java
This commit is contained in:
commit
893698f09e
|
|
@ -26,6 +26,7 @@ public class FieldName {
|
|||
public static String PAGE = "page";
|
||||
public static String SIZE = "size";
|
||||
public static String ROLE = "role";
|
||||
public static String DEFAULT_WIDGET_NAME = "MainContainer";
|
||||
public static String DEFAULT_PAGE_LAYOUT = "{\n" +
|
||||
" \"widgetName\": \"MainContainer\",\n" +
|
||||
" \"backgroundColor\": \"none\",\n" +
|
||||
|
|
|
|||
|
|
@ -193,7 +193,9 @@ public class CurlImporterService extends BaseApiImporter {
|
|||
} else if (token.startsWith("-d")) {
|
||||
// `-dstuff` -> `--data stuff`
|
||||
normalizedTokens.add(ARG_DATA);
|
||||
normalizedTokens.add(token.substring(2));
|
||||
if (token.length() > 2) {
|
||||
normalizedTokens.add(token.substring(2));
|
||||
}
|
||||
|
||||
} else if ("-H".equals(token)) {
|
||||
normalizedTokens.add(ARG_HEADER);
|
||||
|
|
@ -201,7 +203,9 @@ public class CurlImporterService extends BaseApiImporter {
|
|||
} else if (token.startsWith("-H")) {
|
||||
// `-HContent-Type:application/json` -> `--header Content-Type:application/json`
|
||||
normalizedTokens.add(ARG_HEADER);
|
||||
normalizedTokens.add(token.substring(2));
|
||||
if (token.length() > 2) {
|
||||
normalizedTokens.add(token.substring(2));
|
||||
}
|
||||
|
||||
} else if ("-X".equals(token)) {
|
||||
normalizedTokens.add(ARG_REQUEST);
|
||||
|
|
@ -209,7 +213,9 @@ public class CurlImporterService extends BaseApiImporter {
|
|||
} else if (token.startsWith("-X")) {
|
||||
// `-XGET` -> `--request GET`
|
||||
normalizedTokens.add(ARG_REQUEST);
|
||||
normalizedTokens.add(token.substring(2).toUpperCase());
|
||||
if (token.length() > 2) {
|
||||
normalizedTokens.add(token.substring(2).toUpperCase());
|
||||
}
|
||||
|
||||
} else if ("-b".equals(token)) {
|
||||
normalizedTokens.add(ARG_COOKIE);
|
||||
|
|
@ -220,7 +226,9 @@ public class CurlImporterService extends BaseApiImporter {
|
|||
} else if ("-A".equals(token)) {
|
||||
normalizedTokens.add(ARG_USER_AGENT);
|
||||
|
||||
} else {
|
||||
} else if (!"--url".equals(token)) {
|
||||
// We skip the `--url` argument since it's superfluous and URLs are directly sniffed out of the argument
|
||||
// list. The `--url` argument holds no special significance in cURL.
|
||||
normalizedTokens.add(token);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import reactor.core.scheduler.Scheduler;
|
|||
|
||||
import javax.validation.Validator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
|
|
@ -83,6 +84,7 @@ public class PageServiceImpl extends BaseService<PageRepository, Page, String> i
|
|||
layout.setId(id);
|
||||
try {
|
||||
layout.setDsl((JSONObject) new JSONParser(JSONParser.MODE_PERMISSIVE).parse(FieldName.DEFAULT_PAGE_LAYOUT));
|
||||
layout.setWidgetNames(Set.of(FieldName.DEFAULT_WIDGET_NAME));
|
||||
} catch (ParseException e) {
|
||||
log.error("Unable to set the default page layout for id: {}", id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -547,6 +547,26 @@ public class CurlImporterServiceTest {
|
|||
assertEmptyBody(action);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseWithDashedUrlArgument() {
|
||||
Action action = curlImporterService.curlToAction("curl --url http://api.sloths.com");
|
||||
assertMethod(action, HttpMethod.GET);
|
||||
assertUrl(action, "http://api.sloths.com");
|
||||
assertEmptyPath(action);
|
||||
assertEmptyHeaders(action);
|
||||
assertEmptyBody(action);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseWithDashedUrlArgument2() {
|
||||
Action action = curlImporterService.curlToAction("curl -X POST -d '{\"name\":\"test\",\"salary\":\"123\",\"age\":\"23\"}' --url http://dummy.restapiexample.com/api/v1/create");
|
||||
assertMethod(action, HttpMethod.POST);
|
||||
assertUrl(action, "http://dummy.restapiexample.com");
|
||||
assertPath(action, "/api/v1/create");
|
||||
assertHeaders(action, new Property("Content-Type", "application/x-www-form-urlencoded"));
|
||||
assertBody(action, "{\"name\":\"test\",\"salary\":\"123\",\"age\":\"23\"}");
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithUserDetails(value = "api_user")
|
||||
public void importInvalidCurlCommand() {
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ public class PageServiceTest {
|
|||
|
||||
assertThat(page.getLayouts()).isNotEmpty();
|
||||
assertThat(page.getLayouts().get(0).getDsl()).isEqualTo(parsedJson);
|
||||
assertThat(page.getLayouts().get(0).getWidgetNames()).isNotEmpty();
|
||||
})
|
||||
.verifyComplete();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user