コード例 #1
0
def configure_email(file, is_prod: bool):
    if is_prod:
        password = get_secret("email/password")
        slack_url = get_secret("slack/montagu-webhook")
        print("email.mode=real", file=file)
        print("email.password="******"slack.url={}".format(slack_url), file=file)
コード例 #2
0
ファイル: tests.py プロジェクト: yzhan289/semesterly
 def test_logged_in_via_fb_flow(self):
     self.driver.set_window_size(1440, 1080)
     self.clear_tutorial()
     with self.description("succesfully signup with facebook"):
         self.login_via_fb(email=get_secret("FB_TEST_EMAIL"),
                           password=get_secret("FB_TEST_PASS"))
         self.complete_user_settings_basics(major='Computer Science',
                                            class_year=2017)
     with self.description(
             "search, add, change personal timetable name and save"):
         self.search_course('AS.110.105', 1)
         self.add_course(0, n_slots=4, n_master_slots=1)
         self.change_ptt_name("Testing Timetable")
         self.save_ptt()
         self.assert_ptt_const_across_refresh()
     with self.description("add to personal timetable, share, save"):
         self.search_course('AS.110.106', 1)
         self.open_course_modal_from_search(0)
         self.share_timetable([
             self.add_course_from_course_modal(n_slots=8, n_master_slots=2)
         ])
         testing_ptt = self.save_ptt()
         self.assert_ptt_const_across_refresh()
     with self.description(
             "create new personal timetable, validate on reload"):
         self.create_ptt("End To End Testing!")
         self.search_course('AS.110.105', 1)
         self.add_course(0, n_slots=4, n_master_slots=1)
         e2e_ptt = self.save_ptt()
         self.assert_ptt_const_across_refresh()
     with self.description("Switch to original ptt and validate"):
         self.switch_to_ptt("Testing Timetable")
         self.assert_ptt_equals(testing_ptt)
     with self.description(
             "switch semester, create personal timetable, switch back"):
         self.change_term("Spring 2017")
         self.create_ptt("Hope ders no bugs!")
         self.click_off()
         self.search_course('AS.110.106', 1)
         self.add_course(0, n_slots=4, n_master_slots=1)
         self.save_ptt()
         self.change_to_current_term()
         self.assert_ptt_equals(e2e_ptt)
     with self.description(("add friend with course,"
                            "check for friend circles"
                            "and presence in modal")):
         friend = self.create_friend("Tester",
                                     "McTestFace",
                                     social_courses=True)
         self.create_personal_timetable_obj(
             friend, [Course.objects.get(code='AS.110.105')],
             self.current_sem)
         self.assert_ptt_const_across_refresh()
         self.assert_friend_image_found(friend)
         self.open_course_modal_from_slot(0)
         self.assert_friend_in_modal(friend)
コード例 #3
0
ファイル: notify.py プロジェクト: thuyvuong1/montagu
 def __init__(self, channel):
     self.enabled = len(channel) > 0
     if self.enabled:
         path = get_secret('slack/deploy-webhook')
         self.url = 'https://hooks.slack.com/services/{}'.format(path)
         self.channel = "#" + channel
         self.username = "******"
         self.icon = ":robot_face:"
         self.headers = {'Content-Type': 'application/json'}
コード例 #4
0
ファイル: login.py プロジェクト: dfherr/syn
    def get_session(cls, new_session=False):
        """
        loads and checks the last session
        if it's not valid anymore, generate a new session
        """
        if not new_session:
            last_session = cls.load_session()
            if last_session is not None:
                try:
                    r = last_session.session.get(links['home'])
                    if last_session.check_login(r.content):
                        return last_session
                except AttributeError as e:
                    print('Session object corrupted {0}'.format(e))
                    print('Generating a new session')

        return LoggedInSession(
            user=get_secret('user'),
            password=get_secret('password')
        )
コード例 #5
0
def configure_montagu(service, data_exists):
    # Do things to the database
    if data_exists:
        print("Skipping data import: 'persist_data' is set, "
              "and this is not a first-time deployment")
    else:
        data_import.do(service)

    passwords = database.setup(service)

    # Push secrets into containers
    cert_paths = get_ssl_certificate(service.settings["certificate"])
    token_keypair_paths = get_token_keypair()

    is_prod = service.settings["password_group"] == 'production'
    configure_api(service, passwords['api'], token_keypair_paths,
                  service.settings["hostname"], is_prod,
                  service.settings["orderly_web_api_url"])

    task_queue_user = "******"
    task_queue_email = "*****@*****.**"
    if service.settings["use_real_diagnostic_reports"]:
        task_queue_password = get_secret(
            "task-queue-user/{}".format(service.settings["instance_name"]),
            "password")
    else:
        task_queue_password = "******"

    print("Configuring task queue user")
    add_user(task_queue_user, task_queue_user, task_queue_email,
             task_queue_password)
    orderlyweb_cli.add_user(task_queue_email)
    perms = ["*/reports.read", "*/reports.review", "*/reports.run"]
    orderlyweb_cli.grant_permissions(task_queue_email, perms)

    configure_task_queue(service, task_queue_email, task_queue_password,
                         service.settings["orderly_web_api_url"],
                         service.settings["use_real_diagnostic_reports"],
                         service.settings["fake_smtp"])

    configure_proxy(service, cert_paths)

    if service.settings["include_guidance_reports"]:
        configure_contrib_portal(service)

    if service.settings["copy_static_files"]:
        configure_static_server(service, token_keypair_paths)
