小编Amd*_*Ali的帖子

本地主机:提供的 postMessage 目标来源与收件人窗口的来源不匹配

所以我正在尝试构建一个使用 sso 来验证用户身份的应用程序。这是工作流程:

  • 在 localhost:3000 上启动应用程序(我正在使用 React 单个 Web 应用程序)
  • 将显示一个弹出窗口(实际上,弹出窗口将调用我的节点 js 身份验证路由 localhost:4000/authenticate,它将用户重定向到 sso 身份验证页面)
  • 身份验证后,sso 服务器会将用户重定向到节点回调路由 ( http://localhost:4000/authenticate/callback )
  • node 检查这是否是有效用户并返回成功消息(实际上 node 将发送一个 html + javascript 代码来关闭弹出窗口)。
  • 如果收到的消息成功,我们会让用户加载应用程序

这是一些代码:

应用程序.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)

html javascript node.js reactjs

3
推荐指数
1
解决办法
1831
查看次数

Spring - 如何为soap服务构建junit测试

我正在按照 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)

junit spring-mvc spring-test-mvc spring-boot

3
推荐指数
1
解决办法
2万
查看次数