コード例 #1
0
    def test_verify_project_invalid_context(self):
        verifier = pretend.stub(context=pretend.stub())
        caveat = V1Caveat(verifier)

        predicate = {"version": 1, "permissions": {"projects": ["notfoobar"]}}
        with pytest.raises(InvalidMacaroon):
            caveat(json.dumps(predicate))
コード例 #2
0
ファイル: test_caveats.py プロジェクト: miketheman/warehouse
    def test_verify_project(self, db_request):
        project = ProjectFactory.create(name="foobar")
        verifier = pretend.stub(context=project)
        caveat = V1Caveat(verifier)

        predicate = {"version": 1, "permissions": {"projects": ["foobar"]}}
        assert caveat(json.dumps(predicate)) is True
コード例 #3
0
ファイル: test_caveats.py プロジェクト: miketheman/warehouse
    def test_verify_project_invalid_context(self):
        verifier = pretend.stub(context=pretend.stub())
        caveat = V1Caveat(verifier)

        predicate = {"version": 1, "permissions": {"projects": ["notfoobar"]}}

        assert caveat(json.dumps(predicate)) is False
コード例 #4
0
    def test_verify_project_invalid_project_name(self, db_request):
        project = ProjectFactory.create(name="foobar")
        verifier = pretend.stub(context=project)
        caveat = V1Caveat(verifier)

        predicate = {"version": 1, "permissions": {"projects": ["notfoobar"]}}
        with pytest.raises(InvalidMacaroon):
            caveat(json.dumps(predicate))
コード例 #5
0
    def test_verify_project_no_projects_object(self, db_request):
        project = ProjectFactory.create(name="foobar")
        verifier = pretend.stub(context=project)
        caveat = V1Caveat(verifier)

        predicate = {
            "version": 1,
            "permissions": {"somethingthatisntprojects": ["blah"]},
        }
        with pytest.raises(InvalidMacaroonError):
            caveat(json.dumps(predicate))
コード例 #6
0
ファイル: test_caveats.py プロジェクト: miketheman/warehouse
    def test_verify_project_no_projects_object(self, db_request):
        project = ProjectFactory.create(name="foobar")
        verifier = pretend.stub(context=project)
        caveat = V1Caveat(verifier)

        predicate = {
            "version": 1,
            "permissions": {
                "somethingthatisntprojects": ["blah"]
            },
        }

        assert caveat(json.dumps(predicate)) is False
コード例 #7
0
ファイル: test_caveats.py プロジェクト: miketheman/warehouse
    def test_verify_valid_predicate(self):
        verifier = pretend.stub()
        caveat = V1Caveat(verifier)
        predicate = '{"permissions": "user", "version": 1}'

        assert caveat(predicate) is True
コード例 #8
0
ファイル: test_caveats.py プロジェクト: miketheman/warehouse
    def test_verify_invalid_predicates(self, predicate, result):
        verifier = pretend.stub()
        caveat = V1Caveat(verifier)

        assert caveat(predicate) is False
コード例 #9
0
    def test_verify_invalid_predicates(self, predicate, result):
        verifier = pretend.stub()
        caveat = V1Caveat(verifier)

        with pytest.raises(InvalidMacaroon):
            caveat(predicate)