@Before
  public void setUp() {
    when(tokenGenerator.generate()).thenReturn("123456789");
    when(tokenGenerator.hash(anyString())).thenReturn("987654321");
    userSession.login().setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN);
    userDb.insertUser(newUserDto().setLogin(GRACE_HOPPER));
    userDb.insertUser(newUserDto().setLogin(ADA_LOVELACE));

    ws =
        new WsActionTester(
            new GenerateAction(db.getDbClient(), userSession, System2.INSTANCE, tokenGenerator));
  }
Пример #2
0
  @Test
  public void return_only_current_user_projects() {
    ComponentDto jdk7 = insertJdk7();
    ComponentDto cLang = insertClang();
    UserDto anotherUser = userDb.insertUser(newUserDto());
    insertUserPermission(UserRole.ADMIN, user.getId(), jdk7.getId());
    insertUserPermission(UserRole.ADMIN, anotherUser.getId(), cLang.getId());

    SearchMyProjectsWsResponse result = call_ws();

    assertThat(result.getProjectsCount()).isEqualTo(1);
    assertThat(result.getProjects(0).getId()).isEqualTo(jdk7.uuid());
  }
Пример #3
0
  @Before
  public void setUp() {
    user = userDb.insertUser(newUserDto().setLogin(USER_LOGIN));
    userSession.login(this.user.getLogin()).setUserId(user.getId().intValue());
    alertStatusMetric =
        dbClient
            .metricDao()
            .insert(
                dbSession,
                newMetricDto().setKey(ALERT_STATUS_KEY).setValueType(ValueType.LEVEL.name()));
    db.commit();

    ws =
        new WsActionTester(
            new SearchMyProjectsAction(
                dbClient, new SearchMyProjectsDataLoader(userSession, dbClient), userSession));
  }