{"id":23491694,"url":"https://github.com/halfbyte/oa-testing","last_synced_at":"2025-04-14T22:50:55.297Z","repository":{"id":65429534,"uuid":"1171591","full_name":"halfbyte/oa-testing","owner":"halfbyte","description":"Aids integration testing of OmniAuth functionality. WORK IN PROGRESS!","archived":false,"fork":false,"pushed_at":"2010-12-16T08:57:06.000Z","size":909,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-16T12:27:59.707Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/halfbyte.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-12-15T16:28:18.000Z","updated_at":"2018-04-20T05:07:56.000Z","dependencies_parsed_at":"2023-01-23T08:15:19.232Z","dependency_job_id":null,"html_url":"https://github.com/halfbyte/oa-testing","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halfbyte%2Foa-testing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halfbyte%2Foa-testing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halfbyte%2Foa-testing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halfbyte%2Foa-testing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/halfbyte","download_url":"https://codeload.github.com/halfbyte/oa-testing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248975299,"owners_count":21192199,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-25T01:29:15.263Z","updated_at":"2025-04-14T22:50:55.255Z","avatar_url":"https://github.com/halfbyte.png","language":"Ruby","readme":"OmniAuth Testing\n================\n\nAids integration testing of OmniAuth functionality in your app by providing fake\nresponses through FakeWeb for various providers such as Twitter, Facebook,\nOpenID, etc.\n\nInstallation \u0026 Usage\n--------------------\n\nTo install, add this to the Gemfile `test` group and run `bundle`:\n\n    gem 'oa-testing'\n\nUsage is very simple, as `oa-testing` automatically registers the appropriate\nfake responses when you add a provider to the middleware stack.\n\nAssuming you are using Cucumber, this is how a snippet of the \"User signs up\"\nfeature (or whatever it is called) might look:\n\n    When I follow \"Sign up using Twitter.\"\n    And I have authorized the app to read my info\n\nThe first step might take the user to `/auth/twitter`. The definition of the\nsecond step might look like this:\n\n    When /^I have authorized the app to read my info$/ do\n      visit '/auth/twitter/callback'\n    end\n\nThis approach results in the closest mirroring of normal, non-testing behavior,\nsince it allows OmniAuth to work through both the *request phase* and *access\nphase*, as opposed to jumping directly to the latter \u0026mdash; also known as \"short\ncircuiting\".\n\nDon't \"short circuit\"\n---------------------\n\nIf you're using OmniAuth through Devise you might have noticed that [the\nsuggested way to avoid requests to providers](https://github.com/plataformatec/devise/wiki/OmniAuth:-Testing)\nis to \"short circuit\" links to them, i.e. to link directly to the callback.\nHowever, I do not recommend this approach for the simple reason that it doesn't\nwork in some cases. For instance, this is what the process of authorizing\nthrough Twitter looks like:\n\n  1. The user clicks the link for authorizing through Twitter (e.g.\n     `/auth/twitter`), after which the *request phase* begins.\n  2. OmniAuth fetches a *request token* from Twitter which it stores in the\n     current session.\n  3. OmniAuth redirects to the *authorize URL* (e.g. `https://api.twitter.com/oauth/authenticate?oauth_token=...`)\n     where `oauth_token` is the request token.\n  4. The user signs in to Twitter if needed and authorizes the app if he haven't\n     already.\n  5. Twitter redirects back to the app (e.g. to `/auth/twitter/callback`),\n     triggering the *callback phase*.\n  6. OmniAuth fetches an *access token* from Twitter based on the previously\n     stored request token.\n  7. OmniAuth uses the access token to retrieve the user information.\n\nThere are uncovered details, but the description above should be sufficient to\nmake my point: By linking directly to the callback you're effectively skipping\nthe request phase, which in the case of Twitter results in OmniAuth trying to\nuse a session value that hasn't actually been set.\n\nSupported Providers\n-------------------\n\nAt the moment only Twitter is supported. I'm currently working on an app that\nuses OmniAuth, and I'm going through Twitter, Facebook, Google Apps, and OpenID\none by one, trying to figure out how to integration test sign-up and sign-in\nfor each of them, so hopefully `oa-testing` will eventually support all of\nthose. Naturally, you are very welcome to contribute support for other providers\nif you happen to know the appropriate fake responses.\n\nContributing\n------------\n\n  1. Fork the project on GitHub.\n  2. Push your changes to a topic branch of your fork.\n  3. Send me a pull request.\n\nDon't forget that tests are required for a pull request to be accepted!\n\nCopyright\n---------\n\nCopyright \u0026copy; 2010 David Trasbo of Insane Innovation \u0026mdash; See `LICENSE` for more\ndetail.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalfbyte%2Foa-testing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhalfbyte%2Foa-testing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalfbyte%2Foa-testing/lists"}