コード例 #6
0
def configure_task_queue(service, montagu_email, montagu_password,
                         orderly_web_url, use_real_diagnostic_reports,
                         fake_smtp):
    container = service.task_queue

    print("Configuring Task Queue")
    print("- reading config from container")
    local_config_file = join(paths.config, "task_queue_config.yml")
    container_config_file = "home/worker/config/config.yml"
    docker_cp_from(container.name, container_config_file, local_config_file)
    with open(local_config_file, "r") as ymlfile:
        config = yaml.load(ymlfile, Loader=yaml.FullLoader)

    print("- reading diagnostic reports")
    reports_cfg_filename = "real_diagnostic_reports.yml" if use_real_diagnostic_reports else "test_diagnostic_reports.yml"
    local_reports_cfg_file = join(paths.container_config, "task_queue",
                                  reports_cfg_filename)
    with open(local_reports_cfg_file, "r") as ymlfile:
        diag_reports = yaml.load(ymlfile, Loader=yaml.FullLoader)

    print("- adding settings to config")
    montagu = config["servers"]["montagu"]
    montagu["url"] = "http://*****:*****@imperial.ac.uk"
    if fake_smtp:
        smtp["host"] = "montagu_fake_smtp_server_1"
    else:
        smtp["host"] = "smtp.cc.ic.ac.uk"
        smtp["port"] = 587
        smtp["user"] = "******"
        smtp["password"] = get_secret("email/password")

    print("- writing config to container")
    with open(local_config_file, "w") as file:
        yaml.dump(config, file)
    docker_cp(local_config_file, container.name, container_config_file)
コード例 #7
0
ファイル: database.py プロジェクト: thuyvuong1/montagu
 def get(self):
     if self.password_group is None:
         return "changeme" if self.username == "vimc" else self.username
     else:
         return get_secret(self._path(), field="password")
コード例 #8
0
 def get(self):
     if self.auth is None:
         password = get_secret("teamcity/deploy", field="password")
         self.auth = HTTPBasicAuth("deploy", password)
     return self.auth
コード例 #9
0
ファイル: tests.py プロジェクト: majidaziz/semesterly
 def test_logged_in_via_fb_flow(self):
     self.driver.set_window_size(1440, 1080)
     self.clear_tutorial()
     with self.description("succesfully signup with facebook"):
         self.login_via_fb(
             email=get_secret("FB_TEST_EMAIL"),
             password=get_secret("FB_TEST_PASS")
         )
         self.complete_user_settings_basics(
             major='Computer Science',
             class_year=2017
         )
     with self.description("search, add, change personal timetable name and save"):
         self.search_course('AS.110.105', 1)
         self.add_course(0, n_slots=4, n_master_slots=1)
         self.change_ptt_name("Testing Timetable")
         self.save_ptt()
         self.assert_ptt_const_across_refresh()
     with self.description("add to personal timetable, share, save"):
         self.search_course('AS.110.106', 1)
         self.open_course_modal_from_search(0)
         self.share_timetable([
             self.add_course_from_course_modal(
                 n_slots=8, n_master_slots=2
             )
         ])
         testing_ptt = self.save_ptt()
         self.assert_ptt_const_across_refresh()
     with self.description("create new personal timetable, validate on reload"):
         self.create_ptt("End To End Testing!")
         self.search_course('AS.110.105', 1)
         self.add_course(0, n_slots=4, n_master_slots=1)
         e2e_ptt = self.save_ptt()
         self.assert_ptt_const_across_refresh()
     with self.description("Switch to original ptt and validate"):
         self.switch_to_ptt("Testing Timetable")
         self.assert_ptt_equals(testing_ptt)
     with self.description("switch semester, create personal timetable, switch back"):
         self.change_term("Spring 2017")
         self.create_ptt("Hope ders no bugs!")
         self.click_off()
         self.search_course('AS.110.106', 1)
         self.add_course(0, n_slots=4, n_master_slots=1)
         self.save_ptt()
         self.change_to_current_term()
         self.assert_ptt_equals(e2e_ptt)
     with self.description(("add friend with course,"
                            "check for friend circles"
                            "and presence in modal")):
         friend = self.create_friend(
             "Tester",
             "McTestFace",
             social_courses=True
         )
         self.create_personal_timetable_obj(
             friend,
             [Course.objects.get(code='AS.110.105')],
             self.current_sem
         )
         self.assert_ptt_const_across_refresh()
         self.assert_friend_image_found(friend)
         self.open_course_modal_from_slot(0)
         self.assert_friend_in_modal(friend)