Esempio n. 1
0
 def run(self, params={}):
     group_id = get_group_id_from_name(self.logger, self.connection, params.get(Input.GROUP_NAME))
     channels = get_channels_from_microsoft(self.logger, self.connection, group_id, params.get(Input.CHANNEL_NAME))
     user_id = get_user_info(self.logger, self.connection, params.get(Input.MEMBER_LOGIN))
     try:
         channel_id = channels[0].get("id")
         user_id = user_id.get("id")
         if not channel_id:
             raise PluginException(
                 cause="The specified channel does not exist.",
                 assistance="Please check that channel name is correct."
             )
         if not user_id:
             raise PluginException(
                 cause="The specified user does not exist.",
                 assistance="Please check that member login is correct."
             )
     except IndexError as e:
         raise PluginException(
             cause="The specified channel does not exist.",
             assistance="If the issue persists please contact support.",
             data=e
         )
     return {
         Output.SUCCESS: add_user_to_channel(
             self.logger,
             self.connection,
             group_id,
             channel_id,
             user_id
         )
     }
    def test_get_user_info(self):
        log = logging.getLogger()
        connection = Connection()
        connection.logger = log

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

        connection.connect(connection_params)

        result = get_user_info(log, connection,
                               "*****@*****.**")

        self.assertEqual("Joey McAdams", result.get("displayName"))
        self.assertEqual("08290005-23ba-46b4-a377-b381d651a2fb",
                         result.get("id"))

        result = get_user_info(log, connection,
                               "*****@*****.**")

        self.assertEqual("Jon Schipp", result.get("displayName"))
        self.assertEqual("ac785ffe-530a-45a1-bbf4-e275457e464b",
                         result.get("id"))
Esempio n. 3
0
 def run(self, params={}):
     user_id = get_user_info(self.logger, self.connection,
                             params.get(Input.MEMBER_LOGIN))
     if not user_id or not user_id.get("id"):
         raise PluginException(
             cause="The specified user does not exist.",
             assistance="Please check that member login is correct.")
     return {
         Output.SUCCESS:
         add_user_to_owners(
             self.logger, self.connection,
             get_group_id_from_name(self.logger, self.connection,
                                    params.get(Input.GROUP_NAME)),
             user_id.get("id"))
     }
Esempio n. 4
0
    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}