Skip to content

Commit

Permalink
Merge pull request #168 from zcutlip/development
Browse files Browse the repository at this point in the history
merge development into main: v4.0.0
  • Loading branch information
zcutlip committed Nov 6, 2023
2 parents 3ced5ac + a2b3229 commit 4e551ed
Show file tree
Hide file tree
Showing 316 changed files with 15,604 additions and 2,878 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [zcutlip]
4 changes: 2 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ["3.8", "3.9", "3.10", "3.11"]
python: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
Expand Down
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ celerybeat-schedule
*.sage.py

# Environments
dot_env_files/.env*
.env
.env_secret*
.venv
env/
venv/
Expand All @@ -123,7 +125,9 @@ dmypy.json
# Pyre type checker
.pyre/

.vscode
.vscode/*
!/.vscode/settings.json
!/.vscode/launch.json

.idea/
# General
Expand Down Expand Up @@ -161,6 +165,13 @@ Temporary Items
/sanitize.cfg
# ignore private response-generation configs
*private*cfg
/responses_archive

# Makefile stamps
.*stamp

# General
.vagrant/

# Log files (if you are creating logs in debug mode, uncomment this)
# *.log
4 changes: 4 additions & 0 deletions .init/00_pyonepassword
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,9 @@ then
compdef _local_branches deletebranch_pyop pytest_pyop mypy_pyop
fi

if [ -f "$_pyonepasswd_src_root/dot_env_files/.env_pyonepassword_test_rw" ];
then
alias op_sa_rw="\$_pyonepasswd_src_root/scripts/op_env \$_pyonepasswd_src_root/dot_env_files/.env_pyonepassword_test_rw"
fi

unset _realhome
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-json
exclude: ^\.vscode\/.*$
- id: check-yaml
- id: check-merge-conflict
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: 'v2.0.2'
- repo: https://github.com/hhatto/autopep8
rev: 'v2.0.4'
hooks:
- id: autopep8
- repo: https://github.com/pycqa/isort
Expand Down
149 changes: 149 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true
},
{
"name": "sanitize.py",
"type": "python",
"request": "launch",
"program": "scripts/sanitize.py",
"console": "integratedTerminal",
"justMyCode": true,
"args": [
"./sanitize.cfg"
]
},
{
"name": "versions.py",
"type": "python",
"request": "launch",
"program": "examples/versions.py",
"console": "integratedTerminal",
"justMyCode": false
},
{
"name": "debug op forget",
"type": "python",
"request": "launch",
"program": "ipython_snippets/debug.py",
"console": "integratedTerminal"
},
{
"name": "load from json",
"type": "python",
"request": "launch",
"program": "ipython_snippets/load_json_item.py",
"console": "integratedTerminal",
"justMyCode": false
},
{
"name": "new server",
"type": "python",
"request": "launch",
"module": "examples.server"
},
{
"name": "create_item",
"type": "python",
"request": "launch",
"program": "examples/create_item.py",
"console": "integratedTerminal"
},
{
"name": "server ssh keys",
"type": "python",
"request": "launch",
"program": "examples/server-ssh-keys.py",
"console": "integratedTerminal",
"args": [
"Mustafar",
"id_ed25519",
"--vault",
"Machine Credentials",
"--outdir",
"./mustafar-keys"
]
},
{
"name": "mock op",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/mop.py",
"console": "integratedTerminal",
"args": [
"get",
"item",
"Example Login 1",
"--vault",
"Test Data"
]
},
{
"name": "Python: example signin, get item",
"type": "python",
"request": "launch",
"program": "examples/example-signin-get-item.py",
"console": "integratedTerminal"
},
{
"name": "Python: example signin, get document",
"type": "python",
"request": "launch",
"program": "examples/example-signin-get-document.py",
"console": "integratedTerminal"
},
{
"name": "Python: example signin, signout",
"type": "python",
"request": "launch",
"program": "examples/example-signin-signout.py",
"console": "integratedTerminal"
},
{
"name": "example-signin-get-vault",
"type": "python",
"request": "launch",
"program": "examples/example-signin-get-vault.py",
"console": "integratedTerminal"
},
{
"name": "example list items",
"type": "python",
"request": "launch",
"program": "examples/list-items.py",
"console": "integratedTerminal"
},
{
"name": "create items",
"type": "python",
"request": "launch",
"program": "examples/create-item.py",
"console": "integratedTerminal"
},
{
"name": "item edit field type",
"type": "python",
"request": "launch",
"program": "examples/debug_item_edit_field_type.py",
"console": "integratedTerminal"
},
{
"name": "example-service-account",
"type": "python",
"request": "launch",
"program": "examples/example-service-account.py",
"envFile": "${workspaceFolder}/debug_env/svc_acct_env",
"console": "integratedTerminal"
},
]
}
16 changes: 16 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"files.trimTrailingWhitespace": true,
"files.trimFinalNewlines": true,
"files.associations": {
"00_pyonepassword": "shellscript"
},
"files.insertFinalNewline": true,
"isort.args": [
"-m",
"3"
],
"search.useIgnoreFiles": true,

}
52 changes: 52 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,58 @@

All notable changes to this project will be documented in this file.

## [4.0.0] 2023-11-06

### Added
- Item editing (gh-143):
- `OP.item_edit_add_password_field()`
- `OP.item_edit_add_url_field()`
- `OP.item_edit_add_text_field()`
- `OP.item_edit_set_password()`
- `OP.item_edit_set_url_field()`
- `OP.item_edit_set_text_field()`
- `OP.item_edit_delete_field()`
- `OP.item_edit_favorite()`
- `OP.item_edit_generate_password()`
- `OP.item_edit_tags()`
- `OP.item_edit_title()`
- `OP.item_edit_url()`

- `OPAbstractItem.field_value_by_section_label()` (gh-144)
- replacement for poorly named `field_value_by_section_title()`

- Support for `op` new `whoami` behavior version 2.20.0 (gh-146)
- new `whoami` dict
- On `OP()` initialization, accomodate `whoami` failure when the token hasn't been used recently

### Changed
- Added Python 3.12 support (gh-152)
- Removed Python 3.8 support (gh-152)
- Ensure all methods for section lookup by label raise `OPSectionNotFound` if no section is found matching the given label (gh-144)
- Ensure all methods for field lookup by label raise `OPFieldNotFound` if no field is found matching the given label (gh-144)

### Deprecated

- `OPAbstractItem.field_value_by_section_title()` (gh-144)
- call `OPAbstractItem.field_value_by_section_label()` instead

### Removed

- Deprecated kwargs to `OP()`: (gh-161)
- `use_existing_session` (replaced by `existing_auth`)
- `account_shorthand` (replaced by `account`)
- Deprecated exception `OPNotSignedInException` class (gh-161)
- replaced with `OPAuthenticationException`

### Documentation
- Documented item editing in `docs/item-editing.md`
- Added set of item editing examples under `examples/item_editing`

### Misc
- Updated testing configuration in conjuncton with refactored `mock-op`
- Add `FUNDING.yml`
- Have `setup.py` automatically convert relative URLs in `long_description` to absolute GitHub URLs so they work on PyPI

## [3.12.1] 2023-06-26

### Fixed
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ COV_STAMP=.cov_stamp
TOX_STAMP=.tox_stamp
HTML_REPORT_STAMP=".html_report_stamp"

PYONEPASSWORD_SRC_FILES=$(shell find ./pyonepassword -name \*\.py -print)
# find all *.py and *.json files under pyonepassword
PYONEPASSWORD_SRC_FILES=$(shell find ./pyonepassword -name \*\.py -print -o -name \*\.json -print)
# find all regular files under tests excluding *.pyc, and reports/
# this should include *.py, *.json, *.txt plus files without extensions
PYONEPASSWORD_TEST_FILES=$(shell find tests -name \*\.pyc -prune -o -name reports -prune -o -type f -print)

all:
Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A Python API to sign into and query a 1Password account using the `op` command.

## Requirements

- Python >= 3.8
- Python >= 3.9
- 1Password command-line tool >= 2.0.0
- see [1Password Developer Documentation](https://developer.1password.com/docs/cli)
- Internet connectivity to 1Password.com
Expand Down Expand Up @@ -144,7 +144,7 @@ If you want to fully automate connecting to and querying a 1Password account, th

All of these methods return objects types as described above. Also, `item_get()` returns the appropriate object type for the item, such as `OPLoginItem` or `OPSecureNoteItem`, as long as `pyonepassword` has a class for the returned item type.

> *Note*: In some cases the `op` command may return items that don't conform to the expected structure. When this happens, the item dictionary will fail to validate, an exception will be raised. There is API for relaxing item validation, globally, on a per-class basis, or a per-item basis. See [ITEM_VALIDATION.md](ITEM_VALIDATION.md) for more information.
> *Note*: In some cases the `op` command may return items that don't conform to the expected structure. When this happens, the item dictionary will fail to validate, an exception will be raised. There is API for relaxing item validation, globally, on a per-class basis, or a per-item basis. See [item-validation.md](docs/item-validation.md) for more information.
### Sign-in and item retrieval

Expand Down Expand Up @@ -341,8 +341,16 @@ def main():

### Item Creation

For details on creating new items in a 1Password vault, see [ITEM_CREATION.md](ITEM_CREATION.md)
For details on creating new items in a 1Password vault, see [item-creation.md](docs/item-creation.md)

Also see the examles in [examples/item_creation](examples/item_creation/)


### Item Editing

For details on editing existing items in a 1Password vault, see [item-editing.md](docs/item-editing.md)

Also see the examles in [examples/item_editing](examples/item_editing/)

### More Examples

Expand Down
2 changes: 1 addition & 1 deletion docker_testing/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"

docker buildx build "$SCRIPT_DIR"/docker/ -f "$SCRIPT_DIR"/docker/py38.Dockerfile -t docker_py38 || exit
docker buildx build "$SCRIPT_DIR"/docker/ -f "$SCRIPT_DIR"/docker/py39.Dockerfile -t docker_py39 || exit
docker buildx build "$SCRIPT_DIR"/docker/ -f "$SCRIPT_DIR"/docker/py310.Dockerfile -t docker_py310 || exit
docker buildx build "$SCRIPT_DIR"/docker/ -f "$SCRIPT_DIR"/docker/py311.Dockerfile -t docker_py311 || exit
docker buildx build "$SCRIPT_DIR"/docker/ -f "$SCRIPT_DIR"/docker/py312.Dockerfile -t docker_py312 || exit
4 changes: 3 additions & 1 deletion docker_testing/clean.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/sh

docker image rm docker_py39 docker_py38 docker_py310 docker_py311
# keep unused docker image names so we can ensure they get removed
# this should not be an error
docker image rm docker_py38 docker_py39 docker_py310 docker_py311 docker_py312
rm -rf .tox-docker
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.8
FROM python:3.12

RUN useradd -ms /bin/bash unpriv

Expand All @@ -14,6 +14,6 @@ ENV TESTDIR=/usr/src/testdir
# PYVER_FACTOR gets passed to:
# tox run -f $PYVER_FACTOR
# so e.g., all py311-{something,something-else} envs get run
ENV PYVER_FACTOR=py38
ENV PYVER_FACTOR=py312
COPY test.sh /test.sh
CMD [ "/test.sh" ]
Loading

0 comments on commit 4e551ed

Please sign in to comment.