Search in sources :

Example 6 with OAuth2Definition

use of io.swagger.models.auth.OAuth2Definition in project swagger-core by swagger-api.

the class AuthSerializationTest method testPasswordWithScopes.

@Test(description = "it should convert serialize an oauth2 password flow model with scopes")
public void testPasswordWithScopes() throws IOException {
    final OAuth2Definition auth = new OAuth2Definition().password("http://foo.com/token").scope("email", "read your email");
    final String json = "{\n" + "   \"type\":\"oauth2\",\n" + "   \"tokenUrl\":\"http://foo.com/token\",\n" + "   \"flow\":\"password\",\n" + "   \"scopes\":{\n" + "      \"email\":\"read your email\"\n" + "   }\n" + "}";
    SerializationMatchers.assertEqualsToJson(auth, json);
}
Also used : OAuth2Definition(io.swagger.models.auth.OAuth2Definition) Test(org.testng.annotations.Test)

Example 7 with OAuth2Definition

use of io.swagger.models.auth.OAuth2Definition in project swagger-core by swagger-api.

the class AuthSerializationTest method testApplicationWithScopes.

@Test(description = "it should convert serialize an oauth2 application flow model with scopes")
public void testApplicationWithScopes() throws IOException {
    final OAuth2Definition auth = new OAuth2Definition().application("http://foo.com/token").scope("email", "read your email");
    final String json = "{\n" + "   \"type\":\"oauth2\",\n" + "   \"tokenUrl\":\"http://foo.com/token\",\n" + "   \"flow\":\"application\",\n" + "   \"scopes\":{\n" + "      \"email\":\"read your email\"\n" + "   }\n" + "}";
    SerializationMatchers.assertEqualsToJson(auth, json);
}
Also used : OAuth2Definition(io.swagger.models.auth.OAuth2Definition) Test(org.testng.annotations.Test)

Example 8 with OAuth2Definition

use of io.swagger.models.auth.OAuth2Definition in project swagger-core by swagger-api.

the class AuthSerializationTest method testAccessCodeWithScopes.

@Test(description = "it should convert serialize an oauth2 accessCode flow model with scopes")
public void testAccessCodeWithScopes() throws IOException {
    final OAuth2Definition auth = new OAuth2Definition().accessCode("http://foo.com/authorizationUrl", "http://foo.com/token").scope("email", "read your email");
    final String json = "{\n" + "   \"type\":\"oauth2\",\n" + "   \"authorizationUrl\":\"http://foo.com/authorizationUrl\",\n" + "   \"tokenUrl\":\"http://foo.com/token\",\n" + "   \"flow\":\"accessCode\",\n" + "   \"scopes\":{\n" + "      \"email\":\"read your email\"\n" + "   }\n" + "}";
    SerializationMatchers.assertEqualsToJson(auth, json);
}
Also used : OAuth2Definition(io.swagger.models.auth.OAuth2Definition) Test(org.testng.annotations.Test)

Example 9 with OAuth2Definition

use of io.swagger.models.auth.OAuth2Definition in project swagger-core by swagger-api.

the class AuthSerializationTest method testaAcessCode.

@Test(description = "it should convert serialize an oauth2 accessCode flow model")
public void testaAcessCode() throws IOException {
    final OAuth2Definition auth = new OAuth2Definition().accessCode("http://foo.com/authorizationUrl", "http://foo.com/token");
    final String json = "{\n" + "   \"type\":\"oauth2\",\n" + "   \"authorizationUrl\":\"http://foo.com/authorizationUrl\",\n" + "   \"tokenUrl\":\"http://foo.com/token\",\n" + "   \"flow\":\"accessCode\"\n" + "}";
    SerializationMatchers.assertEqualsToJson(auth, json);
}
Also used : OAuth2Definition(io.swagger.models.auth.OAuth2Definition) Test(org.testng.annotations.Test)

Example 10 with OAuth2Definition

use of io.swagger.models.auth.OAuth2Definition in project swagger-core by swagger-api.

the class AuthSerializationTest method testApplicationAuth.

@Test(description = "it should convert serialize an oauth2 application flow model")
public void testApplicationAuth() throws IOException {
    final OAuth2Definition auth = new OAuth2Definition().application("http://foo.com/token");
    final String json = "{\"type\":\"oauth2\",\"tokenUrl\":\"http://foo.com/token\",\"flow\":\"application\"}";
    SerializationMatchers.assertEqualsToJson(auth, json);
}
Also used : OAuth2Definition(io.swagger.models.auth.OAuth2Definition) Test(org.testng.annotations.Test)

Aggregations

OAuth2Definition (io.swagger.models.auth.OAuth2Definition)11 Test (org.testng.annotations.Test)9 Swagger (io.swagger.models.Swagger)3 JaxbAnnotationModule (com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule)2 Contact (io.swagger.models.Contact)1 Error (io.swagger.models.Error)1 Info (io.swagger.models.Info)1 Model (io.swagger.models.Model)1 Operation (io.swagger.models.Operation)1 Path (io.swagger.models.Path)1 Person (io.swagger.models.Person)1 Response (io.swagger.models.Response)1 SecurityRequirement (io.swagger.models.SecurityRequirement)1 PathParameter (io.swagger.models.parameters.PathParameter)1 QueryParameter (io.swagger.models.parameters.QueryParameter)1 LongProperty (io.swagger.models.properties.LongProperty)1 RefProperty (io.swagger.models.properties.RefProperty)1 StringProperty (io.swagger.models.properties.StringProperty)1