diff --git a/core/src/main/resources/schema.yml b/core/src/main/resources/schema.yml index 5f21842..1767582 100644 --- a/core/src/main/resources/schema.yml +++ b/core/src/main/resources/schema.yml @@ -2111,8 +2111,12 @@ components: type: object properties: searchTerm: + minLength: 3 + maxLength: 100 + description: must not be null, and must be at least three characters long to avoid an exception type: string includeAll: + description: must not be null type: boolean GraphQLSetProjectLocationRequest: type: object diff --git a/core/src/test/groovy/org/justserve/GraphQLClientSpec.groovy b/core/src/test/groovy/org/justserve/GraphQLClientSpec.groovy index 1706118..3cc02c5 100644 --- a/core/src/test/groovy/org/justserve/GraphQLClientSpec.groovy +++ b/core/src/test/groovy/org/justserve/GraphQLClientSpec.groovy @@ -367,4 +367,23 @@ class GraphQLClientSpec extends Specification { noExceptionThrown() !response.hasErrors() } + + def "test searchOrganization parses the input correctly"(String searchTerm, Boolean includesAll) { + given: + + GraphQLSearchOrganizationVariables inputData = new GraphQLSearchOrganizationVariables() + .setSearchTerm(searchTerm) + .setIncludeAll(includesAll) + + when: + GraphQLResponse response = client.searchOrganization(inputData) + + then: + noExceptionThrown() + !response.hasErrors() + + where: + [includesAll, searchTerm] << [[true, false], ["the"]].combinations() + + } } diff --git a/core/src/test/groovy/org/justserve/JustServeSpec.groovy b/core/src/test/groovy/org/justserve/JustServeSpec.groovy index 8617b69..834f337 100644 --- a/core/src/test/groovy/org/justserve/JustServeSpec.groovy +++ b/core/src/test/groovy/org/justserve/JustServeSpec.groovy @@ -71,15 +71,14 @@ class JustServeSpec extends Specification { // } ctx = ApplicationContext.builder() .environments(Environment.CLI, Environment.TEST) - .properties([ - "justserve.token": System.getenv("TEST_TOKEN") - ]) + .properties(["justserve.token": System.getenv("TEST_TOKEN")]) .build() .start() noAuthCtx = ApplicationContext .builder() .environments(Environment.CLI, Environment.TEST) .environmentVariableExcludes("JUSTSERVE_TOKEN") + .properties(["justserve.token": ""]) .build() .start() noAuthUserClient = noAuthCtx.getBean(UserClient) @@ -107,14 +106,13 @@ class JustServeSpec extends Specification { HttpResponse createUser(UserClient client = noAuthUserClient) { HttpResponse response = null def tries = 0 - while ((null == response || HttpStatus.OK != response.status()) && tries < 5) { + while ((null == response || ![HttpStatus.OK, HttpStatus.CREATED].contains(response.status())) && tries < 5) { try { // A new user is generated on each loop iteration to avoid collisions response = createUserFromFaker(client, new TestUser(new Faker(Locale.of("en-us")))) } catch (HttpClientResponseException ignored) { - tries++ - // This user likely already exists, so we'll loop and try a new one. } + tries++ } if (null == response) { throw new IllegalStateException("failed to create a test user after five attempts") @@ -161,7 +159,7 @@ class JustServeSpec extends Specification { .setContactPhone(faker.phoneNumber().phoneNumber()) .setDescription(faker.zelda().game()) .setLocationString(knownWorkingLocation) - .setLogo(getUploadedImageFileName()) + .setLogo(null) .setName(faker.zelda().character()) .set_public(null) .setUrl(getUniqueSlug()) @@ -196,9 +194,7 @@ class JustServeSpec extends Specification { * @return The file name of the uploaded image. */ String getUploadedImageFileName() { - HttpResponse profileImage = authImageClient.uploadImage( - new ImageUploadRequest(faker.image().base64JPG().split(",")[1], 256, 256, false, 0, 0) - ) + HttpResponse profileImage = authImageClient.uploadImage(new ImageUploadRequest(faker.image().base64JPG().split(",")[1], 256, 256, false, 0, 0)) return profileImage.body().displayFileName } @@ -209,7 +205,7 @@ class JustServeSpec extends Specification { String getUniqueSlug() { String urlSlug = null while (null == urlSlug) { - def potentialSlug = faker.word().noun() + def potentialSlug = faker.word().noun() + System.currentTimeMillis() def response = authDynamicRoutingClient.getOrgIdFromSlug(potentialSlug) if (response.status() == HttpStatus.NOT_FOUND) { urlSlug = potentialSlug