1. 28 Feb, 2021 10 commits
    • Georges Racinet's avatar
      User: flag to prefer access tokens in VCS operations · d7f2d49a16db
      Georges Racinet authored
      This is necessary for 2FA and SSO, but we don't want to make
      it the general case because:
      
      - accessing `User.token` does not guarantee that the token is
        initialized. It probably will at some point, be it only for
        uniformity with `webdriver`, which does
      - creating a token if needed is expensive, and may not be useful
        for some temporary users.
      d7f2d49a16db
    • Georges Racinet's avatar
      User: cleanup remnant of adoption · 4f0262c58912
      Georges Racinet authored
      Instead of `User` we better use `cls` in the classmethods,
      to avoid puzzling behaviour if subclasses arise in the future.
      4f0262c58912
    • Georges Racinet's avatar
      User: keeping track of email · c58dc5d814f9
      Georges Racinet authored
      This will be essential for SSO logins for which the email
      is the proper identifier.
      c58dc5d814f9
    • Georges Racinet's avatar
      Heptapod: removed the get_user_webdriver() method · 539ade5321f7
      Georges Racinet authored
      It had become frankly redundant, removing it makes it
      clearer that the `User.webdriver` property is what callers
      should use.
      539ade5321f7
    • Georges Racinet's avatar
      User: removed login() method in favor of webdriver property · bbbe50896671
      Georges Racinet authored
      It was just there as a refactoring step, and had the
      drawback to depend on the `_webdriver` attribute not to be None,
      which is an implementation detail.
      
      All callers should use the `webdriver` property.
      bbbe50896671
    • Georges Racinet's avatar
      User: adopted logic to close webdriver · 6d0c5253aacc
      Georges Racinet authored
      Even the `Heptapod` instance should not care about the `_webdriver`
      attribute, which is now an implementation detail.
      
      Also allows to close the webdriver immediately if there's any
      in `delete()`.
      6d0c5253aacc
    • Georges Racinet's avatar
      User: made webdriver a property · 391820b64471
      Georges Racinet authored
      Now the creation of the webdriver and the login sequence are
      all transparently (and lazily) handled by the `User` instance.
      
      This is much simpler for tests, as demonstrated in the case
      of the test with the external_user fixture.
      
      This makes `Heptapod.get_user_webdriver` fairly trivial.
      391820b64471
    • Georges Racinet's avatar
      User: adopted `session.login` · 341c98d15d38
      Georges Racinet authored
      341c98d15d38
    • Georges Racinet's avatar
      User: adopted session.ensure_user · 6bb7ef588881
      Georges Racinet authored
      This follows up on the principle that the `session` module should
      be lower level than the `Heptapod` and `User` classes and prepares
      for future refactorings by avoiding import loops.
      6bb7ef588881
    • Georges Racinet's avatar
      session, User: avoid ambiguity in login flow · c49a65be9f69
      Georges Racinet authored
      The `session` module should be about lower level, not
      object-oriented, primitives that don't care about
      caching of web drivers and generally maintaining state.
      
      The `login_as_user()` method did not fit there, because
      it called to the Heptapod object, which does exactly that.
      This was an ambiguity, that could easily lead to infinite
      loops when developping new features.
      
      It is a better fit on the `User` class. Actually the next
      natural move would be to make `webdriver` a property, renaming
      the current attribute to `_webdriver` as already done with
      `python_gitlab_client`.
      
      The only caller, in `test_projects`, is updated by this.
      c49a65be9f69
  2. 16 Feb, 2021 1 commit
  3. 15 Feb, 2021 2 commits
    • Georges Racinet's avatar
      User: non admin SSH key management · f613b1a6371a
      Georges Racinet authored
      For User instances that already have a token, it is now
      possible to manage SSH keys even if the root password is
      unknown to the tests.
      
      --HG--
      branch : stable
      f613b1a6371a
    • Georges Racinet's avatar
      Heptapod: users registry now contains User instances · 6b153b87be71
      Georges Racinet authored
      This solves a discrepancy that has plagued the heptapod-tests
      code base for long.
      
      In the beginning, users where represented as simple dicts, themselves
      kept in a registry: `user` attribute of the `Heptapod` instance.
      Then, more advanced manipulation needs pushed to the creation of
      the `User` class, but the user registry wasn't updated at the time.
      
      The tricky part, explaining why it wasn't made right away is that
      we often start with a partial representation of the user: for instance
      not knowing its numeric id.
      
      Over time some of the test code has been updated to use higher-level
      methods of the `Heptapod` class, such as `get_user_webdriver()`, in
      prevision for the present move, but still, the registry values remained
      at heart just dicts, while lots of needed logic is implemented in
      the `User` class.
      
      Now we'll have `User` instances in the registry. That still leaves us
      with some illogical aspects, like lazy webdriver and token initialization
      indirected through the `Heptapod` class, instead of being transparent
      properties `User`. But from now on, improving on this should be incremental
      and involve identifiers easy to search in the code base.
      
      --HG--
      branch : stable
      6b153b87be71
  4. 20 Dec, 2020 1 commit
    • Georges Racinet's avatar
      Utilities to run tests with python-gitlab · 2f2562454c1c
      Georges Racinet authored
      The API handle (`gitlab.Gitlab` instance) can be retrieved on
      a `User` instance with `user.python_gitlab_client`).
      
      Since there are several GitLab API client libraries for Python,
      this raises the question whether we should make this
      conditional, and how to make variants if they cannot be installed
      in the same virtualenv (that's probably the case)
      2f2562454c1c
  5. 03 Nov, 2020 1 commit
  6. 17 Nov, 2020 1 commit
  7. 04 Aug, 2020 1 commit
  8. 23 Jul, 2020 2 commits
    • Georges Racinet's avatar
      User: more Heptapod access utilities · 0fe9ec517d14
      Georges Racinet authored
      This follows the general trend that these should be actually
      stored on `User` instances. For some new tests it's already
      more natural to access `webdriver` and `basic_auth_url` from
      the `User` instance.
      
      --HG--
      branch : heptapod-0-14
      0fe9ec517d14
    • Georges Racinet's avatar
      Moving ssh_command generation from User to Project · 45d6b1f8d53b
      Georges Racinet authored
      There's nothing Project specific about which key, and which
      SSH options to use: everything is related instead to the user.
      Besides, for Personal Snippets repository tests, we'll need to perform
      SSH operations without any Project context.
      
      --HG--
      branch : heptapod-0-14
      45d6b1f8d53b
  9. 05 Jun, 2020 7 commits
    • Georges Racinet's avatar
      User.token_headers() · 6cffadeb99cd
      Georges Racinet authored
      This is obviously the right place to mutualize the API token logic.
      Forfunately, token headers creation is not spread all over the
      tests, just in a few helper classes
      6cffadeb99cd
    • Georges Racinet's avatar
      Preparations: made webdriver for basic user lazy · f8b865f4cc43
      Georges Racinet authored
      This already saves us 5s at each startup.
      
      - `session.ensure_user()` doesn't initialize a webdriver any more.
      - `Heptapod.get_user_webdriver()` creates the driver if needed
        and stores it
      - `User.ensure_private_token()` now uses `Heptapod.get_user_webdriver()`
        instead of taking a webdriver argument
      f8b865f4cc43
    • Georges Racinet's avatar
      Preparations: caching user access tokens · 5f5ce18ee546
      Georges Racinet authored
      These can't be read with a webdriver, as it is a security feature
      of GitLab not to display them, that's why we where creating new
      ones for each session.
      
      Storing them in a cache file will help making the session startup
      time shorter. This is especially useful if launching a few tests
      repeatedly or with the tests that have to redo the preparations after
      an instance restart.
      5f5ce18ee546
    • Georges Racinet's avatar
      User: new api_get method · 952e922d9db5
      Georges Racinet authored
      Can be used to obtain more information about the user, and also
      to test that an existing access token is working.
      952e922d9db5
    • Georges Racinet's avatar
      Session: moved user personal token generation to User class · b0029b6dec0c
      Georges Racinet authored
      A prelude to forthcoming changes to cache it.
      
      the `create()` class method will automatically store the user
      information in the Heptapod instance, but `search()` won't,
      because it doesn't have the password information (but its caller
      might)
      b0029b6dec0c
    • Georges Racinet's avatar
      User: separate class method to make the root User instance · 2c804ca57156
      Georges Racinet authored
      Having name and id harcoded, it's better to have a single method
      in case we'd want to hardcode less or change things.
      2c804ca57156
    • Georges Racinet's avatar
      User: nicer repr() · 68c3ffafbb62
      Georges Racinet authored
      We don't need to repeat the Heptapod instance in all log messages,
      nor the password
      68c3ffafbb62
  10. 27 Apr, 2020 2 commits
    • Georges Racinet's avatar
      User and session: login_as_user · aa40b4a18f75
      Georges Racinet authored
      This new function allows to perform a webdriver login with
      a User instance. We have a bit of inconsistency here: it will
      work only for just-created Users (e.g by a fixture),
      not for those that `User.search()` can return -- unless we can
      assume the pasword is a standard one and we set it
      separately before calling `login_as_user()`.
      aa40b4a18f75
    • Georges Racinet's avatar
      New fixture: external_user · b4f1366b536e
      Georges Racinet authored
      As the name suggests, this user is set to "external". This is
      needed to test heptapod#256.
      
      As a fixture, it is created on the fly and deleted in teardown.
      b4f1366b536e
  11. 14 Dec, 2019 1 commit
    • Georges Racinet's avatar
      ssh: key management for testing users · 199fdc12838a
      Georges Racinet authored
      We embed two freshly created SSH keys for these tests,
      and provide the necessary infrastructure to register them
      in Heptapod and retrieve them in the tests.
      199fdc12838a
  12. 12 Aug, 2019 1 commit
  13. 03 Jul, 2019 1 commit
    • Georges Racinet's avatar
      Basic user management helpers · 4da54b2d54dc
      Georges Racinet authored
      Very basic create/search/delete (no user attributes management)
      The default password is the username, right-padded by dots.
      
      We don't create private tokens for them yet
      4da54b2d54dc