yzt
2023-09-27 726603df43447f8cfedfeaae4267209adbd01699
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import { TrustedServers } from "../../Source/Cesium.js";
 
describe("Core/TrustedServers", function () {
  afterEach(function () {
    TrustedServers.clear();
  });
 
  it("add without argument throws", function () {
    expect(function () {
      TrustedServers.add();
    }).toThrowDeveloperError();
  });
 
  it("remove without argument throws", function () {
    expect(function () {
      TrustedServers.remove();
    }).toThrowDeveloperError();
  });
 
  it("isTrusted without argument throws", function () {
    expect(function () {
      TrustedServers.contains();
    }).toThrowDeveloperError();
  });
 
  it("http without a port", function () {
    TrustedServers.add("cesiumjs.org", 80);
    expect(TrustedServers.contains("http://cesiumjs.org/index.html")).toBe(
      true
    );
    expect(TrustedServers.contains("https://cesiumjs.org/index.html")).toBe(
      false
    );
  });
 
  it("https without a port", function () {
    TrustedServers.add("cesiumjs.org", 443);
    expect(TrustedServers.contains("https://cesiumjs.org/index.html")).toBe(
      true
    );
    expect(TrustedServers.contains("http://cesiumjs.org/index.html")).toBe(
      false
    );
  });
 
  it("add", function () {
    expect(TrustedServers.contains("http://cesiumjs.org:81/index.html")).toBe(
      false
    );
    TrustedServers.add("cesiumjs.org", 81);
    expect(TrustedServers.contains("http://cesiumjs.org/index.html")).toBe(
      false
    );
    expect(TrustedServers.contains("http://cesiumjs.org:81/index.html")).toBe(
      true
    );
  });
 
  it("remove", function () {
    TrustedServers.add("cesiumjs.org", 81);
    expect(TrustedServers.contains("http://cesiumjs.org:81/index.html")).toBe(
      true
    );
    TrustedServers.remove("cesiumjs.org", 8080);
    expect(TrustedServers.contains("http://cesiumjs.org:81/index.html")).toBe(
      true
    );
    TrustedServers.remove("cesiumjs.org", 81);
    expect(TrustedServers.contains("http://cesiumjs.org:81/index.html")).toBe(
      false
    );
  });
 
  it("handles username/password credentials", function () {
    TrustedServers.add("cesiumjs.org", 81);
    expect(
      TrustedServers.contains("http://user:pass@cesiumjs.org:81/index.html")
    ).toBe(true);
  });
 
  it("always returns false for relative paths", function () {
    expect(TrustedServers.contains("./data/index.html")).toBe(false);
  });
 
  it("handles protocol relative URLs", function () {
    TrustedServers.add("cesiumjs.org", 80);
    expect(TrustedServers.contains("//cesiumjs.org/index.html")).toBe(true);
  });
 
  it("clear", function () {
    TrustedServers.add("cesiumjs.org", 80);
    expect(TrustedServers.contains("http://cesiumjs.org/index.html")).toBe(
      true
    );
    TrustedServers.clear();
    expect(TrustedServers.contains("http://cesiumjs.org/index.html")).toBe(
      false
    );
    TrustedServers.add("cesiumjs.org", 80);
    expect(TrustedServers.contains("http://cesiumjs.org/index.html")).toBe(
      true
    );
  });
});