Esempio n. 1
0
    def test_search_alert(self, mocked_requests_post, mocked_requests_get):
        content = {"access_token": "fake_access_token"}
        content2 = {"alerts": [{"alert1": 1}, {"alert2": 2}]}
        mocked_requests_post.return_value = generate_response(content, 200)
        mocked_requests_get.return_value = generate_response(content2, 200)
        ms_helper = MicrosoftGraphHelper("tenant_id1234", "client_id1234",
                                         "client_secret1234")
        ms_helper.clear_cache()
        r = alert_search("ms_graph_url", ms_helper, "filter")

        assert r.json() == content2
Esempio n. 2
0
    def test_update_alert(self, mocked_requests_post, mocked_requests_patch):
        content = {"access_token": "fake_access_token"}
        content2 = {"alert_details": {"details": "updated"}}
        mocked_requests_post.return_value = generate_response(content, 200)
        mocked_requests_patch.return_value = generate_response(content2, 200)
        ms_helper = MicrosoftGraphHelper("tenant_id1234", "client_id1234",
                                         "client_secret1234")
        ms_helper.clear_cache()
        r = update_alert("ms_graph_url", ms_helper, "21354657678",
                         '{"update_data": "data"}')

        assert r.json() == content2
Esempio n. 3
0
    def test_get_alert_details(self, mocked_requests_post,
                               mocked_requests_get):
        content = {"access_token": "fake_access_token"}
        content2 = {"alert_details": {"details": 1234}}
        mocked_requests_post.return_value = generate_response(content, 200)
        mocked_requests_get.return_value = generate_response(content2, 200)
        ms_helper = MicrosoftGraphHelper("tenant_id1234", "client_id1234",
                                         "client_secret1234")
        ms_helper.clear_cache()
        r = get_alert_details("ms_graph_url", ms_helper, "1223456788")

        assert r.json() == content2
Esempio n. 4
0
    def test_get_access_token_refresh(self, mocked_requests_post):
        content1 = {"access_token": ""}
        content2 = {"access_token": "fake_refreshed_access_token"}
        mocked_requests_post.side_effect = [
            generate_response(content1, 200),
            generate_response(content2, 200)
        ]

        ms_helper = MicrosoftGraphHelper("tenant_id1234", "client_id1234",
                                         "client_secret1234")
        ms_helper.clear_cache()
        token = ms_helper.get_access_token()
        assert token == "fake_refreshed_access_token"