-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from devatherock/integration-tests
test: Finished writing integration tests
- Loading branch information
Showing
9 changed files
with
87 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: '3.7' | ||
services: | ||
|
||
ldap-search-api: | ||
image: devatherock/ldap-search-api:latest | ||
network_mode: "host" | ||
environment: | ||
LDAP_HOST: ldaps://ldap.jumpcloud.com:636 | ||
LDAP_USERNAME: $JUMPCLOUD_USERNAME | ||
LDAP_PASSWORD: $JUMPCLOUD_PASSWORD | ||
LDAP_BASE_DN: $JUMPCLOUD_BASE_DN |
10 changes: 10 additions & 0 deletions
10
...Test/groovy/io.github.devatherock/ldapsearch.controllers/RemoteUrlsIntegrationSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.github.devatherock.ldapsearch.controllers | ||
|
||
import io.micronaut.test.extensions.spock.annotation.MicronautTest | ||
|
||
/** | ||
* Integration test that calls remote endpoints | ||
*/ | ||
@MicronautTest(propertySources = 'classpath:application-integration.yml', startApplication = false) | ||
class RemoteUrlsIntegrationSpec extends RemoteUrlsSpec { | ||
} |
40 changes: 40 additions & 0 deletions
40
src/test/groovy/io/github/devatherock/ldapsearch/controllers/RemoteUrlsSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.github.devatherock.ldapsearch.controllers | ||
|
||
import javax.inject.Inject | ||
|
||
import groovy.json.JsonSlurper | ||
|
||
import io.micronaut.http.HttpRequest | ||
import io.micronaut.http.client.HttpClient | ||
import io.micronaut.http.client.annotation.Client | ||
import io.micronaut.http.uri.UriBuilder | ||
import spock.lang.Specification | ||
|
||
/** | ||
* Test that calls remote endpoints. Needed for proper netty SSL reflection config | ||
*/ | ||
abstract class RemoteUrlsSpec extends Specification { | ||
|
||
@Inject | ||
@Client('${test.server.url}') | ||
HttpClient httpClient | ||
|
||
JsonSlurper slurper = new JsonSlurper() | ||
|
||
void 'test search - get specific user'() { | ||
when: | ||
String response = httpClient.toBlocking().retrieve( | ||
HttpRequest.GET(UriBuilder.of('/search') | ||
.queryParam('filter', 'uid=test').build()) | ||
) | ||
|
||
then: | ||
def json = slurper.parseText(response) | ||
json.size() == 1 | ||
json[0]['givenName'] == 'Test' | ||
json[0]['sn'] == 'User' | ||
json[0]['objectClass'].containsAll(['top', 'person', 'organizationalPerson', 'inetOrgPerson']) | ||
json[0]['uid'] == 'test' | ||
json[0]['cn'] == 'Test User' | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/test/groovy/io/github/devatherock/ldapsearch/controllers/RemoteUrlsTestSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.github.devatherock.ldapsearch.controllers | ||
|
||
import io.micronaut.test.extensions.spock.annotation.MicronautTest | ||
|
||
/** | ||
* Unit test that calls remote endpoints | ||
*/ | ||
@MicronautTest(propertySources = ['classpath:application-test.yml', 'classpath:application-remote.yml']) | ||
class RemoteUrlsTestSpec extends RemoteUrlsSpec { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ldap: | ||
host: ldaps://ldap.jumpcloud.com:636 | ||
username: ${JUMPCLOUD_USERNAME} | ||
password: ${JUMPCLOUD_PASSWORD} | ||
base-dn: ${JUMPCLOUD_BASE_DN} |