From 14e85616e4d945348cf50c2113b900b39dc4672c Mon Sep 17 00:00:00 2001 From: William Kim <wkim@mitre.org> Date: Wed, 3 Jul 2013 08:49:07 -0400 Subject: [PATCH] init commit. webfinger service test. --- .../impl/TestWebfingerIssuerService.java | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 openid-connect-client/src/test/java/org/mitre/openid/connect/client/service/impl/TestWebfingerIssuerService.java diff --git a/openid-connect-client/src/test/java/org/mitre/openid/connect/client/service/impl/TestWebfingerIssuerService.java b/openid-connect-client/src/test/java/org/mitre/openid/connect/client/service/impl/TestWebfingerIssuerService.java new file mode 100644 index 000000000..1b0de7f39 --- /dev/null +++ b/openid-connect-client/src/test/java/org/mitre/openid/connect/client/service/impl/TestWebfingerIssuerService.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright 2013 The MITRE Corporation + * and the MIT Kerberos and Internet Trust Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ +package org.mitre.openid.connect.client.service.impl; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.*; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.log4j.BasicConfigurator; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mitre.openid.connect.client.model.IssuerServiceResponse; +import org.mockito.Mockito; + +/** + * @author wkim + * + */ +public class TestWebfingerIssuerService { + + // Test fixture: + private HttpServletRequest request; + + // WebfingerIssuerService.parameterName = "identifier"; + private String identifier = "user@example.org"; + + private String loginPageUrl = "https://www.example.com/account"; + + private WebfingerIssuerService service = new WebfingerIssuerService(); + + @Before + public void prepare() { + + BasicConfigurator.configure(); + + service.setLoginPageUrl(loginPageUrl); + + request = Mockito.mock(HttpServletRequest.class); + Mockito.when(request.getParameter("identifier")).thenReturn(identifier); + } + + @After + public void cleanup() { + + BasicConfigurator.resetConfiguration(); + } + + //@Test + public void getIssuer_validIdentifier() { + + IssuerServiceResponse response = service.getIssuer(request); + + String expectedIssuer = "https://example.org/.well-known/webfinger"; + + assertThat(response.getIssuer(), equalTo(expectedIssuer)); + } + +}