def test_integration_get_team(self):
        log = logging.getLogger("Test")
        test_connection = Connection()
        test_connection.logger = log

        with open("../tests/send_message.json") as file:
            data = json.load(file)
            connection_params = data.get("body").get("connection")

        test_connection.connect(connection_params)

        expected = "[Test] for customer"
        teams = get_teams_from_microsoft(log, test_connection, expected, True)
        self.assertEquals(teams[0].get("displayName"), expected)

        expected = "Dream Team"
        teams = get_teams_from_microsoft(log, test_connection, expected, True)
        self.assertEquals(teams[0].get("displayName"), expected)

        expected = "change_me"
        teams = get_teams_from_microsoft(log, test_connection, expected, True)
        self.assertEquals(teams[0].get("displayName"), expected)

        expected = "Komand-Test-Everyone"
        teams = get_teams_from_microsoft(log, test_connection, expected, True)
        self.assertEquals(teams[0].get("displayName"), expected)
    def test_integration_negative_get_blank_team(self):
        log = logging.getLogger("Test")
        test_connection = Connection()
        test_connection.logger = log

        with open("../tests/send_message.json") as file:
            data = json.load(file)
            connection_params = data.get("body").get("connection")

        test_connection.connect(connection_params)
        expected = ""
        with self.assertRaises(PluginException):
            teams = get_teams_from_microsoft(log, test_connection, expected, True)

        expected = "DONT FIND THIS"
        with self.assertRaises(PluginException):
            teams = get_teams_from_microsoft(log, test_connection, expected, True)
Exemple #3
0
    def run(self, params={}):
        team_name = params.get(Input.TEAM_NAME)
        channel_name = params.get(Input.CHANNEL_NAME)
        channel_description = params.get(Input.CHANNEL_DESCRIPTION)

        teams = get_teams_from_microsoft(self.logger, self.connection, team_name)
        team_id = teams[0].get("id")

        success = create_channel(self.logger, self.connection, team_id, channel_name, channel_description)

        return {Output.SUCCESS: success}
Exemple #4
0
    def run(self, params={}):
        team_name = params.get(Input.TEAM_NAME)
        channel_name = params.get(Input.CHANNEL_NAME)

        teams = get_teams_from_microsoft(self.logger, self.connection, team_name)
        team_id = teams[0].get("id")
        channels = get_channels_from_microsoft(self.logger, self.connection, team_id, channel_name)
        channel_id = channels[0].get("id")

        success = delete_channel(self.logger, self.connection, team_id, channel_id)

        return {Output.SUCCESS: success}
    def run(self, params={}):
        team_name = params.get(Input.TEAM_NAME, "")

        # The end of this filters for only MS Team enabled Teams
        teams = get_teams_from_microsoft(self.logger, self.connection,
                                         team_name, False)

        clean_teams = []
        for team in teams:
            clean_teams.append(remove_null_and_clean(team))

        return {Output.TEAMS: clean_teams}
Exemple #6
0
    def setup_endpoint(self, channel_name: str, team_name: str) -> str:
        """
        This takes a team name and channel in that team and generates a get messages endpoint.

        :param channel_name: String
        :param team_name: String
        :return: String (URL)
        """
        team = get_teams_from_microsoft(self.logger, self.connection, team_name)
        team_id = team[0].get("id")
        channel = get_channels_from_microsoft(self.logger, self.connection, team_id, channel_name)
        channel_id = channel[0].get("id")
        messages_endpoint = f"https://graph.microsoft.com/beta/teams/{team_id}/channels/{channel_id}/messages"
        return messages_endpoint
    def run(self, params={}):
        team_name = params.get(Input.TEAM_NAME)
        channel_name = params.get(Input.CHANNEL_NAME)
        message = params.get(Input.MESSAGE_CONTENT)

        teams = get_teams_from_microsoft(self.logger, self.connection, team_name)
        team_id = teams[0].get("id")
        channels = get_channels_from_microsoft(self.logger, self.connection, team_id, channel_name)
        channel_id = channels[0].get("id")

        message = send_html_message(self.logger, self.connection, message, team_id, channel_id)

        clean_message = remove_null_and_clean(message)

        return {Output.MESSAGE: clean_message}
Exemple #8
0
    def run(self, params={}):
        team_name = params.get(Input.TEAM_NAME)
        channel_name = params.get(Input.CHANNEL_NAME)

        team_array = get_teams_from_microsoft(self.logger, self.connection,
                                              team_name)
        team = team_array[0]

        team_id = team.get("id")

        channels = get_channels_from_microsoft(self.logger, self.connection,
                                               team_id, channel_name)
        clean_channels = []
        for channel in channels:
            clean_channels.append(remove_null_and_clean(channel))

        return {Output.CHANNELS: clean_channels}
    def run(self, params={}):
        user_login = params.get(Input.MEMBER_LOGIN)
        team_name = params.get(Input.TEAM_NAME)

        # Get User ID
        user_result = get_user_info(self.logger, self.connection, user_login)
        user_id = user_result.get("id")

        # Get Group ID
        teams_result = get_teams_from_microsoft(self.logger, self.connection,
                                                team_name)
        group_id = teams_result[0].get("id")

        # Add user to Group
        success = add_user_to_group(self.logger, self.connection, group_id,
                                    user_id)

        return {Output.SUCCESS: success}
    def run(self, params={}):
        message = params.get(Input.MESSAGE_CONTENT)

        teams = get_teams_from_microsoft(self.logger, self.connection,
                                         params.get(Input.TEAM_NAME))
        team_id = teams[0].get("id")
        channels = get_channels_from_microsoft(self.logger, self.connection,
                                               team_id,
                                               params.get(Input.CHANNEL_NAME))

        message = send_html_message(self.logger,
                                    self.connection,
                                    message,
                                    team_id,
                                    channels[0].get("id"),
                                    thread_id=params.get(
                                        Input.THREAD_ID, None))

        return {Output.MESSAGE: remove_null_and_clean(message)}