所以我正在尝试构建一个使用 sso 来验证用户身份的应用程序。这是工作流程:
这是一些代码:
应用程序.js
handleLogIn() {
const msg = loginTab('http://localhost:4000/authenticate');
msg.then(response => {
console.log(response)
});
}
render() {
let loginButton = (<button onClick={this.handleLogIn.bind(this)}>Sign in</button>)
return (
<div>
{loginButton}
</div>
)
}
Run Code Online (Sandbox Code Playgroud)
登录选项卡
const loginTab = (myUrl) => {
const windowArea = {
width: Math.floor(window.outerWidth * 0.8),
height: Math.floor(window.outerHeight * 0.5),
};
if …Run Code Online (Sandbox Code Playgroud) 我正在按照 spring 指南创建一个 hello world 肥皂 ws。链接如下:
https://spring.io/guides/gs/having-web-service/
我成功地让它发挥作用。当我运行此命令行时:
curl --header“内容类型:text/xml”-d @src/test/resources/request.xml http://localhost:8080/ws/coutries.wsdl
我得到这个回应。
<SOAP-ENV:Header/><SOAP-ENV:Body><ns2:getCountryResponse xmlns:ns2="http://spring.io/guides/gs-producing-web-service"><ns2:country><ns2:name>Spain</ns2:name><ns2:population>46704314</ns2:population><ns2:capital>Madrid</ns2:capital><ns2:currency>EUR</ns2:currency></ns2:country></ns2:getCountryResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
Run Code Online (Sandbox Code Playgroud)
现在我正在尝试为此服务(控制器层)创建一个 junit 测试,但它不起作用。
这是我的单元测试:
@RunWith(SpringRunner.class)
@WebMvcTest(CountryEndpoint.class)
@ContextConfiguration(classes = {CountryRepository.class, WebServiceConfig.class})
public class CountryEndpointTest {
private final String URI = "http://localhost:8080/ws/countries.wsdl";
@Autowired
private MockMvc mockMvc;
@Test
public void test() throws Exception {
mockMvc.perform(
get(URI)
.accept(MediaType.TEXT_XML)
.contentType(MediaType.TEXT_XML)
.content(request)
)
.andDo(print())
.andExpect(status().isOk());
}
static String request = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n" +
" xmlns:gs=\"http://spring.io/guides/gs-producing-web-service\">\n" +
" <soapenv:Header/>\n" +
" <soapenv:Body>\n" +
" <gs:getCountryRequest>\n" +
" <gs:name>Spain</gs:name>\n" +
" </gs:getCountryRequest>\n" …Run Code Online (Sandbox Code Playgroud)