Skip to content

Commit

Permalink
Review feedback and test
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuart Bishop committed Jun 24, 2016
1 parent 4776a5e commit ab746aa
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
11 changes: 6 additions & 5 deletions demos/git/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ command to grant it access to your home directory:
snap connect git:home ubuntu-core:home
```

Only access the home directory is granted. You can see this containment
Only access to the home directory is granted. You can see this containment
in action by attempting to initialize a repository in /tmp:

```sh
Expand All @@ -18,10 +18,11 @@ $ /snap/bin/git init
fatal: Could not change back to '/tmp/foo': No such file or directory
```

Files repositories in your home directory work fine:
Initializing and using repositories in your home directory works fine:

```sh
$ mkdir -p ~/tmp/foo
$ cd ~/tmp/foo
$ mkdir -p $HOME/tmp/foo
$ cd $HOME/tmp/foo
$ /snap/bin/git init
Initialized empty Git repository in /home/stub/tmp/foo/.git/
Initialized empty Git repository in /home/ubuntu/tmp/foo/.git/
```
4 changes: 3 additions & 1 deletion demos/git/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ confinement: strict
apps:
git:
command: bin/git
# git will now have access to files outside of its containment
# git will not have access to files outside of its containment
# until you run the following command after installing the snap:
# snap connect git:home ubuntu-core:home
# After connecting up the home interface it gains access to
# non-hidden files in home directories.
plugs:
- home

Expand Down
31 changes: 31 additions & 0 deletions snaps_tests/demos_tests/test_git.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
#
# Copyright (C) 2016 Canonical Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import snaps_tests


class GitTestCase(snaps_tests.SnapsTestCase):

snap_content_dir = 'git'

def test_git(self):
self.build_snap(self.snap_content_dir)
self.install_snap(self.snap_content_dir, 'git', '0')
self.snappy_testbed.run_command(['sudo', 'snap', 'connect',
'git:home', 'ubuntu-core:home'])
self.assertTrue(
self.snappy_testbed.run_command(['/snap/bin/git',
'--version']).startswith('git'))

0 comments on commit ab746aa

Please sign in to comment.