| 1546 | } |
| 1547 | |
| 1548 | func (s *testSuite) TestIsURLPath() { |
| 1549 | cases := []struct { |
| 1550 | name string |
| 1551 | path string |
| 1552 | expected bool |
| 1553 | }{ |
| 1554 | { |
| 1555 | name: "http URL", |
| 1556 | path: "http://example.com/policy.rego", |
| 1557 | expected: true, |
| 1558 | }, |
| 1559 | { |
| 1560 | name: "https URL", |
| 1561 | path: "https://example.com/policy.rego", |
| 1562 | expected: true, |
| 1563 | }, |
| 1564 | { |
| 1565 | name: "relative file path", |
| 1566 | path: "policy.rego", |
| 1567 | expected: false, |
| 1568 | }, |
| 1569 | { |
| 1570 | name: "absolute file path", |
| 1571 | path: "/absolute/path/policy.rego", |
| 1572 | expected: false, |
| 1573 | }, |
| 1574 | { |
| 1575 | name: "file scheme", |
| 1576 | path: "file:///path/to/policy.rego", |
| 1577 | expected: false, |
| 1578 | }, |
| 1579 | { |
| 1580 | name: "chainloop scheme", |
| 1581 | path: "chainloop://provider/policy", |
| 1582 | expected: false, |
| 1583 | }, |
| 1584 | { |
| 1585 | name: "empty path", |
| 1586 | path: "", |
| 1587 | expected: false, |
| 1588 | }, |
| 1589 | } |
| 1590 | |
| 1591 | for _, tc := range cases { |
| 1592 | s.Run(tc.name, func() { |
| 1593 | result := isURLPath(tc.path) |
| 1594 | s.Equal(tc.expected, result) |
| 1595 | }) |
| 1596 | } |
| 1597 | } |
| 1598 | |
| 1599 | func (s *testSuite) TestPolicyAttachmentGate() { |
| 1600 | trueGate := true |