Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new isEqualTo with auth for secured endpoints. #35

Merged
merged 2 commits into from
Mar 6, 2018
Merged
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
26 changes: 26 additions & 0 deletions src/main/java/io/github/robwin/swagger/test/SwaggerAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
package io.github.robwin.swagger.test;

import io.swagger.models.Swagger;
import io.swagger.models.auth.AuthorizationValue;
import io.swagger.parser.SwaggerParser;
import org.assertj.core.api.AbstractAssert;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Properties;


Expand Down Expand Up @@ -85,6 +87,18 @@ public SwaggerAssert isEqualTo(String expectedLocation) {
return isEqualTo(new SwaggerParser().read(expectedLocation));
}

/**
* Verifies that the actual value is equal to the given one.
*
* @param expectedLocation the location of the given value to compare the actual value to.
* @param auths List of io.swagger.models.auth.AuthorizationValue for access to protected locations.
* @return {@code this} assertion object.
* @throws AssertionError if the actual value is not equal to the given one or if the actual value is {@code null}..
*/
public SwaggerAssert isEqualTo(String expectedLocation, List<AuthorizationValue> auths) {
return isEqualTo(new SwaggerParser().read(expectedLocation, auths, true));
}

/**
* Verifies that the actual value is equal to the given one.
*
Expand All @@ -109,6 +123,18 @@ public SwaggerAssert satisfiesContract(String expectedLocation) {
return satisfiesContract(new SwaggerParser().read(expectedLocation));
}

/**
* Verifies that the actual value is equal to the given one.
*
* @param expectedLocation the location of the given value to compare the actual value to.
* @param auths List of io.swagger.models.auth.AuthorizationValue for access to protected locations.
* @return {@code this} assertion object.
* @throws AssertionError if the actual value is not equal to the given one or if the actual value is {@code null}..
*/
public SwaggerAssert satisfiesContract(String expectedLocation, List<AuthorizationValue> auths) {
return satisfiesContract(new SwaggerParser().read(expectedLocation, auths, true));
}

private SwaggerAssertionConfig loadSwaggerAssertionFlagsConfiguration(String configurationResourceLocation) {
final Properties props = new Properties();
try (final InputStream is = this.getClass().getResourceAsStream(configurationResourceLocation)) {
Expand Down