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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations