小编Mar*_*lik的帖子

为什么IE XDomainRequest不发送Referer头

当我通过XDomainRequest对象在IE中执行CORS时,不会发送Referer HTTP标头.有没有官方文件说明这个?我完全理解,依赖Referer HTTP头是基本错误的想法,但是没有确凿的证据我被困在这里,并且无法证明我们的架构师是错误的.

转储示例:

IE请求

GET http://example.com/some/url HTTP/1.1
Accept: */*
Origin: http://another.domain.com
Accept-Language: sk-SK
UA-CPU: AMD64
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.3)
Host: example.com
Connection: Keep-Alive
Pragma: no-cache
Run Code Online (Sandbox Code Playgroud)

Chrome请求

GET http://example.com/some/url HTTP/1.1
Host: example.com
Connection: keep-alive
Origin: http://another.domain.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36
Accept: */*
Referer: http://another.domain.com/
Accept-Encoding: gzip,deflate,sdch …
Run Code Online (Sandbox Code Playgroud)

javascript http-referer internet-explorer cors xdomainrequest

8
推荐指数
1
解决办法
3028
查看次数

如何使用 Cypress 和 Auth0 测试单页应用程序

我有一个隐藏在 Auth0 锁后面的单页应用程序,使用@auth0/auth0-spa-js。我想使用 Cypress 对其进行测试,因此我决定关注Auth0官方博客文章以及 Johnny Reilly博客文章

我能够使用建议的请求从 auth0 成功检索有效的 JWT 令牌。我不知道该怎么办:(

我面临的问题是,上述两种方法都依赖于应用程序在本地存储 JWT 令牌(在 cookie 或 localstorage 中)。然而,@auth0/auth0-spa-js使用不同的方法,我假设所有相关的 cookie/localstorage 都存储在 auth0 域中。

你有什么想法,如果有办法绕过它吗?

2018 年 7 月这里报告一个类似的问题,没有真正提供任何解决方案

auth0 cypress auth0-lock

5
推荐指数
1
解决办法
3911
查看次数

如何模拟获取响应对象

我尝试使用 ts-jest 模拟获取响应,但遇到打字稿错误

import { mocked } from 'ts-jest/utils';
import fetch from 'node-fetch';

import { getInstallationAccessToken } from './index';

const mockedFetch = mocked(fetch, true);

describe('getInstallationAccessToken', () => {
  const TODAY = new Date();
  const TOMORROW = new Date();
  TOMORROW.setDate(TODAY.getDate() + 1);

  beforeEach(() => {
    mockedFetch.mockResolvedValue({
      status: 200,
      json: async () => ({
        token: 'MOCKED_GITHUB_INSTALLATION_ACCESS_TOKEN',
        expires_at: TOMORROW.toISOString()
      })
    });
    jest.clearAllMocks();
  });

  test('generates github app jwt token', async () => {
    await getInstallationAccessToken();
    expect(mockedJwt.sign).toBeCalledTimes(1);
  });
})
Run Code Online (Sandbox Code Playgroud)

在此示例中,我收到以下错误:

Argument of type '{ status: …
Run Code Online (Sandbox Code Playgroud)

response fetch typescript jestjs ts-jest

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

Laravel 中用于路由测试的模拟中间件

我正在尝试编写一些单元测试以确保我的路由不会被意外重写。我已经找到一个答案来检查正确的控制器是否分配给特定的路线在这里

但是,我还想检查是否为路由分配了正确的中间件。我尝试了类似的方法

$tmp = new CorsService;
$corsMiddleware = Mockery::mock('Barryvdh\Cors\HandleCors[handle]', array($tmp))
    ->shouldReceive('handle')->once()
    ->andReturnUsing(function($request, Closure $next) {
        return $next($request);
    });

\App::instance('Barryvdh\Cors\HandleCors', $corsMiddleware);
Run Code Online (Sandbox Code Playgroud)

出于某种原因,测试没有发现这一点。我假设这是因为中间件实例不是使用App::instance.

我究竟做错了什么?

phpunit unit-testing middleware mocking laravel

4
推荐指数
1
解决办法
3525
查看次数