-
Notifications
You must be signed in to change notification settings - Fork 73
providers/base: add fscrypt test (New) #2215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
3334c41 to
bc7d5f2
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2215 +/- ##
==========================================
+ Coverage 53.70% 53.81% +0.11%
==========================================
Files 401 402 +1
Lines 43144 43258 +114
Branches 7996 8022 +26
==========================================
+ Hits 23170 23281 +111
- Misses 19161 19162 +1
- Partials 813 815 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
c4de44f to
cef64d9
Compare
hawesy-can
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I'm not an expert in this area.
providers/base/bin/fscrypt_test.py
Outdated
| text=True, | ||
| ) | ||
| found = False | ||
| pattern = re.compile(rf"^{re.escape(str(mnt))}.*supported *Yes$") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignoring the CI run which failed at this line with an invalid syntax error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what's wrong there. I do not reproduce on my side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fstring does not exsit in python 3.5!
4aba6b4 to
9a34ccc
Compare
3de25d3 to
4e57c8d
Compare
pieqq
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the long silence. I've added a few comments, see if they make sense.
providers/base/bin/fscrypt_test.py
Outdated
| You should have received a copy of the GNU General Public License | ||
| along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| The purpose of this scrupt is to make a small fscrupt test on a generated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| The purpose of this scrupt is to make a small fscrupt test on a generated | |
| The purpose of this script is to make a small fscrypt test on a generated |
providers/base/bin/fscrypt_test.py
Outdated
| ) | ||
| found = False | ||
| pattern = re.compile( | ||
| "^{}.*supported *Yes$".format(re.escape(str(mnt))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| "^{}.*supported *Yes$".format(re.escape(str(mnt))) | |
| "^{}.*supported\s*Yes$".format(re.escape(str(mnt))) |
I'm not sure if fscrypt uses tabs as well in its output, it's probably better to catch any kind of space there.
providers/base/bin/fscrypt_test.py
Outdated
| "--quiet", | ||
| "--source=raw_key", | ||
| "--name=test_key", | ||
| f"--key={str(key_file)}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f-strings are not supported in python 3.5 which we still support, so please use .format instead.
|
|
||
| with test_file.open("r") as f: | ||
| content = f.read().strip() | ||
| if content != test_content: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For easier debugging or review, please print the expected content and the actual content before raising SystemExit.
| print("File is accessible and content is correct after unlock") | ||
| finally: | ||
| subprocess.check_call(["umount", str(mnt)]) | ||
| if not fscrypt_setup and fscrypt_config.exists(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure to understand this line, given that at the top of the script, you set
fscrypt_setup = fscrypt_config.exists()
What's the expectation here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending if there was an error during the test, the configuration might not have been created. I could just remove the test (the exists() one) and do a "rm -f" if you prefer.
d8b9f0f to
270f461
Compare
New: Add a small fscrypt test into the base provider, in its own category.
Description
The new fscrypt test generates an ext4 disk image, mount it and setup fscrypt.
Then it creates a file in the disk image mountpoint, locks it and verifies that the file is not accessible anymore. Finally, it unlocks it and check that the file is accessible and its content is correct.
Tests
checkbox-cli, selectautomated fscrypt test, run the test plan. Tested on my laptop and on my project device (qualcomm arm64 device). Testing with fscrypt already setup and not setup.