예제 #1
0
def test_update_user_success(mocker):
    responses.add(
        responses.GET,
        f"{URL}/api/security/users/{USER_TO_UPDATE.name}",
        json=USER.dict(),
        status=200,
    )

    responses.add(
        responses.POST,
        f"{URL}/api/security/users/{USER_TO_UPDATE.name}",
        json=USER.dict(),
        status=200,
    )
    artifactory_user = ArtifactoryUser(AuthModel(url=URL, auth=AUTH))
    mocker.spy(artifactory_user, "get")
    artifactory_user.update(USER_TO_UPDATE)

    artifactory_user.get.assert_called_with(NEW_USER.name)
    assert artifactory_user.get.call_count == 2
    def test_create_user_success(mocker):
        responses.add(responses.GET,
                      f"{URL}/api/security/users/{USER.name}",
                      status=404)
        responses.add(
            responses.PUT,
            f"{URL}/api/security/users/{USER.name}",
            json=USER.dict(),
            status=201,
        )
        responses.add(
            responses.GET,
            f"{URL}/api/security/users/{USER.name}",
            json=USER.dict(),
            status=200,
        )

        artifactory_user = ArtifactoryUser(AuthModel(url=URL, auth=AUTH))
        mocker.spy(artifactory_user, "get")
        user = artifactory_user.create(NEW_USER)

        artifactory_user.get.assert_called_with(NEW_USER.name)
        assert artifactory_user.get.call_count == 2
        assert user == USER.dict()
예제 #3
0
def test_unlock_user_success(mocker):
    responses.add(responses.POST,
                  f"{URL}/api/security/unlockUsers/{NEW_USER.name}",
                  status=200)
    artifactory_user = ArtifactoryUser(AuthModel(url=URL, auth=AUTH))
    artifactory_user.unlock(NEW_USER.name)