Friday, March 24, 2017

#AWS #IAM introductions

What is IAM?

Essentially, IAM allows you to manage users and their level of access to the AWS console.

What does IAM give you?

Centralised control of your AWS account.
Shared Access of your AWS account
Granular Permissions
Identity Federation ( including Active Directory, Facebook, Linkedin etc )
Mutifactor Authentication
Provide temporary access for users/devices and services where necessary
Allows you to set up your own password rotation policy 
Integrates with many different AWS services
Supports PCI DSS Compliance
Free to use

Critical Terms:

Users
Groups - A collection of users under on set of permissions. 
Roles - You create roles and can then assign them to AWS resources. 
Policies - A document that defines one ( or more permissions 


Sunday, March 12, 2017

#AWS Root path access denined on #S3 Static Website Hosting with #CloudFront

Problem. Access Denied on root path of cloudfront's endpoint.


I see Access Denined even I configured 'Index Document' on S3.
And access root path with S3' endpoint works perfect.

Answer. Default Root Object on CloudFront

Configure 'Default Root Object' property on cloudfront same as S3's 'Index Document'.


Friday, March 10, 2017

#Android How to setup test environment with Robolectric

1. ADD dependencies

    testCompile 'org.mockito:mockito-core:1.10.19'
    testCompile "org.robolectric:robolectric:3.3.1"
    testCompile "org.robolectric:shadows-multidex:3.0"
    testCompile 'org.khronos:opengl-api:gl1.1-android-2.1_r1'

2. Create Test Class for Activity 

if you have a activity at 'src/main/java/com.example.activity.SomeActivity', 
create test activity at 'src/test/java/com.example.activitySomeActivityTest'.

* Edit Run Configuration , if you use OSX or linu.



3. Write Test Code 


@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 22)
public class LoginActivityTest {

    private LoginActivity subject;
    private EditText editTextId;
    private EditText editTextPass;
    private Button buttonLogin;

    @Before
    public void setUp() throws Exception {
        subject = Robolectric.setupActivity(LoginActivity.class);
        editTextId = (WashEditText) subject.findViewById(R.id.layoutEmail);
        editTextPass = (WashEditText) subject.findViewById(R.id.layoutPw);
        buttonLogin = (Button) subject.findViewById(R.id.btnLogin);
        subject.loginCommunicator = mock(LoginCommunicator.class);
    }

    @Test
    public void loginWithoutEmail() throws Exception {
        buttonLogin.performClick();
        ShadowLooper.idleMainLooper();
        verify(subject.loginCommunicator, never()).requestLoginEmail(eq("liketaehoon@gmail.com"), eq(CommonUtil.password("1234")), anyString(), any(WashResponse.Listener.class));
        assertThat( ShadowToast.getTextOfLatestToast(), equalTo(subject.getString(R.string.error_input_email)));
    }
}
4. Run Test